void App::dec_task() { std::unique_lock<std::mutex> lock(mutex); if(num_tasks){ num_tasks--; } }
void IpcSocketDispatcher::insertClient(IDispatcherClient * client) { LOG4CPLUS_TRACE_METHOD(mLogger, __PRETTY_FUNCTION__); MutexLocker lock(mClientsSetMutex); mClients.insert(client); }
void GameTable::unReady(User *u){ MutexLockGuard lock(mutex); readyNum--; broadCast("Unready\n" + u->getName() + "\n"); }
void TickerInfoManager::put(std::string const& id, int total, int active) { SharedString shid(id.begin(), id.end(), pimpl_->m_alloc); lock_guard lock(pimpl_->mutex()); pimpl_->map()[shid] = { total, active }; }
void MassStorage::ReleaseWriteBuffer(FileWriteBuffer *buffer) { MutexLocker lock(fsMutex); buffer->SetNext(freeWriteBuffers); freeWriteBuffers = buffer; }
void SlotVisitor::drainFromShared(SharedDrainMode sharedDrainMode) { StackStats::probe(); ASSERT(m_isInParallelMode); ASSERT(Options::numberOfGCMarkers()); { std::lock_guard<Lock> lock(m_heap.m_markingMutex); m_heap.m_numberOfActiveParallelMarkers++; } while (true) { { std::unique_lock<Lock> lock(m_heap.m_markingMutex); m_heap.m_numberOfActiveParallelMarkers--; m_heap.m_numberOfWaitingParallelMarkers++; // How we wait differs depending on drain mode. if (sharedDrainMode == MasterDrain) { // Wait until either termination is reached, or until there is some work // for us to do. while (true) { // Did we reach termination? if (!m_heap.m_numberOfActiveParallelMarkers && m_heap.m_sharedMarkStack.isEmpty()) { // Let any sleeping slaves know it's time for them to return; m_heap.m_markingConditionVariable.notifyAll(); return; } // Is there work to be done? if (!m_heap.m_sharedMarkStack.isEmpty()) break; // Otherwise wait. m_heap.m_markingConditionVariable.wait(lock); } } else { ASSERT(sharedDrainMode == SlaveDrain); // Did we detect termination? If so, let the master know. if (!m_heap.m_numberOfActiveParallelMarkers && m_heap.m_sharedMarkStack.isEmpty()) m_heap.m_markingConditionVariable.notifyAll(); m_heap.m_markingConditionVariable.wait( lock, [this] { return !m_heap.m_sharedMarkStack.isEmpty() || m_heap.m_parallelMarkersShouldExit; }); // Is the current phase done? If so, return from this function. if (m_heap.m_parallelMarkersShouldExit) return; } m_stack.stealSomeCellsFrom( m_heap.m_sharedMarkStack, m_heap.m_numberOfWaitingParallelMarkers); m_heap.m_numberOfActiveParallelMarkers++; m_heap.m_numberOfWaitingParallelMarkers--; } drain(); } }
void SocketTransport::listenForClientConnection() { // If there was a previous connection in the base class, shut it down. // This will close the old transport and wait for both the send and receive // worker threads to terminate before proceeding. if (getTransportFd() >= 0) { shutdown(); } VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "SocketTransport worker thread listening for connections..." ); int abortFd; { Lock lock(m_lock); abortFd = m_abortPipeFd[0]; assertx(abortFd >= 0); } struct addrinfo hint; struct addrinfo* ai = nullptr; std::vector<int> socketFds; memset(&hint, 0, sizeof(hint)); hint.ai_family = AF_UNSPEC; hint.ai_socktype = SOCK_STREAM; hint.ai_flags = AI_PASSIVE; SCOPE_EXIT { if (ai != nullptr) { freeaddrinfo(ai); } for (auto it = socketFds.begin(); it != socketFds.end(); it++) { close(*it); } close(abortFd); m_abortPipeFd[0] = -1; VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "SocketTransport connection polling thread exiting." ); }; // Share existing DebuggerDisableIPv6 configuration with hphpd. if (RuntimeOption::DebuggerDisableIPv6) { hint.ai_family = AF_INET; } const auto name = RuntimeOption::DebuggerServerIP.empty() ? "localhost" : RuntimeOption::DebuggerServerIP.c_str(); if (getaddrinfo(name, std::to_string(m_listenPort).c_str(), &hint, &ai)) { VSDebugLogger::Log( VSDebugLogger::LogLevelError, "Failed to call getaddrinfo: %d.", errno ); return; } // Attempt to listen on the specified port on each of this host's available // addresses. struct addrinfo* address; bool anyInterfaceBound = false; for (address = ai; address != nullptr; address = address->ai_next) { if (bindAndListen(address, socketFds)) { anyInterfaceBound = true; } } if (!anyInterfaceBound) { VSDebugLogger::Log( VSDebugLogger::LogLevelWarning, "Debugger failed to bind to any interface!" ); return; } else { VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "Debugger bound to at least one interface." ); } waitForConnection(socketFds, abortFd); }
std::string AbstractConfiguration::expand(const std::string& value) const { FastMutex::ScopedLock lock(_mutex); return internalExpand(value); }
void HTTPServerConnection::run() { std::string server = _pParams->getSoftwareVersion(); HTTPServerSession session(socket(), _pParams); while (!_stopped && session.hasMoreRequests()) { try { Poco::FastMutex::ScopedLock lock(_mutex); if (!_stopped) { HTTPServerResponseImpl response(session); HTTPServerRequestImpl request(response, session, _pParams); Poco::Timestamp now; response.setDate(now); response.setVersion(request.getVersion()); response.setKeepAlive(_pParams->getKeepAlive() && request.getKeepAlive() && session.canKeepAlive()); if (!server.empty()) response.set("Server", server); try { std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request)); if (pHandler.get()) { if (request.getExpectContinue() && response.getStatus() == HTTPResponse::HTTP_OK) response.sendContinue(); pHandler->handleRequest(request, response); session.setKeepAlive(_pParams->getKeepAlive() && response.getKeepAlive() && session.canKeepAlive()); } else sendErrorResponse(session, HTTPResponse::HTTP_NOT_IMPLEMENTED); } catch (Poco::Exception&) { if (!response.sent()) { try { sendErrorResponse(session, HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); } catch (...) { } } throw; } } } catch (NoMessageException&) { break; } catch (MessageException&) { sendErrorResponse(session, HTTPResponse::HTTP_BAD_REQUEST); } catch (Poco::Exception&) { if (session.networkException()) { session.networkException()->rethrow(); } else throw; } } }
void AbstractConfiguration::setDouble(const std::string& key, double value) { FastMutex::ScopedLock lock(_mutex); setRaw(key, NumberFormatter::format(value)); }
void AbstractConfiguration::setBool(const std::string& key, bool value) { FastMutex::ScopedLock lock(_mutex); setRaw(key, value ? "true" : "false"); }
void AbstractConfiguration::setString(const std::string& key, const std::string& value) { FastMutex::ScopedLock lock(_mutex); setRaw(key, value); }
void Plotter2DDisplay::updateHeight() { boost::mutex::scoped_lock lock(mutex_); texture_height_ = height_property_->getInt(); }
void Plotter2DDisplay::updateWidth() { boost::mutex::scoped_lock lock(mutex_); texture_width_ = width_property_->getInt(); }
void CWinSystemBase::RegisterRenderLoop(IRenderLoop *client) { CSingleLock lock(m_renderLoopSection); m_renderLoopClients.push_back(client); }
void UOTreeView::UpdateView() { QMutexLocker lock(&mMutex); luaL_dostring(L,"SetCliNr(1)"); int error = luaL_dofile(L, "macros/internal/treeview.lua"); if(error!=0) { } /*lua_getglobal(L, "CharPosX"); mViewMap["CharPosX"]->setText(QString("CharPosX: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharPosY"); mViewMap["CharPosY"]->setText(QString("CharPosY: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharPosZ"); mViewMap["CharPosZ"]->setText(QString("CharPosZ: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharDir"); mViewMap["CharDir"]->setText(QString("CharDir: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharStatus"); mViewMap["CharStatus"]->setText(QString("CharStatus: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharID"); mViewMap["CharID"]->setText(QString("CharID: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharType"); mViewMap["CharType"]->setText(QString("CharType: %0").arg(lua_tostring(L, -1))); //lua_getglobal(L, "CharPosX"); //mViewMap["CharGhost"]->setText(QString("CharGhost: %0").arg(CharGhost)); lua_getglobal(L, "BackpackID"); mViewMap["BackpackID"]->setText(QString("BackpackID: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CharName"); mViewMap["CharName"]->setText(QString("CharName: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Sex"); mViewMap["Sex"]->setText(QString("Sex: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Str"); mViewMap["Str"]->setText(QString("Str: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Dex"); mViewMap["Dex"]->setText(QString("Dex: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Int"); mViewMap["Int"]->setText(QString("Int: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Hits"); mViewMap["Hits"]->setText(QString("Hits: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxHits"); mViewMap["MaxHits"]->setText(QString("MaxHits: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Stamina"); mViewMap["Stamina"]->setText(QString("Stamina: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxStam"); mViewMap["MaxStam"]->setText(QString("MaxStam: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Mana"); mViewMap["Mana"]->setText(QString("Mana: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxMana"); mViewMap["MaxMana"]->setText(QString("MaxMana: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxStats"); mViewMap["MaxStats"]->setText(QString("MaxStats: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Luck"); mViewMap["Luck"]->setText(QString("Luck: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Weight"); mViewMap["Weight"]->setText(QString("Weight: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxWeight"); mViewMap["MaxWeight"]->setText(QString("MaxWeight: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MinDmg"); mViewMap["MinDmg"]->setText(QString("MinDmg: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxDmg"); mViewMap["MaxDmg"]->setText(QString("MaxDmg: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Gold"); mViewMap["Gold"]->setText(QString("Gold: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Followers"); mViewMap["Followers"]->setText(QString("Followers: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "MaxFol"); mViewMap["MaxFol"]->setText(QString("MaxFol: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Ar"); mViewMap["Ar"]->setText(QString("Ar: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Fr"); mViewMap["Fr"]->setText(QString("Fr: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Cr"); mViewMap["Cr"]->setText(QString("Cr: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Pr"); mViewMap["Pr"]->setText(QString("Pr: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Er"); mViewMap["Er"]->setText(QString("Er: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "Tp"); mViewMap["Tp"]->setText(QString("Tp: %0").arg(lua_tostring(L, -1))); */ /* lua_getglobal(L, "ContID"); mViewMap["ContID"]->setText(QString("ContID: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContType"); mViewMap["ContType"]->setText(QString("ContType: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContKind"); mViewMap["ContKind"]->setText(QString("ContKind: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContName"); mViewMap["ContName"]->setText(QString("ContName: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContPosX"); mViewMap["ContPosX"]->setText(QString("ContPosX: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContPosY"); mViewMap["ContPosY"]->setText(QString("ContPosY: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContSizeX"); mViewMap["ContSizeX"]->setText(QString("ContSizeX: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "ContSizeY"); mViewMap["ContSizeY"]->setText(QString("ContSizeY: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "NextCPosX"); mViewMap["NextCPosX"]->setText(QString("NextCPosX: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "NextCPosY"); mViewMap["NextCPosY"]->setText(QString("NextCPosY: %0").arg(lua_tostring(L, -1))); */ /*lua_getglobal(L, "CliNr"); mViewMap["CliNr"]->setText(QString("CliNr: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliCnt"); mViewMap["CliCnt"]->setText(QString("CliCnt: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliLang"); mViewMap["CliLang"]->setText(QString("CliLang: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliVer"); mViewMap["CliVer"]->setText(QString("CliVer: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliLogged"); mViewMap["CliLogged"]->setText(QString("CliLogged: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliLeft"); mViewMap["CliLeft"]->setText(QString("CliLeft: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliTop"); mViewMap["CliTop"]->setText(QString("CliTop: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliXRes"); mViewMap["CliXRes"]->setText(QString("CliXRes: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliYRes"); mViewMap["CliYRes"]->setText(QString("CliYRes: %0").arg(lua_tostring(L, -1))); lua_getglobal(L, "CliTitle"); mViewMap["CliTitle"]->setText(QString("CliTitle: %0").arg(lua_tostring(L, -1))); */ /* mViewMap["LObjectID"]->setText(QString("LObjectID: %0").arg(LObjectID)); mViewMap["LObjectType"]->setText(QString("LObjectType: %0").arg(LObjectType)); mViewMap["LTargetID"]->setText(QString("LTargetID: %0").arg(LTargetID)); mViewMap["LTargetKind"]->setText(QString("LTargetKind: %0").arg(LTargetKind)); mViewMap["LTargetTile"]->setText(QString("LTargetTile: %0").arg(LTargetTile)); mViewMap["LTargetX"]->setText(QString("LTargetX: %0").arg(LTargetX)); mViewMap["LTargetY"]->setText(QString("LTargetY: %0").arg(LTargetY)); mViewMap["LTargetZ"]->setText(QString("LTargetZ: %0").arg(LTargetZ)); mViewMap["LLiftedID"]->setText(QString("LLiftedID: %0").arg(LLiftedID)); mViewMap["LLiftedKind"]->setText(QString("LLiftedKind: %0").arg(LLiftedKind)); mViewMap["LLiftedType"]->setText(QString("LLiftedType: %0").arg(LLiftedType)); mViewMap["LSkill"]->setText(QString("LSkill: %0").arg(LSkill)); mViewMap["LSpell"]->setText(QString("LSpell: %0").arg(LSpell)); mViewMap["Alchemy"]->setText(QString("Alchemy: %0").arg(Alchemy/10)); mViewMap["Blacksmithy"]->setText(QString("Blacksmithy: %0").arg(Blacksmithy/10)); mViewMap["Bowcraft"]->setText(QString("Bowcraft:%0").arg(Bowcraft/10)); mViewMap["Bushido"]->setText(QString("Bushido:%0").arg(Bushido/10)); mViewMap["Carpentry"]->setText(QString("Carpentry:%0").arg(Carpentry/10)); mViewMap["Chivalry"]->setText(QString("Chivalry:%0").arg(Chivalry/10)); mViewMap["Cooking"]->setText(QString("Cooking:%0").arg(Cooking/10)); mViewMap["Fishing"]->setText(QString("Fishing:%0").arg(Fishing/10)); mViewMap["Focus"]->setText(QString("Focus:%0").arg(Focus/10)); mViewMap["Healing"]->setText(QString("Healing:%0").arg(Healing/10)); mViewMap["Herding"]->setText(QString("Herding:%0").arg(Herding/10)); mViewMap["Lockpicking"]->setText(QString("Lockpicking:%0").arg(Lockpicking/10)); mViewMap["Lumberjacking"]->setText(QString("Lumberjacking:%0").arg(Lumberjacking/10)); mViewMap["Magery"]->setText(QString("Magery:%0").arg(Magery/10)); mViewMap["Meditation"]->setText(QString("Meditation:%0").arg(Meditation/10)); mViewMap["Mining"]->setText(QString("Mining:%0").arg(Mining/10)); mViewMap["Musicianship"]->setText(QString("Musicianship:%0").arg(Musicianship/10)); mViewMap["Necromancy"]->setText(QString("Necromancy:%0").arg(Necromancy/10)); mViewMap["Ninjitsu"]->setText(QString("Ninjitsu:%0").arg(Ninjitsu/10)); mViewMap["RemoveTrap"]->setText(QString("RemoveTrap:%0").arg(RemoveTrap/10)); mViewMap["ResistingSpells"]->setText(QString("ResistingSpells:%0").arg(ResistingSpells/10)); mViewMap["Snooping"]->setText(QString("Snooping:%0").arg(Snooping/10)); mViewMap["Stealing"]->setText(QString("Stealing:%0").arg(Stealing/10)); mViewMap["Stealth"]->setText(QString("Stealth:%0").arg(Stealth/10)); mViewMap["Tailoring"]->setText(QString("Tailoring:%0").arg(Tailoring/10)); mViewMap["Tinkering"]->setText(QString("Tinkering:%0").arg(Tinkering/10)); mViewMap["Veterinary"]->setText(QString("Veterinary:%0").arg(Veterinary/10)); mViewMap["Archery"]->setText(QString("Archery:%0").arg(Archery/10)); mViewMap["Fencing"]->setText(QString("Fencing:%0").arg(Fencing/10)); mViewMap["MaceFighting"]->setText(QString("MaceFighting:%0").arg(MaceFighting/10)); mViewMap["Parrying"]->setText(QString("Parrying:%0").arg(Parrying/10)); mViewMap["Swordsmanship"]->setText(QString("Swordsmanship:%0").arg(Swordsmanship/10)); mViewMap["Tactics"]->setText(QString("Tactics:%0").arg(Tactics/10)); mViewMap["Wrestling"]->setText(QString("Wrestling:%0").arg(Wrestling/10)); mViewMap["AnimalTaming"]->setText(QString("AnimalTaming:%0").arg(AnimalTaming/10)); mViewMap["Begging"]->setText(QString("Begging:%0").arg(Begging/10)); mViewMap["Camping"]->setText(QString("Camping:%0").arg(Camping/10)); mViewMap["DetectingHidden"]->setText(QString("DetectingHidden:%0").arg(DetectingHidden/10)); mViewMap["Discordance"]->setText(QString("Discordance:%0").arg(Discordance/10)); mViewMap["Hiding"]->setText(QString("Hiding:%0").arg(Hiding/10)); mViewMap["Inscription"]->setText(QString("Inscription:%0").arg(Inscription/10)); mViewMap["Peacemaking"]->setText(QString("Peacemaking:%0").arg(Peacemaking/10)); mViewMap["Poisoning"]->setText(QString("Poisoning:%0").arg(Poisoning/10)); mViewMap["Provocation"]->setText(QString("Provocation:%0").arg(Provocation/10)); mViewMap["SpiritSpeak"]->setText(QString("SpiritSpeak:%0").arg(SpiritSpeak/10)); mViewMap["Tracking"]->setText(QString("Tracking:%0").arg(Tracking/10)); mViewMap["Anatomy"]->setText(QString("Anatomy:%0").arg(Anatomy/10)); mViewMap["AnimalLore"]->setText(QString("AnimalLore:%0").arg(AnimalLore/10)); mViewMap["ArmsLore"]->setText(QString("ArmsLore:%0").arg(ArmsLore/10)); mViewMap["EvaluatingIntelligence"]->setText(QString("EvaluatingIntelligence:%0").arg(EvaluatingIntelligence/10)); mViewMap["ForensicEvaluation"]->setText(QString("ForensicEvaluation:%0").arg(ForensicEvaluation/10)); mViewMap["ItemIdentification"]->setText(QString("ItemIdentification:%0").arg(ItemIdentification/10)); mViewMap["TasteIdentification"]->setText(QString("TasteIdentification:%0").arg(TasteIdentification/10)); */ }
void ctkServiceRegistration::unregister() { Q_D(ctkServiceRegistration); if (!d) throw std::logic_error("ctkServiceRegistration object invalid"); if (d->unregistering) return; // Silently ignore redundant unregistration. { QMutexLocker lock(&d->eventLock); if (d->unregistering) return; d->unregistering = true; if (d->available) { if (d->plugin) { d->plugin->fwCtx->services->removeServiceRegistration(*this); } } else { throw std::logic_error("Service is unregistered"); } } if (d->plugin) { d->plugin->fwCtx->listeners.serviceChanged( d->plugin->fwCtx->listeners.getMatchingServiceSlots(d->reference), ctkServiceEvent(ctkServiceEvent::UNREGISTERING, d->reference)); } { QMutexLocker lock(&d->eventLock); { QMutexLocker lock2(&d->propsLock); d->available = false; if (d->plugin) { for (QHashIterator<QSharedPointer<ctkPlugin>, QObject*> i(d->serviceInstances); i.hasNext();) { QObject* obj = i.next().value(); try { // NYI, don't call inside lock qobject_cast<ctkServiceFactory*>(d->service)->ungetService(i.key(), *this, obj); } catch (const std::exception& ue) { ctkPluginFrameworkEvent pfwEvent(ctkPluginFrameworkEvent::ERROR, d->plugin->q_func().data(), ue); d->plugin->fwCtx->listeners .emitFrameworkEvent(pfwEvent); } } } d->plugin = 0; d->dependents.clear(); d->service = 0; d->serviceInstances.clear();; d->unregistering = false; } } }
int fll_band_edge_cc_4o_base::_transformerServiceFunction( std::vector< gr_istream_base * > &istreams , std::vector< gr_ostream_base * > &ostreams ) { typedef std::vector< gr_istream_base * > _IStreamList; typedef std::vector< gr_ostream_base * > _OStreamList; boost::mutex::scoped_lock lock(serviceThreadLock); if ( validGRBlock() == false ) { // create our processing block, and setup property notifiers createBlock(); LOG_DEBUG( fll_band_edge_cc_4o_base, " FINISHED BUILDING GNU RADIO BLOCK"); } //process any Stream ID changes this could affect number of io streams processStreamIdChanges(); if ( !validGRBlock() || istreams.size() == 0 || ostreams.size() == 0 ) { LOG_WARN( fll_band_edge_cc_4o_base, "NO STREAMS ATTACHED TO BLOCK..." ); return NOOP; } _input_ready.resize( istreams.size() ); _ninput_items_required.resize( istreams.size() ); _ninput_items.resize( istreams.size() ); _input_items.resize( istreams.size() ); _output_items.resize( ostreams.size() ); // // RESOLVE: need to look at forecast strategy, // 1) see how many read items are necessary for N number of outputs // 2) read input data and see how much output we can produce // // // Grab available data from input streams // _OStreamList::iterator ostream; _IStreamList::iterator istream = istreams.begin(); int nitems=0; for ( int idx=0 ; istream != istreams.end() && serviceThread->threadRunning() ; idx++, istream++ ) { // note this a blocking read that can cause deadlocks nitems = (*istream)->read(); if ( (*istream)->overrun() ) { LOG_WARN( fll_band_edge_cc_4o_base, " NOT KEEPING UP WITH STREAM ID:" << (*istream)->streamID ); } if ( (*istream)->sriChanged() ) { // RESOLVE - need to look at how SRI changes can affect Gnu Radio BLOCK state LOG_DEBUG( fll_band_edge_cc_4o_base, "SRI CHANGED, STREAMD IDX/ID: " << idx << "/" << (*istream)->getPktStreamId() ); setOutputStreamSRI( idx, (*istream)->getPktSri() ); } } LOG_TRACE( fll_band_edge_cc_4o_base, "READ NITEMS: " << nitems ); if ( nitems <= 0 && !_istreams[0]->eos() ) { return NOOP; } bool eos = false; int nout = 0; bool workDone = false; while ( nout > -1 && serviceThread->threadRunning() ) { eos = false; nout = _forecastAndProcess( eos, istreams, ostreams ); if ( nout > -1 ) { workDone = true; // we chunked on data so move read pointer.. istream = istreams.begin(); for ( ; istream != istreams.end(); istream++ ) { int idx=std::distance( istreams.begin(), istream ); // if we processed data for this stream if ( _input_ready[idx] ) { size_t nitems = 0; try { nitems = gr_sptr->nitems_read( idx ); } catch(...){} if ( nitems > (*istream)->nitems() ) { LOG_WARN( fll_band_edge_cc_4o_base, "WORK CONSUMED MORE DATA THAN AVAILABLE, READ/AVAILABLE " << nitems << "/" << (*istream)->nitems() ); nitems = (*istream)->nitems(); } (*istream)->consume( nitems ); LOG_TRACE( fll_band_edge_cc_4o_base, " CONSUME READ DATA ITEMS/REMAIN " << nitems << "/" << (*istream)->nitems()); } } gr_sptr->reset_read_index(); } // check for not enough data return if ( nout == -1 ) { // check for end of stream istream = istreams.begin(); for ( ; istream != istreams.end() ; istream++) { if ( (*istream)->eos() ) { eos=true; } } if ( eos ) { LOG_TRACE( fll_band_edge_cc_4o_base, "EOS SEEN, SENDING DOWNSTREAM " ); _forecastAndProcess( eos, istreams, ostreams); } } } if ( eos ) { istream = istreams.begin(); for ( ; istream != istreams.end() ; istream++ ) { int idx=std::distance( istreams.begin(), istream ); LOG_DEBUG( fll_band_edge_cc_4o_base, " CLOSING INPUT STREAM IDX:" << idx ); (*istream)->close(); } // close remaining output streams ostream = ostreams.begin(); for ( ; eos && ostream != ostreams.end(); ostream++ ) { int idx=std::distance( ostreams.begin(), ostream ); LOG_DEBUG( fll_band_edge_cc_4o_base, " CLOSING OUTPUT STREAM IDX:" << idx ); (*ostream)->close(); } } // // set the read pointers of the GNU Radio Block to start at the beginning of the // supplied buffers // gr_sptr->reset_read_index(); LOG_TRACE( fll_band_edge_cc_4o_base, " END OF TRANSFORM SERVICE FUNCTION....." << noutput_items ); if ( nout == -1 && eos == false && !workDone ) { return NOOP; } else { return NORMAL; } }
bool SocketTransport::clientConnected() const { Lock lock(m_lock); return m_clientConnected; }
void ContentLayerChromium::updateContents() { RenderLayerBacking* backing = static_cast<RenderLayerBacking*>(m_owner->client()); if (!backing || backing->paintingGoesToWindow()) return; ASSERT(drawsContent()); ASSERT(layerRenderer()); // FIXME: Remove this test when tiled layers are implemented. m_skipsDraw = false; if (!layerRenderer()->checkTextureSize(m_bounds)) { m_skipsDraw = true; return; } void* pixels = 0; IntRect dirtyRect(m_dirtyRect); IntSize requiredTextureSize; IntSize bitmapSize; requiredTextureSize = m_bounds; IntRect boundsRect(IntPoint(0, 0), m_bounds); // If the texture needs to be reallocated then we must redraw the entire // contents of the layer. if (requiredTextureSize != m_allocatedTextureSize) dirtyRect = boundsRect; else { // Clip the dirtyRect to the size of the layer to avoid drawing outside // the bounds of the backing texture. dirtyRect.intersect(boundsRect); } #if PLATFORM(SKIA) const SkBitmap* skiaBitmap = 0; OwnPtr<skia::PlatformCanvas> canvas; OwnPtr<PlatformContextSkia> skiaContext; OwnPtr<GraphicsContext> graphicsContext; canvas.set(new skia::PlatformCanvas(dirtyRect.width(), dirtyRect.height(), false)); skiaContext.set(new PlatformContextSkia(canvas.get())); // This is needed to get text to show up correctly. // FIXME: Does this take us down a very slow text rendering path? skiaContext->setDrawingToImageBuffer(true); graphicsContext.set(new GraphicsContext(reinterpret_cast<PlatformGraphicsContext*>(skiaContext.get()))); // Bring the canvas into the coordinate system of the paint rect. canvas->translate(static_cast<SkScalar>(-dirtyRect.x()), static_cast<SkScalar>(-dirtyRect.y())); m_owner->paintGraphicsLayerContents(*graphicsContext, dirtyRect); const SkBitmap& bitmap = canvas->getDevice()->accessBitmap(false); skiaBitmap = &bitmap; ASSERT(skiaBitmap); SkAutoLockPixels lock(*skiaBitmap); SkBitmap::Config skiaConfig = skiaBitmap->config(); // FIXME: do we need to support more image configurations? if (skiaConfig == SkBitmap::kARGB_8888_Config) { pixels = skiaBitmap->getPixels(); bitmapSize = IntSize(skiaBitmap->width(), skiaBitmap->height()); } #elif PLATFORM(CG) Vector<uint8_t> tempVector; int rowBytes = 4 * dirtyRect.width(); tempVector.resize(rowBytes * dirtyRect.height()); memset(tempVector.data(), 0, tempVector.size()); RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); RetainPtr<CGContextRef> contextCG(AdoptCF, CGBitmapContextCreate(tempVector.data(), dirtyRect.width(), dirtyRect.height(), 8, rowBytes, colorSpace.get(), kCGImageAlphaPremultipliedLast)); CGContextTranslateCTM(contextCG.get(), 0, dirtyRect.height()); CGContextScaleCTM(contextCG.get(), 1, -1); GraphicsContext graphicsContext(contextCG.get()); // Translate the graphics context into the coordinate system of the dirty rect. graphicsContext.translate(-dirtyRect.x(), -dirtyRect.y()); m_owner->paintGraphicsLayerContents(graphicsContext, dirtyRect); pixels = tempVector.data(); bitmapSize = dirtyRect.size(); #else #error "Need to implement for your platform." #endif unsigned textureId = m_contentsTexture; if (!textureId) textureId = layerRenderer()->createLayerTexture(); if (pixels) updateTextureRect(pixels, bitmapSize, requiredTextureSize, dirtyRect, textureId); }
void SocketTransport::waitForConnection( std::vector<int>& socketFds, int abortFd ) { // Wait for a connection on any of the fds we are listening to. We allow only // one debugger client to connect a a time, so once any bound fd accepts a // connection, we stop listening on all the others. int count = socketFds.size() + 1; size_t size = sizeof(struct pollfd) * count; struct pollfd* fds = (struct pollfd*)malloc(size); if (fds == nullptr) { VSDebugLogger::Log( VSDebugLogger::LogLevelError, "SocketTransport out of memory while trying to create pollfd." ); return; } memset(fds, 0, size); SCOPE_EXIT { if (fds != nullptr) { free(fds); } }; // fds[0] will contain the read end of our "abort" pipe. Another thread will // write data to tihs pipe to signal it's time for this worker to stop // blocking in poll() and terminate. int eventMask = POLLIN | POLLERR | POLLHUP; fds[0].fd = abortFd; fds[0].events = eventMask; for (unsigned int i = 1; i < count; i++) { fds[i].fd = socketFds[i - 1]; fds[i].events = eventMask; } // Poll socket fds until a connection is established or we're terminated. while (true) { VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "SocketTransport polling for connections..." ); int ret = poll(fds, count, -1); if (ret < 0) { if (ret == -EINTR) { continue; } VSDebugLogger::Log( VSDebugLogger::LogLevelError, "Polling inputs failed: %d. (%s)", errno, strerror(errno) ); return; } if (fds[0].revents != 0) { VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "Socket polling thread terminating due to shutdown request." ); return; } struct sockaddr sa; socklen_t len = sizeof(sa); for (unsigned int i = 1; i < count; i++) { if (fds[i].revents & POLLIN) { int newFd = ::accept(fds[i].fd, &sa, &len); if (newFd < 0) { VSDebugLogger::Log( VSDebugLogger::LogLevelWarning, "Accept returned an error: %d. (%s)", errno, strerror(errno) ); } else { Lock lock(m_lock); if (m_clientConnected) { // A client is already connected! m_lock.unlock(); rejectClientWithMsg(newFd, abortFd); m_lock.lock(); } else { VSDebugLogger::Log( VSDebugLogger::LogLevelInfo, "SocketTransport: new client connection accepted." ); // We have established a connection with a client. m_clientConnected = true; setTransportFd(newFd); m_debugger->setClientConnected(true); } } } // Reset the event flags. fds[i].revents = 0; } } }
//================================================================================================= //================================================================================================= void Camera::startAcq() { DEB_MEMBER_FUNCT(); m_acq_frame_nb = -1; m_pcoData->pcoError = 0; m_pcoData->pcoErrorMsg[0] = 0; m_pcoData->traceAcqClean(); TIME_USEC tStart; msElapsedTimeSet(tStart); //===================================================================== DEF_FNID; HANDLE hEvent= NULL; DEB_ALWAYS() << _sprintComment(false, fnId, "[ENTRY]") << _checkLogFiles(); int error; //------------------------------------------------- start acquisition m_pcoData->traceAcq.msStartAcqStart = msElapsedTime(tStart); m_sync->setStarted(true); //m_sync->setExposing(pcoAcqRecordStart); m_sync->setExposing(pcoAcqStart); int iRequestedFrames; m_sync->getNbFrames(iRequestedFrames); int forced = 0; getRecorderForcedFifo(forced); int iPending; PCO_GetPendingBuffer(m_handle, &iPending); if(iPending < m_pco_buffer_nrevents) { PCO_CancelImages(m_handle); DEB_ALWAYS() << "PCO_CancelImages "<< DEB_VAR1(iPending); } unsigned long ulFramesMaxInSegment = _pco_GetNumberOfImagesInSegment_MaxCalc(m_pcoData->wActiveRamSegment); unsigned long ulRequestedFrames = (unsigned long) iRequestedFrames; if(ulRequestedFrames > 0) { WORD wDoubleImage; int err; // Double Image -> requested images will be the total nr of images (basic + primary) // must be even and twice of the nr of images for pco _pco_GetDoubleImageMode(wDoubleImage, err); bool bOutOfRange = false; if( (wDoubleImage) && ((ulRequestedFrames % 2) != 0) ) { DEB_ALWAYS() << "\nERROR odd nr of frames in DoubleImage"; bOutOfRange = true; } if((ulFramesMaxInSegment > 0) && (ulRequestedFrames > ulFramesMaxInSegment) && (!forced) ) { DEB_ALWAYS() << "\nERROR many frames in record mode"; bOutOfRange = true; } if(bOutOfRange) { char msg[MSG1K]; __sprintfSExt(msg, sizeof(msg)-1, "ERROR frames OUT OF RANGE ulRequestedFrames[%ld], ulFramesMaxInSegment[%ld], wDoubleImage[%d], forced[%d]", ulRequestedFrames, ulFramesMaxInSegment, wDoubleImage, forced); DEB_ALWAYS() << msg; m_sync->setStarted(false); m_sync->setExposing(pcoAcqError); throw LIMA_EXC(CameraPlugin, InvalidValue, msg); return; } } if(!_isRunAfterAssign()) { DEB_TRACE() << "========================= recordingState 1 - BEFORE ASSIGN (startAcq)"; _pco_SetRecordingState(1, error); } if(_isCameraType(Edge)){ _beginthread( _pco_acq_thread_edge, 0, (void*) this); #if 0 AutoMutex lock(m_cond.mutex()); bool resWait; int retry = 3; int val, val0; val0 = pcoAcqRecordStart; while( ((val = m_sync->getExposing()) != val0) && retry--) { DEB_TRACE() << "+++ getExposing / pcoAcqRecordStart - WAIT - " << DEB_VAR3(val, val0, retry); resWait = m_cond.wait(2.); } DEB_TRACE() << "+++ getExposing / pcoAcqRecordStart - EXIT - " << DEB_VAR3(val, val0, retry); lock.unlock(); #endif m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart); return; } #if 0 if(_isCameraType(Pco2k | Pco4k)){ _beginthread( _pco_acq_thread_ringBuffer, 0, (void*) this); m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart); return; } #endif if(_isCameraType(Dimax | Pco2k | Pco4k)){ int iRequestedFrames; m_sync->getNbFrames(iRequestedFrames); TrigMode trig_mode; m_sync->getTrigMode(trig_mode); _pco_SetRecordingState(1, error); int forcedFifo = 0; getRecorderForcedFifo(forcedFifo); if((iRequestedFrames > 0 ) && (forcedFifo == 0) ){ if((trig_mode == ExtTrigSingle) ) { _beginthread( _pco_acq_thread_dimax_trig_single, 0, (void*) this); } else { _beginthread( _pco_acq_thread_dimax, 0, (void*) this); // normal mode } } else { _beginthread( _pco_acq_thread_dimax_live, 0, (void*) this); } m_pcoData->traceAcq.msStartAcqEnd = msElapsedTime(tStart); return; } throw LIMA_HW_EXC(Error, "unkown camera type"); return; }
void TickerInfoManager::print_contents() const { lock_guard lock(pimpl_->mutex()); for (auto const& e : pimpl_->map()) std::cout << e.first << " " << e.second.first << " " << e.second.second << std::endl; }
RuntimeObjectImp* Instance::newRuntimeObject(ExecState* exec) { JSLock lock(SilenceAssertionsOnly); return new (exec) RuntimeObjectImp(exec, this); }
void MassStorage::Spin() { for (size_t card = 0; card < NumSdCards; ++card) { SdCardInfo& inf = info[card]; if (inf.cdPin != NoPin) { if (digitalRead(inf.cdPin)) { // Pin state says no card present switch (inf.cardState) { case CardDetectState::inserting: case CardDetectState::present: inf.cardState = CardDetectState::removing; inf.cdChangedTime = millis(); break; case CardDetectState::removing: if (millis() - inf.cdChangedTime > SdCardDetectDebounceMillis) { inf.cardState = CardDetectState::notPresent; if (inf.isMounted) { const unsigned int numFiles = InternalUnmount(card, false); if (numFiles != 0) { reprap.GetPlatform().MessageF(ErrorMessage, "SD card %u removed with %u file(s) open on it\n", card, numFiles); } } } break; default: break; } } else { // Pin state says card is present switch (inf.cardState) { case CardDetectState::removing: case CardDetectState::notPresent: inf.cardState = CardDetectState::inserting; inf.cdChangedTime = millis(); break; case CardDetectState::inserting: inf.cardState = CardDetectState::present; break; default: break; } } } } // Check if any files are supposed to be closed { MutexLocker lock(fsMutex); for (FileStore & fil : files) { if (fil.closeRequested) { // We could not close this file in an ISR, so do it here fil.Close(); } } } }
VJSModuleState *VJSModuleState::GetModuleState (XBOX::VJSContext &inContext) { VJSModuleState *moduleState; if ((moduleState = (VJSModuleState *) inContext.GetGlobalObjectPrivateInstance()->GetSpecific((VJSSpecifics::key_type) kSpecificKey)) == NULL) { XBOX::VError error; XBOX::VString urlString; error = XBOX::VE_OK; _GetRequireFunctionURL(&urlString); // If needed, load the JavaScript code of the require() function. if (!sIsCodeLoaded) { // Avoid race condition. XBOX::StLocker<XBOX::VCriticalSection> lock(&sMutex); if (!sIsCodeLoaded) { error = LoadScript(urlString, &sRequireFunctionURL, &sRequireFunctionScript); // Even if loading fails, set boolean as true, so as not to try again. sIsCodeLoaded = true; } } // Make require() function. XBOX::JS4D::ObjectRef requireFunctionRef = NULL; if (error != XBOX::VE_OK) { if (error == XBOX::VE_JVSC_SCRIPT_NOT_FOUND) XBOX::vThrowError(XBOX::VE_JVSC_SCRIPT_NOT_FOUND, urlString); else XBOX::vThrowError(error); } else if (!inContext.CheckScriptSyntax(sRequireFunctionScript, &sRequireFunctionURL, NULL)) { // Syntax error. XBOX::vThrowError(XBOX::VE_JVSC_SYNTAX_ERROR, urlString); } else { XBOX::VJSValue result(inContext); XBOX::JS4D::ExceptionRef exception; if (!inContext.EvaluateScript(sRequireFunctionScript, &sRequireFunctionURL, &result, &exception)) { // Should be more specific instead. XBOX::vThrowError(XBOX::VE_JVSC_SYNTAX_ERROR, urlString); } // Must return a function object for require(). xbox_assert(result.IsFunction()); requireFunctionRef = (XBOX::JS4D::ObjectRef) result.GetValueRef(); JS4D::ProtectValue(inContext, requireFunctionRef); } // Set module state. if ((moduleState = new VJSModuleState(requireFunctionRef)) == NULL) XBOX::vThrowError(XBOX::VE_MEMORY_FULL); else inContext.GetGlobalObjectPrivateInstance()->SetSpecific( (VJSSpecifics::key_type) kSpecificKey, moduleState, VJSSpecifics::DestructorVObject); } return moduleState; }
// Number of bytes, assumes a rx endpoint u8 USB_Available(u8 ep) { LockEP lock(ep); return FifoByteCount(); }
void* malloc(size_t bytes) { lock(); ++totalMallocs; if (bytes <= tinyBufferSize) { void* ptr = tinyMalloc(bytes); if (ptr) { ++mallocsFromTinyPool; unlock(); return ptr; } } // Failure to allocate a tiny buffer is allowed to flow // through to a small buffer if (bytes <= smallBufferSize) { void* ptr = malloc(smallPool, smallPoolSize, bytes); if (ptr) { ++mallocsFromSmallPool; unlock(); return ptr; } } else if (bytes <= medBufferSize) { // Note that a small allocation failure does *not* fall // through into a medium allocation because that would // waste the medium buffer's resources. void* ptr = malloc(medPool, medPoolSize, bytes); if (ptr) { ++mallocsFromMedPool; unlock(); return ptr; } } bytesAllocated += 4 + (int) bytes; unlock(); // Heap allocate // Allocate 4 extra bytes for our size header (unfortunate, // since malloc already added its own header). void* ptr = ::malloc(bytes + 4); if (ptr == NULL) { // Flush memory pools to try and recover space flushPool(smallPool, smallPoolSize); flushPool(medPool, medPoolSize); ptr = ::malloc(bytes + 4); } if (ptr == NULL) { if ((System::outOfMemoryCallback != NULL) && (System::outOfMemoryCallback(bytes + 4, true) == true)) { // Re-attempt the malloc ptr = ::malloc(bytes + 4); } } if (ptr == NULL) { if (System::outOfMemoryCallback != NULL) { // Notify the application System::outOfMemoryCallback(bytes + 4, false); } return NULL; } *(uint32*)ptr = (uint32)bytes; return (uint8*)ptr + 4; }
void GameTable::chat(User *u, const char *val){ MutexLockGuard lock(mutex); broadCast("Chat\n" + u->getName() + "\n" + val + "\n"); }
void App::inc_task() { std::unique_lock<std::mutex> lock(mutex); num_tasks++; }