Dali 3D User Interface Engine
lockless-buffer.h
Go to the documentation of this file.
1 #ifndef __DALI_INTEGRATION_LOCKLESS_BUFFER_H__
2 #define __DALI_INTEGRATION_LOCKLESS_BUFFER_H__
3 
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20 
21 // EXTERNAL INCLUDES
22 
23 // INTERNAL INCLUDES
24 #include <cstring>
27 
28 namespace Dali
29 {
30 
31 namespace Integration
32 {
33 
48 {
49 
50 public:
55  LocklessBuffer( size_t size );
56 
60  ~LocklessBuffer();
61 
67  void Write( const unsigned char *src, size_t size );
68 
74  const unsigned char* Read();
75 
79  unsigned int GetSize() const;
80 
81 private:
88  {
89  R0W1 = 0,
90  R1W0 = 1,
91  WRITING = 2,
92  UPDATED = 4,
93  WRITE_BUFFER_MASK = 1,
94  WRITING_MASK = 2,
95  UPDATED_MASK = 4
96  };
97 
98 private:
99  LocklessBuffer();
100  LocklessBuffer( const LocklessBuffer& );
101  LocklessBuffer& operator=( const LocklessBuffer& );
102 
103 private:
104  unsigned char* mBuffer[2];
105  BufferState volatile mState;
106  size_t mSize;
107 };
108 
109 } // Internal
110 
111 } // Dali
112 
113 #endif // __DALI_INTEGRATION_LOCKLESS_H__
Dali Docs Home
Read more about Dali