void ossimQtImageControllerOssimEventCapture::disconnectInputEvent(ossimConnectionEvent& /*event*/) { // if(event.getOldObject()) // { // event.getOldObject()->removeListener((ossimConnectableObjectListener*)this); // } if(!theController||!theController->getImageWindow()) { return; } if(!isConnected()) { removeListener((ossimConnectableObjectListener*)this); removeListener((ossimDisplayEventListener*)this); if(theController->getAutoDeleteIfNoInputFlag()) { QCloseEvent* closeEvent = new QCloseEvent; QApplication::postEvent(theController->getImageWindow(), closeEvent); theController = NULL; } } else { ossimConnectableObjectListener::disableListener(); theController->initializePointers(); theController->initializeMenus(); QApplication::postEvent(theController->getImageWindow(), new ossimQtRefreshDisplayEvent); ossimConnectableObjectListener::enableListener(); } }
ossimQtImageControllerOssimEventCapture::~ossimQtImageControllerOssimEventCapture() { // for(int idx = 0; idx < getNumberOfInputs(); ++idx) // { // if(getInput(idx)) // { // getInput(idx)->removeListener((ossimConnectableObjectListener*)this); // } // } removeListener((ossimConnectableObjectListener*)this); removeListener((ossimDisplayEventListener*)this); theController = NULL; ossimConnectableObject::disconnect(); ossimReferenced::unref_nodelete(); }
void SoundManager::removeListener(Listener* listener) { if (listener == nullptr) return; removeListener(listener->getID()); }
LLSimpleDispatcher::~LLSimpleDispatcher() { while (mListeners.size() > 0) { removeListener(mListeners.begin()->listener); } }
void ProgressWidget::setObject(ossimObject* obj) { removeListener(); reset(); m_object = obj; addListener(); }
void GuideManager::endGuide() { Assistant::sharedAssistant()->removeResourceFromFile(P_Guide, T_Guide); m_guideLayer->removeFromParent(); m_guideLayer->release(); removeListener(); GuideHelper::getInstance()->setInGuide(false); }
// ============================================================================ void IncidentSvc::removeListener ( IIncidentListener* lis , const std::string& type ) { boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex); if( type == "") { // remove Listener from all the lists ListenerMap::iterator itmap; for ( itmap = m_listenerMap.begin(); itmap != m_listenerMap.end();) { // since the current entry may be eventually deleted // we need to keep a memory of the next index before // calling recursively this method ListenerMap::iterator itmap_old = itmap; itmap++; removeListener( lis, (*itmap_old).first ); } } else { ListenerMap::iterator itmap = m_listenerMap.find( type ); if( itmap == m_listenerMap.end() ) { // if not found the incident type then return return; } else { ListenerList* llist = (*itmap).second; ListenerList::iterator itlist; bool justScheduleForRemoval = ( 0!= m_currentIncidentType ) && (type == *m_currentIncidentType); // loop over all the entries in the Listener list // to remove all of them than matches // the listener address. Remember the next index // before erasing the current one for( itlist = llist->begin(); itlist != llist->end(); ) { if( (*itlist).iListener == lis || lis == 0) { if (justScheduleForRemoval) { (itlist++)->singleShot = true; // remove it as soon as it is safe } else { DEBMSG << "Removing [" << type << "] listener '" << getListenerName(lis) << "'" << endmsg; itlist = llist->erase(itlist); // remove from the list now } } else { itlist++; } } if( llist->size() == 0) { delete llist; m_listenerMap.erase(itmap); } } } }
ProgressWidget::~ProgressWidget() { if(m_listener) { removeListener(); delete m_listener; m_listener = 0; } m_object = 0; }
//LOCK!! UserConnection* MessageManager::getPMConn(const UserPtr& user) { auto i = ccpms.find(user); if (i != ccpms.end()) { auto uc = i->second; uc->removeListener(this); ccpms.erase(i); return uc; } return nullptr; }
void LLSimpleDispatcher::addListener(LLEventListener* listener, LLSD filter, const LLSD& userdata) { if (listener == NULL) return; removeListener(listener); LLListenerEntry new_entry; new_entry.listener = listener; new_entry.filter = filter; new_entry.userdata = userdata; mListeners.push_back(new_entry); listener->handleAttach(mParent); }
ossimImageChain::~ossimImageChain() { removeListener((ossimConnectableObjectListener*)this); deleteList(); if(theChildListener) { delete theChildListener; theChildListener = NULL; } }
// realtime context (dataTask) void RackDataModule::putDataBufferWorkSpace(uint32_t datalength) { uint32_t i; int ret; if (datalength > dataBufferMaxDataSize) return; bufferMtx.lock(RACK_INFINITE); listenerMtx.lock(RACK_INFINITE); index = (index + 1) % dataBufferMaxEntries; globalDataCount += 1; if(globalDataCount == 0) // handle uint32 overflow globalDataCount = 1; /* GDOS_PRINT("Put DataBuffer: buffer[%d/%d] @ %p, time %d, size %d \n", index, dataBufferMaxEntries, entry[index].p_data, getRecTime(entry[index].p_data), entry[index].dataSize); */ entry[index].dataSize = datalength; for (i=0; i<listenerNum; i++) { if ((globalDataCount % listener[i].reduction) == 0) { /* GDOS_ERROR("Sending continuous data to listener[%d] %n, listenernum: %d, " "reduction %d\n", i, listener[i].msgInfo.src, listenerNum, listener[i].reduction); */ ret = dataBufferSendMbx->sendDataMsgReply(MSG_DATA, &listener[i].msgInfo, 1, entry[index].p_data, entry[index].dataSize); if (ret) { GDOS_ERROR("DataBuffer: Can't send continuous data " "to listener %n, code = %d\n", listener[i].msgInfo.src, ret); removeListener(listener[i].msgInfo.src); } } } listenerMtx.unlock(); bufferMtx.unlock(); }
/** * \copydoc Controller::run() */ bool UpdateController::run() { addListener(lpStep); addListener(&lAutoCorrelator); addListener(&lParameterSum); // Run lPhase2N2subphases sub phases lpStep->setGain(lGainInitial); for (int subphase = 0; subphase < lNSubphases; ++subphase) { const pair<int, int> n = calculateNIterations(subphase); LOGS(Priority::INFO)<<"\n\n=== start subphase ===========" <<"\nSubphase: "<<subphase <<"\nIterations: ["<<n.first<<".."<<n.second<<"]" <<"\n==============================\n"; retryPhase(n); // Reduce gain lpStep->setGain(lpStep->getGain() * lGainDecay); LOGS(Priority::VERBOSE)<<"reduced gain to: "<<lpStep->getGain(); } removeListener(&lParameterSum); removeListener(&lAutoCorrelator); removeListener(lpStep); return true; }
void EditorButton::setState(bool state) { isEnabled = state; if (!state) { removeListener((Button::Listener*) getParentComponent()); } else { addListener((Button::Listener*) getParentComponent()); } repaint(); }
void SharedLoadingTask::postProcess() { // to receive progress info again. Should be safe now, we are alone. addListener(this); // ---- Color management ---- // switch (m_loadingDescription.postProcessingParameters.colorManagement) { case LoadingDescription::NoColorConversion: break; case LoadingDescription::ApplyTransform: { IccTransform trans = m_loadingDescription.postProcessingParameters.transform(); trans.apply(m_img, this); m_img.setIccProfile(trans.outputProfile()); break; } case LoadingDescription::ConvertForEditor: { IccManager manager(m_img); manager.transformDefault(); break; } case LoadingDescription::ConvertToSRGB: { IccManager manager(m_img); manager.transformToSRGB(); break; } case LoadingDescription::ConvertForDisplay: { IccManager manager(m_img); manager.transformForDisplay(m_loadingDescription.postProcessingParameters.profile()); break; } case LoadingDescription::ConvertForOutput: { IccManager manager(m_img); manager.transformForOutput(m_loadingDescription.postProcessingParameters.profile()); break; } } removeListener(this); }
void MessageManager::DisconnectCCPM(const UserPtr& aUser) { { RLock l(cs); auto i = chats.find(aUser); if (i != chats.end()) { i->second->closeCC(true, true); return; } } WLock l(cs); auto i = ccpms.find(aUser); if (i != ccpms.end()) { auto uc = i->second; uc->disconnect(true); uc->removeListener(this); ccpms.erase(i); } }
/// Closes the LocalConnection object. // /// This removes the advanceCallback (so we can be removed by the GC) and /// removes this object as a listener from the shared memory listeners /// section. void LocalConnection_as::close() { // We may be waiting either to send or to receive, so in both cases // make sure update() isn't called again. movie_root& mr = getRoot(owner()); mr.removeAdvanceCallback(this); if (!_connected) return; _connected = false; SharedMem::Lock lock(_shm); if (!lock.locked()) { log_error("Failed to get lock on shared memory! Will not remove " "listener"); return; } removeListener(_domain + ":" + _name, _shm); }
int main() { { auto s = std::make_shared<vik::EventSource>(); auto l = std::make_shared<EventListenerTester>(); // intentionally not using the vik::Event constructor // because it requires GameApp to be defined, which means // including a bazillion other files. BogusEvent bogusEvent; // test no events l->resetEventCount(); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 0); l->resetEventCount(); // test adding listener s->addListener(l); // test sending events s->onEvent(bogusEvent); s->onEvent(bogusEvent); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 3); // test removing listener l->resetEventCount(); s->removeListener(l); s->onEvent(bogusEvent); test_assert(l->getEventCount() == 0); // test listener being removed by being destroyed { auto l2 = std::make_shared<EventListenerTester>(); s->addListener(l2); } s->onEvent(bogusEvent); } generateReport(); }
Combo::~Combo() { removeListener(this); }
void ThumbnailLoadingTask::execute() { if (m_loadingTaskStatus == LoadingTaskStatusStopping) { return; } if (m_loadingDescription.previewParameters.onlyPregenerate()) { setupCreator(); switch (m_loadingDescription.previewParameters.type) { case LoadingDescription::PreviewParameters::Thumbnail: m_creator->pregenerate(m_loadingDescription.thumbnailIdentifier()); break; case LoadingDescription::PreviewParameters::DetailThumbnail: m_creator->pregenerateDetail(m_loadingDescription.thumbnailIdentifier(), m_loadingDescription.previewParameters.extraParameter.toRect()); break; default: break; } m_thread->taskHasFinished(); // do not emit any signal return; } LoadingCache* const cache = LoadingCache::cache(); { LoadingCache::CacheLock lock(cache); // find possible cached images const QImage* const cachedImage = cache->retrieveThumbnail(m_loadingDescription.cacheKey()); if (cachedImage) { m_qimage = QImage(*cachedImage); } if (m_qimage.isNull()) { // find possible running loading process m_usedProcess = cache->retrieveLoadingProcess(m_loadingDescription.cacheKey()); // do not wait on other loading processes? //m_usedProcess = cache->retrieveLoadingProcess(m_loadingDescription.cacheKey()); if (m_usedProcess) { // Other process is right now loading this image. // Add this task to the list of listeners and // attach this thread to the other thread, wait until loading // has finished. m_usedProcess->addListener(this); // break loop when either the loading has completed, or this task is being stopped while ( !m_usedProcess->completed() && m_loadingTaskStatus != LoadingTaskStatusStopping ) { lock.timedWait(); } // remove listener from process if (m_usedProcess) { m_usedProcess->removeListener(this); } // wake up the process which is waiting until all listeners have removed themselves lock.wakeAll(); // set to 0, as checked in setStatus m_usedProcess = 0; } else { // Neither in cache, nor currently loading in different thread. // Load it here and now, add this LoadingProcess to cache list. cache->addLoadingProcess(this); // Add this to the list of listeners addListener(this); // for use in setStatus m_usedProcess = this; // Notify other processes that we are now loading this image. // They might be interested - see notifyNewLoadingProcess below cache->notifyNewLoadingProcess(this, m_loadingDescription); } } } if (!m_qimage.isNull()) { // following the golden rule to avoid deadlocks, do this when CacheLock is not held postProcess(); m_thread->taskHasFinished(); m_thread->thumbnailLoaded(m_loadingDescription, m_qimage); return; } // Load or create thumbnail setupCreator(); switch (m_loadingDescription.previewParameters.type) { case LoadingDescription::PreviewParameters::Thumbnail: m_qimage = m_creator->load(m_loadingDescription.thumbnailIdentifier()); break; case LoadingDescription::PreviewParameters::DetailThumbnail: m_qimage = m_creator->loadDetail(m_loadingDescription.thumbnailIdentifier(), m_loadingDescription.previewParameters.extraParameter.toRect()); break; default: break; } { LoadingCache::CacheLock lock(cache); // put (valid) image into cache of loaded images if (!m_qimage.isNull()) { cache->putThumbnail(m_loadingDescription.cacheKey(), m_qimage, m_loadingDescription.filePath); } // remove this from the list of loading processes in cache cache->removeLoadingProcess(this); } { LoadingCache::CacheLock lock(cache); // indicate that loading has finished so that listeners can stop waiting m_completed = true; // dispatch image to all listeners, including this for (int i=0; i<m_listeners.count(); ++i) { ThumbnailLoadingTask* const task = dynamic_cast<ThumbnailLoadingTask*>(m_listeners.at(i)); if (task) { task->setResult(m_loadingDescription, m_qimage); } } // remove myself from list of listeners removeListener(this); // wake all listeners waiting on cache condVar, so that they remove themselves lock.wakeAll(); // wait until all listeners have removed themselves while (m_listeners.count() != 0) { lock.timedWait(); } // set to 0, as checked in setStatus m_usedProcess = 0; } // again: following the golden rule to avoid deadlocks, do this when CacheLock is not held postProcess(); m_thread->taskHasFinished(); m_thread->thumbnailLoaded(m_loadingDescription, m_qimage); }
void InputSource::removeInputListener( InputListener& inputListener ) { removeListener(inputListener); }
void ossimListenerManager::fireEvent(ossimEvent& event) { // only process the event if it has not been consumed. event.setCurrentObject( dynamic_cast<ossimObject*>(this) ); if(event.isConsumed()) { return; } theFireEventFlag = true; std::list<ossimListener*>::iterator currentIterator = theListenerList.begin(); while(currentIterator != theListenerList.end()) { // only fire if the event is not consumed if(!event.isConsumed()) { if(*currentIterator) { if(theDelayedRemove.end()==std::find(theDelayedRemove.begin(), theDelayedRemove.end(), (*currentIterator))) { if((*currentIterator)->isListenerEnabled()) { (*currentIterator)->processEvent(event); } } } } else { // the event is now consumed so stop propagating. // theFireEventFlag = false; break; } ++currentIterator; } theFireEventFlag = false; if(theDelayedAdd.size()) { for(std::list<ossimListener*>::iterator current = theDelayedAdd.begin(); current != theDelayedAdd.end();++current) { addListener(*current); } theDelayedAdd.clear(); } if(theDelayedRemove.size()) { for(std::list<ossimListener*>::iterator current = theDelayedRemove.begin(); current != theDelayedRemove.end();++current) { removeListener(*current); } theDelayedRemove.clear(); } }
status_t BnCameraService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case GET_NUMBER_OF_CAMERAS: { CHECK_INTERFACE(ICameraService, data, reply); reply->writeNoException(); reply->writeInt32(getNumberOfCameras()); return NO_ERROR; } break; case GET_CAMERA_INFO: { CHECK_INTERFACE(ICameraService, data, reply); CameraInfo cameraInfo = CameraInfo(); memset(&cameraInfo, 0, sizeof(cameraInfo)); status_t result = getCameraInfo(data.readInt32(), &cameraInfo); reply->writeNoException(); reply->writeInt32(result); // Fake a parcelable object here reply->writeInt32(1); // means the parcelable is included reply->writeInt32(cameraInfo.facing); reply->writeInt32(cameraInfo.orientation); return NO_ERROR; } break; case GET_CAMERA_CHARACTERISTICS: { CHECK_INTERFACE(ICameraService, data, reply); CameraMetadata info; status_t result = getCameraCharacteristics(data.readInt32(), &info); reply->writeNoException(); reply->writeInt32(result); // out-variables are after exception and return value reply->writeInt32(1); // means the parcelable is included info.writeToParcel(reply); return NO_ERROR; } break; case CONNECT: { CHECK_INTERFACE(ICameraService, data, reply); sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder()); int32_t cameraId = data.readInt32(); const String16 clientName = data.readString16(); int32_t clientUid = data.readInt32(); sp<ICamera> camera; status_t status = connect(cameraClient, cameraId, clientName, clientUid, /*out*/ camera); reply->writeNoException(); reply->writeInt32(status); if (camera != NULL) { reply->writeInt32(1); reply->writeStrongBinder(camera->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CONNECT_PRO: { CHECK_INTERFACE(ICameraService, data, reply); sp<IProCameraCallbacks> cameraClient = interface_cast<IProCameraCallbacks>(data.readStrongBinder()); int32_t cameraId = data.readInt32(); const String16 clientName = data.readString16(); int32_t clientUid = data.readInt32(); sp<IProCameraUser> camera; status_t status = connectPro(cameraClient, cameraId, clientName, clientUid, /*out*/ camera); reply->writeNoException(); reply->writeInt32(status); if (camera != NULL) { reply->writeInt32(1); reply->writeStrongBinder(camera->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CONNECT_DEVICE: { CHECK_INTERFACE(ICameraService, data, reply); sp<ICameraDeviceCallbacks> cameraClient = interface_cast<ICameraDeviceCallbacks>(data.readStrongBinder()); int32_t cameraId = data.readInt32(); const String16 clientName = data.readString16(); int32_t clientUid = data.readInt32(); sp<ICameraDeviceUser> camera; status_t status = connectDevice(cameraClient, cameraId, clientName, clientUid, /*out*/ camera); reply->writeNoException(); reply->writeInt32(status); if (camera != NULL) { reply->writeInt32(1); reply->writeStrongBinder(camera->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case ADD_LISTENER: { CHECK_INTERFACE(ICameraService, data, reply); sp<ICameraServiceListener> listener = interface_cast<ICameraServiceListener>(data.readStrongBinder()); reply->writeNoException(); reply->writeInt32(addListener(listener)); return NO_ERROR; } break; case REMOVE_LISTENER: { CHECK_INTERFACE(ICameraService, data, reply); sp<ICameraServiceListener> listener = interface_cast<ICameraServiceListener>(data.readStrongBinder()); reply->writeNoException(); reply->writeInt32(removeListener(listener)); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
// realtime context (dataTask) void RackDataModule::putDataBufferWorkSpace(uint32_t datalength) { uint32_t i; int ret; if ((datalength < 0) || (datalength > dataBufferMaxDataSize)) { GDOS_WARNING("datalen %i doesn't fit dataBufferMaxDataSize %i", datalength, dataBufferMaxDataSize); return; } bufferMtx.lock(RACK_INFINITE); listenerMtx.lock(RACK_INFINITE); index = (index + 1) % dataBufferMaxEntries; globalDataCount += 1; if(globalDataCount == 0) // handle uint32 overflow globalDataCount = 1; /* GDOS_PRINT("Put DataBuffer: buffer[%d/%d] @ %p, time %d, size %d \n", index, dataBufferMaxEntries, dataBuffer[index].pData, getRecordingTime(dataBuffer[index].pData), dataBuffer[index].dataSize); */ dataBuffer[index].dataSize = datalength; for (i=0; i<listenerNum; i++) { if ((globalDataCount % listener[i].reduction) == 0) { /* GDOS_ERROR("Sending continuous data to listener[%d] %n, listenernum: %d, " "reduction %d\n", i, listener[i].msgInfo.getSrc(), listenerNum, listener[i].reduction); */ ret = dataBufferSendMbx->sendDataMsgReply(MSG_DATA, &listener[i].msgInfo, 1, dataBuffer[index].pData, dataBuffer[index].dataSize); if (ret) { GDOS_ERROR("DataBuffer: Can't send continuous data " "to listener %n, code = %d\n", listener[i].msgInfo.getSrc(), ret); removeListener(listener[i].msgInfo.getSrc()); } else if (listener[i].getNextData) { /* GDOS_DBG_DETAIL("DataBuffer: Remove nextData listener %n time %i\n", listener[i].msgInfo.getSrc(), rackTime.get()); */ removeListener(listener[i].msgInfo.getSrc()); } } } listenerMtx.unlock(); bufferMtx.unlock(); }
void Button::removeButtonListener (ButtonListener* l) { removeListener (l); }
// realtime context (cmdTask) int RackDataModule::moduleCommand(RackMessage *msgInfo) { int ret = 0; switch (msgInfo->getType()) { case MSG_GET_DATA: { rack_get_data *p_data = RackGetData::parse(msgInfo); //GDOS_DBG_DETAIL("CmdTask: GET_DATA: from %n -> %n, recTime: %d\n", // msgInfo->src, msgInfo->dest, p_data->recordingTime); if (status == MODULE_STATE_ENABLED) { ret = sendDataReply(p_data->recordingTime, msgInfo); if (ret) { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } } else { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } return 0; } case MSG_GET_CONT_DATA: { rack_get_cont_data *p_data = RackGetContData::parse(msgInfo); GDOS_DBG_DETAIL("CmdTask: GET_CONT_DATA: %n -> %n,type: %d, Prio: %d, " " seq: %d, len: %d, dataMbx: %x, periodTime: %d\n", msgInfo->getSrc(), msgInfo->getDest(), msgInfo->getType(), msgInfo->getPriority(), msgInfo->getSeqNr(), msgInfo->datalen, p_data->dataMbxAdr, p_data->periodTime); if (status == MODULE_STATE_ENABLED) { ret = addListener(p_data->periodTime, 0, p_data->dataMbxAdr, msgInfo); if (ret) { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } else { rack_cont_data contData; contData.periodTime = getListenerPeriodTime(p_data->dataMbxAdr); ret = cmdMbx.sendDataMsgReply(MSG_CONT_DATA, msgInfo, 1, &contData, sizeof(rack_cont_data)); if (ret) { GDOS_ERROR("CmdTask: Can't send get_cont_data reply, " "code = %d\n", ret); return ret; } } } else // status != MODULE_STATE_ENABLED { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } return 0; } case MSG_STOP_CONT_DATA: { rack_stop_cont_data *p_data = RackStopContData::parse(msgInfo); GDOS_DBG_DETAIL("CmdTask: STOP_CONT_DATA: from %n, to %n, dataMbx: %x\n", msgInfo->getSrc(), msgInfo->getDest(), p_data->dataMbxAdr); listenerMtx.lock(RACK_INFINITE); removeListener(p_data->dataMbxAdr); listenerMtx.unlock(); ret = cmdMbx.sendMsgReply(MSG_OK, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send ok reply, code = %d\n", ret); return ret; } return 0; } case MSG_GET_NEXT_DATA: { //GDOS_DBG_DETAIL("CmdTask: GET_NEXT_DATA: %n -> %n, type: %d\n", // msgInfo->src, msgInfo->dest, msgInfo->type); if (status == MODULE_STATE_ENABLED) { ret = addListener(0, 1, msgInfo->getSrc(), msgInfo); if (ret) { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } } else // status != MODULE_STATE_ENABLED { ret = cmdMbx.sendMsgReply(MSG_ERROR, msgInfo); if (ret) { GDOS_ERROR("CmdTask: Can't send error reply, " "code = %d\n", ret); return ret; } } return 0; } default: // not for me -> ask Module return RackModule::moduleCommand(msgInfo); } }
void LocalConnection_as::update() { // Check whether local connection is disabled(!): brilliant choice of // function name. if (rcfile.getLocalConnection()) { log_security("Attempting to write to disabled LocalConnection!"); movie_root& mr = getRoot(owner()); mr.removeAdvanceCallback(this); return; } // No-op if already attached. Nothing to do if it fails, but we // should probably stop trying. if (!_shm.attach()) { log_error("Failed to attach shared memory segment"); return; } // We need the lock to prevent simultaneous reads/writes from other // processes. SharedMem::Lock lock(_shm); if (!lock.locked()) { log_debug("Failed to get shm lock"); return; } SharedMem::iterator ptr = _shm.begin(); // First check timestamp data. // These are not network byte order by default, but not sure about // host byte order. const boost::uint32_t timestamp = readLong(ptr + 8); const boost::uint32_t size = readLong(ptr + 12); // As long as there is a timestamp in the shared memory, we mustn't // write anything. // // We check if this is data we are listening for. If it is, read it and // mark for overwriting. // // If not, we keep checking until the data has been overwritten by // another listener or until it's expired. If it's expired, we // mark for overwriting. if (timestamp) { // Start after 16-byte header. const boost::uint8_t* b = ptr + 16; // End at reported size of AMF sequence. const boost::uint8_t* end = b + size; amf::Reader rd(b, end, getGlobal(owner())); as_value a; // Get the connection name. That's all we need to remove expired // data. if (!rd(a)) { log_error("Invalid connection name data"); return; } const std::string& connection = a.to_string(); // Now check if data we wrote has expired. There's no really // reliable way of checking that we genuinely wrote it. if (_lastTime == timestamp) { const size_t timeout = 4 * 1000; VM& vm = getVM(owner()); const boost::uint32_t timeNow = getTimestamp(vm); if (timeNow - timestamp > timeout) { log_debug("Data %s expired at %s. Removing its target " "as a listener", timestamp, timeNow); removeListener(connection, _shm); markRead(_shm); _lastTime = 0; } } // If we are listening and the data is for us, get the rest of it // and call the method. if (_connected && connection == _domain + ":" + _name) { executeAMFFunction(owner(), rd); // Zero the timestamp bytes to signal that the shared memory // can be written again. markRead(_shm); } else { // The data has not expired and we didn't read it. Leave it // alone until it's expired or someone else has read it. return; } } // If we have no data to send, there's nothing more to do. if (_queue.empty()) { // ...except remove the callback if we aren't listening for anything. if (!_connected) { movie_root& mr = getRoot(owner()); mr.removeAdvanceCallback(this); } return; } // Get the first buffer. boost::shared_ptr<ConnectionData> cd = _queue.front(); _queue.pop_front(); // If the correct listener isn't there, iterate until we find one or // there aren't any left. while (!findListener(_domain + ":" + cd->name, _shm)) { if (_queue.empty()) { // Make sure we send the empty header later. cd->ts = 0; break; } cd = _queue.front(); _queue.pop_front(); } // Yes, there is data to send. const char i[] = { 1, 0, 0, 0, 1, 0, 0, 0 }; std::copy(i, i + arraySize(i), ptr); SimpleBuffer& buf = cd->data; SharedMem::iterator tmp = ptr + 8; writeLong(tmp, cd->ts); writeLong(tmp, cd->ts ? buf.size() : 0); std::copy(buf.data(), buf.data() + buf.size(), tmp); // Note the timestamp of our last send. We will keep calling update() // until the data has expired or been read. _lastTime = cd->ts; }
//************************************************************************************************* // Destructor. //************************************************************************************************* ossimImageChainMtAdaptor::~ossimImageChainMtAdaptor() { removeListener((ossimConnectableObjectListener*)this); m_clones.clear(); m_chainContainers.clear(); }
void DeviceManager::removeListeners() { Listeners listeners = mListeners; // The copy is on purpose here for ( Listeners::iterator itr=listeners.begin(); itr!=listeners.end(); ++itr ) removeListener( *itr ); }
ossimImageSourceSequencer::~ossimImageSourceSequencer() { removeListener((ossimConnectableObjectListener*)this); }