VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlLockfreeQueue.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2014 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
9 #pragma once
10 
11 #ifdef WIN32
12 #if _MSC_VER < 1400 // MSVC++ 8.0 2005
13 #define LOCKFREEQUEUE_UNSUPPORTED
14 #endif
15 #endif
16 
17 #ifndef LOCKFREEQUEUE_UNSUPPORTED
18 
19 #include <vlutil/vlMachineTypes.h>
20 
21 #ifdef DtUSE_UTILITIES_NAMESPACE
22 namespace DtUSE_UTILITIES_NAMESPACE
23 {
24 #endif
25 
26 
28 {
29 public:
30  DtLockfreeQueueImpl(size_t sizeToUse);
31 
32  virtual ~DtLockfreeQueueImpl();
33 
34  size_t _size() const;
35 
36  bool _push(void* const & t);
37 
38  size_t _pop(void* & ret);
39 
40  bool _empty();
41 
45  size_t _read_available() const;
46 
50  size_t _write_available() const;
51 
52 private:
53  void* myQueue;
54  size_t mySize;
55 };
56 
57 template<class T>
59 {
60 
61 public:
62 
63  DtLockfreeQueue(size_t sizeToUse) : DtLockfreeQueueImpl(sizeToUse)
64  {
65  }
66 
68  {
69 
70  }
71 
72  inline size_t size() const
73  {
74  return _size();
75  }
76 
77  inline bool push(T const & t)
78  {
79  return _push(reinterpret_cast<void*>(t));
80  }
81 
82  inline size_t pop(T & ret)
83  {
84  return _pop(reinterpret_cast<void* &>(ret));
85  }
86 
87  inline bool empty(void)
88  {
89  return _empty();
90  }
91 
95  inline size_t readAvailableForConsumption() const
96  {
97  return _read_available();
98  }
99 
103  inline size_t writeAvailableForProduction() const
104  {
105  return _write_available();
106  }
107 
111  inline size_t writtenAvailableForConsumption() const
112  {
113  return size() - writeAvailableForProduction();
114  }
115 };
116 
117 
118 #ifdef DtUSE_UTILITIES_NAMESPACE
119 } // end of namespace DtUSE_UTILITIES_NAMESPACE
120 #endif
121 
122 #endif

Document ID: Generated on Thu Feb 22 04:26:36 EST 2018 from SVN revision 186468
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)