OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 #ifndef PPAPI_MAIN_PPAPI_QUEUE_H | 6 #ifndef PPAPI_MAIN_PPAPI_QUEUE_H |
7 #define PPAPI_MAIN_PPAPI_QUEUE_H | 7 #define PPAPI_MAIN_PPAPI_QUEUE_H |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 bool AddNewMessage(void* msg); | 54 bool AddNewMessage(void* msg); |
55 void* RemoveStaleMessage(); | 55 void* RemoveStaleMessage(); |
56 | 56 |
57 // | 57 // |
58 // Consumer API | 58 // Consumer API |
59 // | 59 // |
60 // The reader will attempt to Acquire the top message, if one is not | 60 // The reader will attempt to Acquire the top message, if one is not |
61 // available NULL will be returned. Once the consumer is done with the | 61 // available NULL will be returned. Once the consumer is done with the |
62 // message, ReleaseTopMessage is called to signal that the payload is no | 62 // message, ReleaseTopMessage is called to signal that the payload is no |
63 // longer visible to the consumer and can be recycled or destroyed. | 63 // longer visible to the consumer and can be recycled or destroyed. |
64 // Since messages are freed in order, it is recquired that messages are | 64 // Since messages are freed in order, it is required that messages are |
65 // consumed in order. For this reason, it is illegal to call Acquire again | 65 // consumed in order. For this reason, it is illegal to call Acquire again |
66 // after a non-NULL message pointer is returned, until Release is called on | 66 // after a non-NULL message pointer is returned, until Release is called on |
67 // the old message. This means the consumer can only look at one message | 67 // the old message. This means the consumer can only look at one message |
68 // at a time. To look at multiple messages at once, the consumer would | 68 // at a time. To look at multiple messages at once, the consumer would |
69 // need to make a copy and release the top message. | 69 // need to make a copy and release the top message. |
70 // | 70 // |
71 void* AcquireTopMessage(); | 71 void* AcquireTopMessage(); |
72 void ReleaseTopMessage(void* msg); | 72 void ReleaseTopMessage(void* msg); |
73 | 73 |
74 private: | 74 private: |
75 uint32_t read_; | 75 uint32_t read_; |
76 uint32_t write_; | 76 uint32_t write_; |
77 uint32_t freed_; | 77 uint32_t freed_; |
78 uint32_t size_; | 78 uint32_t size_; |
79 void* last_msg_; | 79 void* last_msg_; |
80 void** array_; | 80 void** array_; |
81 }; | 81 }; |
82 | 82 |
83 | 83 |
84 #endif // PPAPI_MAIN_PPAPI_QUEUE_H | 84 #endif // PPAPI_MAIN_PPAPI_QUEUE_H |
OLD | NEW |