void CAbstractRegistryDriver::WaitForDriverStop()const { while( CThread::isRun() && !Wait( 0 ) ) { synchronization().continueRead(); } }
void simulatort::compute_successor_states( const statet &state, bool check_property, queuet &queue) { #ifdef DEBUG std::cout << "simulatort::compute_successor_states1" << std::endl; #endif // see if there are any threads that try to synchronize synchronization(state, queue); // now do regular statements interleavingt interleaving; compute_interleaving(state, interleaving); for(interleavingt::const_iterator i_it=interleaving.begin(); i_it!=interleaving.end(); i_it++) { execute_thread(state, *i_it, check_property, queue); if(error_state_found) return; } #ifdef DEBUG std::cout << "simulatort::compute_succesor_states2" << std::endl; #endif }
TKeyListIterator CAbstractRegistryDriver::VariableList( const std::string& aKey, TKeyList& aList )const { CMutexLocker locker( synchronization().mutex() ); TKeyListIterator ret( aList.end() ); do { CCategoryKeyParser keyParser( aKey ); ret = category()->VariableList( keyParser, aList ); synchronization().continueRead(); } while( ret == aList.end() && isRun() ); return ret; }
bool CAbstractRegistryDriver::Read( const std::string& aKey, CVariant& aValue )const { TRACE_FUN( Frequently, "CAbstractRegistryDriver::Read" ); CMutexLocker locker( synchronization().mutex() ); bool ret( false ); do { CCategoryKeyParser keyParser( aKey ); ret = category()->Read( keyParser, aValue ); synchronization().continueRead(); } while( !ret && isRun() ); return ret; }
void CAbstractRegistryDriver::Clear() { TRACE_FUN( Routine, "CAbstractRegistryDriver::Clear" ); WaitForDriverStop(); CMutexLocker locker( synchronization().mutex() ); category()->Clear(); _isModified = false; }
void CIniImpl::parse() { TRACE_FUN( Routine, "CIniImpl::parse" ); CLexScaner scaner( &stream() ); CCategoryParserDriver driver( file(), scaner, category(), synchronization(), errorRepository() ); parser theParser( driver ); theParser.parse(); }
bool CIniImpl::Close() { TRACE_FUN( Routine, "CIniImpl::Close" ); if( !isModified() && CThread::isRun() ) { synchronization().terminate(); } WaitForDriverStop(); bool ret( false ); CMutexLocker locker( synchronization().mutex() ); if( !( ret = !isModified() ) ) { CFile theFile( file() ); if( !hasError() && theFile.open( CFile::omWriteOnly | CFile::omTruncate ) ) { std::string buf; buf += "/*********************************************************" + CBaseSerializer::cr() + " * The file was generated by l2Registry driver" + CBaseSerializer::cr() + " * Name: " + _registryDriverInfo._name + CBaseSerializer::cr() + " * Description: " + _registryDriverInfo._description + CBaseSerializer::cr() + " * Version: " + _registryDriverInfo._version + CBaseSerializer::cr() + " *********************************************************/" + CBaseSerializer::cr(); buf += CTextIniCategorySerializer( category()->members(), 0 ).serialized(); ret = theFile.write( buf.c_str(), buf.size() ) == buf.size(); } } return ret; }
bool CAbstractRegistryDriver::Open( const std::string& aFile ) { TRACE_FUN( Routine, "CAbstractRegistryDriver::Open" ); bool ret( false ); Close(); CMutexLocker locker( synchronization().mutex() ); synchronization().ResetTerminate(); _file = aFile; _fstream.open( _file.c_str(), std::ios_base::in ); if( ret = _fstream.is_open() ) { _errorRepository.SetParsedFileName( _file ); Start(); } return ret && !hasError(); }
bool CAbstractRegistryDriver::Write( const std::string& aKey, const CVariant& aValue ) { TRACE_FUN( Frequently, "CAbstractRegistryDriver::Write" ); CMutexLocker locker( synchronization().mutex() ); bool ret( false ); CCategoryKeyParser keyParser( aKey ); if( ret = category()->Write( keyParser, aValue ) ) { _isModified = true; } return ret; }
unsigned int CAbstractRegistryDriver::run() { unsigned int ret( 0 ); try { parse(); } catch( const CException& anException ) { _errorRepository.RegisterError( anException.what() ); TraceCritical << "Registry driver ERROR:" << std::endl; TraceCritical << _errorRepository.errorString() << std::endl; } catch( ... ) { TraceCritical << "Unknown Exception" << std::endl; } synchronization().parserStopped(); return ret; }
/** * \brief Synchronize to stream and estimate the amount of missing access units due * to a current synchronization error in case of constant average bit rate. */ static TRANSPORTDEC_ERROR transportDec_readStream ( HANDLE_TRANSPORTDEC hTp, const UINT layer ) { TRANSPORTDEC_ERROR error = TRANSPORTDEC_OK; HANDLE_FDK_BITSTREAM hBs = &hTp->bitStream[layer]; INT nAU = -1; INT headerBits; INT bitDistance, bfDelta; /* Obtain distance to next synch word */ bitDistance = FDKgetValidBits(hBs); error = synchronization(hTp, &headerBits); bitDistance -= FDKgetValidBits(hBs); FDK_ASSERT(bitDistance >= 0); if (error == TRANSPORTDEC_SYNC_ERROR || (hTp->flags & TPDEC_LOST_FRAMES_PENDING)) { /* Check if estimating lost access units is feasible. */ if (hTp->avgBitRate > 0 && hTp->asc[0].m_samplesPerFrame > 0 && hTp->asc[0].m_samplingFrequency > 0) { if (error == TRANSPORTDEC_OK) { int aj; aj = transportDec_GetBufferFullness(hTp); if (aj > 0) { bfDelta = aj; } else { bfDelta = 0; } /* sync was ok: last of a series of bad access units. */ hTp->flags &= ~TPDEC_LOST_FRAMES_PENDING; /* Add up bitDistance until end of the current frame. Later we substract this frame from the grand total, since this current successfully synchronized frame should not be skipped of course; but it must be accounted into the bufferfulness math. */ bitDistance += hTp->auLength[0]; } else { if ( !(hTp->flags & TPDEC_LOST_FRAMES_PENDING) ) { /* sync not ok: one of many bad access units. */ hTp->flags |= TPDEC_LOST_FRAMES_PENDING; bfDelta = - (INT)hTp->lastValidBufferFullness; } else { bfDelta = 0; } } { int num, denom; /* Obtain estimate of number of lost frames */ num = hTp->asc[0].m_samplingFrequency * (bfDelta + bitDistance) + hTp->remainder; denom = hTp->avgBitRate * hTp->asc[0].m_samplesPerFrame; if (num > 0) { nAU = num / denom; hTp->remainder = num % denom; } else { hTp->remainder = num; } if (error == TRANSPORTDEC_OK) { /* Final adjustment of remainder, taken -1 into account because current frame should not be skipped, thus substract -1 or do nothing instead of +1-1 accordingly. */ if ( (denom - hTp->remainder) >= hTp->remainder ) { nAU--; } if (nAU < 0) { /* There was one frame too much concealed, so unfortunately we will have to skip one good frame. */ transportDec_EndAccessUnit(hTp); error = synchronization(hTp, &headerBits); nAU = -1; #ifdef DEBUG FDKprintf("ERROR: Bufferfullness accounting failed. remainder=%d, nAU=%d\n", hTp->remainder, nAU); #endif } hTp->remainder = 0; /* Enforce last missed frames to be concealed. */ if (nAU > 0) { FDKpushBack(hBs, headerBits); } } } } } /* Be sure that lost frames are handled correctly. This is necessary due to some sync error sequences where later it turns out that there is not enough data, but the bits upto the sync word are discarded, thus causing a value of nAU > 0 */ if (nAU > 0) { error = TRANSPORTDEC_SYNC_ERROR; } hTp->missingAccessUnits = nAU; return error; }
bool CAbstractRegistryDriver::isRun()const { return CThread::isRun() && synchronization().isRun() && synchronization().WaitForData(); }
bool CAbstractRegistryDriver::isModified()const { CMutexLocker locker( synchronization().mutex() ); return _isModified; }