Changeset 46185 in vbox for trunk/include/iprt
- Timestamp:
- May 21, 2013 6:28:49 AM (12 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/queueatomic.h
r45777 r46185 1 1 /** @file 2 * IPRT - Generic Work Queue with concurrent a ccess.2 * IPRT - Generic Work Queue with concurrent atomic access. 3 3 */ 4 4 … … 24 24 */ 25 25 26 #ifndef ___iprt_ workqueue_h27 #define ___iprt_ workqueue_h26 #ifndef ___iprt_queueatomic_h 27 #define ___iprt_queueatomic_h 28 28 29 29 #include <iprt/types.h> 30 30 #include <iprt/asm.h> 31 31 32 /** @defgroup grp_rt_list RT WorkQueue- Generic Work Queue32 /** @defgroup grp_rt_list RTQueueAtomic - Generic Work Queue 33 33 * @ingroup grp_rt 34 34 * … … 42 42 * A work item 43 43 */ 44 typedef struct RT WORKITEM44 typedef struct RTQUEUEATOMICITEM 45 45 { 46 46 /** Pointer to the next work item in the list. */ 47 struct RT WORKITEM * volatile pNext;48 } RT WORKITEM;47 struct RTQUEUEATOMICITEM * volatile pNext; 48 } RTQUEUEATOMICITEM; 49 49 /** Pointer to a work item. */ 50 typedef RT WORKITEM *PRTWORKITEM;50 typedef RTQUEUEATOMICITEM *PRTQUEUEATOMICITEM; 51 51 /** Pointer to a work item pointer. */ 52 typedef PRT WORKITEM *PPRTWORKITEM;52 typedef PRTQUEUEATOMICITEM *PPRTQUEUEATOMICITEM; 53 53 54 54 /** 55 55 * Work queue. 56 56 */ 57 typedef struct RT WORKQUEUE57 typedef struct RTQUEUEATOMIC 58 58 { 59 59 /* Head of the work queue. */ 60 volatile PRT WORKITEM pHead;61 } RT WORKQUEUE;60 volatile PRTQUEUEATOMICITEM pHead; 61 } RTQUEUEATOMIC; 62 62 /** Pointer to a work queue. */ 63 typedef RT WORKQUEUE *PRTWORKQUEUE;63 typedef RTQUEUEATOMIC *PRTQUEUEATOMIC; 64 64 65 65 /** … … 68 68 * @param pWorkQueue Pointer to an unitialised work queue. 69 69 */ 70 DECLINLINE(void) RT WorkQueueInit(PRTWORKQUEUEpWorkQueue)70 DECLINLINE(void) RTQueueAtomicInit(PRTQUEUEATOMIC pWorkQueue) 71 71 { 72 72 ASMAtomicWriteNullPtr(&pWorkQueue->pHead); … … 79 79 * @param pItem The item to insert. 80 80 */ 81 DECLINLINE(void) RT WorkQueueInsert(PRTWORKQUEUE pWorkQueue, PRTWORKITEM pItem)81 DECLINLINE(void) RTQueueAtomicInsert(PRTQUEUEATOMIC pWorkQueue, PRTQUEUEATOMICITEM pItem) 82 82 { 83 PRT WORKITEM pNext = ASMAtomicUoReadPtrT(&pWorkQueue->pHead, PRTWORKITEM);84 PRT WORKITEM pHeadOld;83 PRTQUEUEATOMICITEM pNext = ASMAtomicUoReadPtrT(&pWorkQueue->pHead, PRTQUEUEATOMICITEM); 84 PRTQUEUEATOMICITEM pHeadOld; 85 85 pItem->pNext = pNext; 86 86 while (!ASMAtomicCmpXchgExPtr(&pWorkQueue->pHead, pItem, pNext, &pHeadOld)) … … 99 99 * @param pWorkQueue The work queue. 100 100 */ 101 DECLINLINE(PRT WORKITEM) RTWorkQueueRemoveAll(PRTWORKQUEUEpWorkQueue)101 DECLINLINE(PRTQUEUEATOMICITEM) RTQueueAtomicRemoveAll(PRTQUEUEATOMIC pWorkQueue) 102 102 { 103 PRT WORKITEM pHead = ASMAtomicXchgPtrT(&pWorkQueue->pHead, NULL, PRTWORKITEM);103 PRTQUEUEATOMICITEM pHead = ASMAtomicXchgPtrT(&pWorkQueue->pHead, NULL, PRTQUEUEATOMICITEM); 104 104 105 105 /* Reverse it. */ 106 PRT WORKITEM pCur = pHead;106 PRTQUEUEATOMICITEM pCur = pHead; 107 107 pHead = NULL; 108 108 while (pCur) 109 109 { 110 PRT WORKITEM pInsert = pCur;110 PRTQUEUEATOMICITEM pInsert = pCur; 111 111 pCur = pCur->pNext; 112 112 pInsert->pNext = pHead;
Note:
See TracChangeset
for help on using the changeset viewer.