unsigned int pmdEDUMgr::_getEDUCount ( int property ) { unsigned int eduCount = 0 ; std::map<EDUID, pmdEDUCB*>::iterator it ; /*******************CRITICAL SECTION ********************/ _mutex.get_shared() ; for ( it = _runQueue.begin () ; it != _runQueue.end () ; ++it ) { if ( ((EDU_SYSTEM & property) && _isSystemEDU( it->first )) || ((EDU_USER & property) && !_isSystemEDU( it->first )) ) { ++eduCount ; } } for ( it = _idleQueue.begin () ; it != _idleQueue.end () ; ++it ) { if ( EDU_USER & property ) { ++eduCount ; } } _mutex.release_shared() ; /******************END CRITICAL SECTION******************/ return eduCount ; }
// block all new request and attempt to terminate existing requests int pmdEDUMgr::_forceEDUs ( int property ) { std::map<EDUID, pmdEDUCB*>::iterator it ; /*******************CRITICAL SECTION ********************/ _mutex.get() ; // send terminate request to everyone for ( it = _runQueue.begin () ; it != _runQueue.end () ; ++it ) { if ( ((EDU_SYSTEM & property) && _isSystemEDU( it->first )) || ((EDU_USER & property) && !_isSystemEDU( it->first )) ) { ( *it ).second->force () ; PD_LOG ( PDDEBUG, "force edu[ID:%lld]", it->first ) ; } } for ( it = _idleQueue.begin () ; it != _idleQueue.end () ; ++it ) { if ( EDU_USER & property ) { ( *it ).second->force () ; } } _mutex.release() ; /******************END CRITICAL SECTION******************/ return EDB_OK ; }
bool isSystemEDU ( EDUID eduID ) { bool isSys = false ; _mutex.get_shared () ; isSys = _isSystemEDU ( eduID ) ; _mutex.release_shared () ; return isSys ; }