| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * be found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 /* | 7 /* |
| 8 * NaCl service runtime synchronized queue. | 8 * NaCl service runtime synchronized queue. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "native_client/src/shared/platform/nacl_check.h" | 11 #include "native_client/src/shared/platform/nacl_check.h" |
| 12 #include "native_client/src/shared/platform/nacl_log.h" | 12 #include "native_client/src/shared/platform/nacl_log.h" |
| 13 #include "native_client/src/shared/platform/nacl_sync_checked.h" | 13 #include "native_client/src/shared/platform/nacl_sync_checked.h" |
| 14 | 14 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 void *NaClSyncQueueDequeue(struct NaClSyncQueue *nsqp) { | 99 void *NaClSyncQueueDequeue(struct NaClSyncQueue *nsqp) { |
| 100 struct NaClSyncQueueItem *qitem; | 100 struct NaClSyncQueueItem *qitem; |
| 101 void *item; | 101 void *item; |
| 102 | 102 |
| 103 NaClLog(3, "NaClSyncQueueDequeue: waiting on queue 0x%08"NACL_PRIxPTR"\n", | 103 NaClLog(3, "NaClSyncQueueDequeue: waiting on queue 0x%08"NACL_PRIxPTR"\n", |
| 104 (uintptr_t) nsqp); | 104 (uintptr_t) nsqp); |
| 105 NaClXMutexLock(&nsqp->mu); | 105 NaClXMutexLock(&nsqp->mu); |
| 106 while (NaClSyncQueueEmptyMu(nsqp) && !nsqp->quit) { | 106 while (NaClSyncQueueEmptyMu(nsqp) && !nsqp->quit) { |
| 107 NaClLog(3, "NaClSyncQueueDequeue: waiting\n"); | 107 NaClLog(3, "NaClSyncQueueDequeue: waiting\n"); |
| 108 NaClCondVarWait(&nsqp->cv, &nsqp->mu); | 108 NaClXCondVarWait(&nsqp->cv, &nsqp->mu); |
| 109 } | 109 } |
| 110 | 110 |
| 111 if (nsqp->quit) { | 111 if (nsqp->quit) { |
| 112 item = NULL; | 112 item = NULL; |
| 113 } else { | 113 } else { |
| 114 CHECK(!NaClSyncQueueEmptyMu(nsqp)); | 114 CHECK(!NaClSyncQueueEmptyMu(nsqp)); |
| 115 | 115 |
| 116 qitem = nsqp->head; | 116 qitem = nsqp->head; |
| 117 nsqp->head = qitem->next; | 117 nsqp->head = qitem->next; |
| 118 if (NULL == nsqp->head) { | 118 if (NULL == nsqp->head) { |
| 119 nsqp->insert_pt = &nsqp->head; | 119 nsqp->insert_pt = &nsqp->head; |
| 120 } | 120 } |
| 121 item = qitem->item; | 121 item = qitem->item; |
| 122 free(qitem); | 122 free(qitem); |
| 123 } | 123 } |
| 124 | 124 |
| 125 NaClXMutexUnlock(&nsqp->mu); | 125 NaClXMutexUnlock(&nsqp->mu); |
| 126 | 126 |
| 127 NaClLog(3, "NaClSyncQueueDequeue: returning item 0x%08"NACL_PRIxPTR"\n", | 127 NaClLog(3, "NaClSyncQueueDequeue: returning item 0x%08"NACL_PRIxPTR"\n", |
| 128 (uintptr_t) item); | 128 (uintptr_t) item); |
| 129 return item; | 129 return item; |
| 130 } | 130 } |
| OLD | NEW |