home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-06-17 | 928 b | 58 lines | [TEXT/CWIE] |
- // OSQueueBase.cp
-
- #ifndef OSQueueBase_h
- #include "OSQueueBase.h"
- #endif
- #ifndef OSQueueLinkBase_h
- #include "OSQueueLinkBase.h"
- #endif
- #ifndef Assert_h
- #include "Assert.h"
- #endif
- #ifndef OSError_h
- #include "OSError.h"
- #endif
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
- OSQueueBase::OSQueueBase()
- {
- head.qFlags = 0;
- head.qHead = 0;
- head.qTail = 0;
- }
-
- OSQueueBase::~OSQueueBase()
- {
- Assert( IsEmpty() );
- }
-
- void OSQueueBase::Put( OSQueueLinkBase& link )
- {
- Assert( !link.queued );
- link.queued = true;
- Enqueue( &link, const_cast<QHdr *>( &head ) );
- }
-
- OSQueueLinkBase *OSQueueBase::Get()
- {
- OSQueueLinkBase *got = static_cast<OSQueueLinkBase *>( head.qHead );
-
- if ( got == 0 )
- return 0;
-
- OSErr error = Dequeue( got, const_cast<QHdr *>( &head ) );
-
- if ( error != noErr )
- {
- if ( error != qErr )
- DebugOSError( error );
- return 0;
- }
-
- Assert( got->queued );
- got->queued = 0;
- return got;
- }
-