|
From: Hans D. <dul...@us...> - 2000-11-15 22:44:17
|
Update of /cvsroot/corelinux/corelinux/src/classlibs/corelinux In directory slayer.i.sourceforge.net:/tmp/cvs-serv20115 Modified Files: EventSemaphore.cpp Log Message: Added post() method Index: EventSemaphore.cpp =================================================================== RCS file: /cvsroot/corelinux/corelinux/src/classlibs/corelinux/EventSemaphore.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** EventSemaphore.cpp 2000/09/18 03:07:00 1.3 --- EventSemaphore.cpp 2000/11/15 22:44:14 1.4 *************** *** 97,100 **** --- 97,132 ---- // + // Indicates owner's commitment to trigger an event + // + + SemaphoreOperationStatus EventSemaphore::post( void ) + throw(SemaphoreException) + { + SemaphoreOperationStatus aStatus(SUCCESS); + + if ( Thread::getThreadIdentifier() == getOwnerId() ) + { + if ( theNumListeners == 0 ) + { + setValue( 1 ); // lock it again + } + else + { + aStatus = UNAVAILABLE; + } + } + else + { + throw SemaphoreException + ( + "Not authorized to post an event", + LOCATION, + Exception::CONTINUABLE + ); + } + return aStatus; + } + + // // Call for lock with wait disposition // *************** *** 118,126 **** myGuard.release(); aStatus = waitZero( 0 ); ! theNumListeners--; ! if ( theNumListeners == 0 ) { ! setValue( 1 ); // lock it again } } else { --- 150,161 ---- myGuard.release(); aStatus = waitZero( 0 ); ! if ( aStatus == SUCCESS ) { ! theNumListeners--; } + else + { + ; // do nothing + } } else { *************** *** 146,149 **** --- 181,185 ---- // + myGuard.release(); aStatus = UNAVAILABLE; } *************** *** 173,180 **** myGuard.release(); aStatus = waitZero( IPC_NOWAIT ); ! theNumListeners--; ! if ( theNumListeners == 0 ) { ! setValue( 1 ); // lock it again } } --- 209,219 ---- myGuard.release(); aStatus = waitZero( IPC_NOWAIT ); ! if ( aStatus == SUCCESS ) ! { ! theNumListeners--; ! } ! else { ! ; // do nothing } } *************** *** 211,215 **** SemaphoreOperationStatus EventSemaphore::release( void ) ! throw(SemaphoreException) { GUARD; --- 250,254 ---- SemaphoreOperationStatus EventSemaphore::release( void ) ! throw( SemaphoreException ) { GUARD; *************** *** 220,232 **** // ! if( ( aStatus = setLock( IPC_NOWAIT ) ) == SUCCESS ) ! { ! Semaphore::resetOwnerId(); ! theNumListeners = 0; ! } ! else ! { ! ; // do nothing, error ! } return aStatus; --- 259,263 ---- // ! aStatus = setLock( IPC_NOWAIT ); return aStatus; *************** *** 238,243 **** void EventSemaphore::setLimit( Counter aLimit ) { ! theMaxListeners = aLimit; } --- 269,287 ---- void EventSemaphore::setLimit( Counter aLimit ) + throw( SemaphoreException ) { ! if ( Thread::getThreadIdentifier() == getOwnerId() ) ! { ! theMaxListeners = aLimit; ! } ! else ! { ! throw SemaphoreException ! ( ! "Not authorized to set limit", ! LOCATION, ! Exception::CONTINUABLE ! ); ! } } |