/* Seal * indicate that the queue has been closed off * meaning there will be no further push operations * if "writes" is true, and no further pop operations * otherwise. */ LIB_EXPORT rc_t CC KQueueSeal ( KQueue *self ) { rc_t rc = 0; QMSG ( "%s[%p] called\n", __func__, self ); if ( self == NULL ) return RC ( rcCont, rcQueue, rcFreezing, rcSelf, rcNull ); if ( atomic32_test_and_set ( & self -> sealed, 1, 0 ) == 0 ) { #if 1 QMSG ( "%s[%p]: acquiring write lock ( %p )\n", __func__, self, self -> wl ); rc = KLockAcquire ( self -> wl ); if ( rc == 0 ) { QMSG ( "%s[%p]: canceling write semaphore...\n", __func__, self ); rc = KSemaphoreCancel ( self -> wc ); QMSG ( "%s[%p]: ...done, rc = %R.\n", __func__, self, rc ); KLockUnlock ( self -> wl ); if ( rc == 0 ) { QMSG ( "%s[%p]: acquiring read lock ( %p )\n", __func__, self, self -> rl ); rc = KLockAcquire ( self -> rl ); if ( rc == 0 ) { QMSG ( "%s[%p]: canceling read semaphore...\n", __func__, self ); rc = KSemaphoreCancel ( self -> rc ); QMSG ( "%s[%p]: ...done, rc = %R.\n", __func__, self, rc ); KLockUnlock ( self -> rl ); } } } #endif } return rc; }
/* Seal * indicate that the queue has been closed off * meaning there will be no further push operations * if "writes" is true, and no further pop operations * otherwise. */ LIB_EXPORT rc_t CC KQueueSeal ( KQueue *self ) { rc_t rc = 0; QMSG ( "%s called\n", __func__ ); if ( self == NULL ) return RC ( rcCont, rcQueue, rcFreezing, rcSelf, rcNull ); self -> sealed = true; #if 0 QMSG ( "%s: acquiring write lock ( %p )\n", __func__, self -> wl ); rc = KLockAcquire ( self -> wl ); if ( rc == 0 ) { QMSG ( "%s: canceling write semaphore...\n", __func__ ); rc = KSemaphoreCancel ( self -> wc ); QMSG ( "%s: ...done, rc = %R.\n", __func__, rc ); KLockUnlock ( self -> wl ); if ( rc == 0 ) { QMSG ( "%s: acquiring read lock ( %p )\n", __func__, self -> rl ); rc = KLockAcquire ( self -> rl ); if ( rc == 0 ) { QMSG ( "%s: canceling read semaphore...\n", __func__ ); rc = KSemaphoreCancel ( self -> rc ); QMSG ( "%s: ...done, rc = %R.\n", __func__, rc ); KLockUnlock ( self -> rl ); } } } #endif return rc; }