MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui_(new Ui::MainWindow), data_file_name_(DATA_FILE_PATH), password_(QString()), money_(Money()) { ui_->setupUi(this); connect(ui_->ActionChangePass, SIGNAL(triggered()), this, SLOT(changePassword())); connect(ui_->ActionSave, SIGNAL(triggered()), this, SLOT(saveData())); connect(ui_->ActionExit, SIGNAL(triggered()), this, SLOT(requestExit())); connect(ui_->ActionUpdate, SIGNAL(triggered()), this, SLOT(updateState())); connect(ui_->AddEventButton, SIGNAL(clicked()), this, SLOT(addEvent())); connect(ui_->AddFriendButton, SIGNAL(clicked()), this, SLOT(addFriend())); connect(ui_->DelEventsButton, SIGNAL(clicked()), this, SLOT(delEvents())); connect(ui_->DelFriendsButton, SIGNAL(clicked()), this, SLOT(delFriends())); // financial events connect(ui_->CurRubNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurEurNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurUsdNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurRubElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurEurElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->CurUsdElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldRubNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldEurNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldUsdNalEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldRubElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldEurElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); connect(ui_->OldUsdElecEdit, SIGNAL(textChanged(QString)), this, SLOT(changeMoneyDiff())); loadData(); updateState(); }
//----------------------------------------------------------------------------- MBOOL ThermalMonitorImp:: exit() { //Mutex::Autolock lock(mLock); // FUNC_START; // requestExit(); // mState = STATE_EXIT; mCond.broadcast(); // MY_LOGD("join() E"); status_t status = join(); if( OK != status ) { MY_LOGW("Not to wait , status[%s(%d)]", ::strerror(-status), -status); } MY_LOGD("join() X"); // FUNC_END; // return MTRUE; }
void HeadSetDetect::stop() { SXLOGV("HeadSetDetect::stop"); Mutex::Autolock _l(mLock); mActive = false; requestExit(); }
void TaskManager::WorkerThread::exit() { { Mutex::Autolock l(mLock); mTasks.clear(); } requestExit(); mSignal.signal(); }
void BootAnimation::checkExit() { // Allow surface flinger to gracefully request shutdown char value[PROPERTY_VALUE_MAX]; property_get(EXIT_PROP_NAME, value, "0"); int exitnow = atoi(value); if (exitnow) { requestExit(); } }
void AudioPolicyService::AudioCommandThread::exit() { LOGV("AudioCommandThread::exit"); { AutoMutex _l(mLock); requestExit(); mWaitWorkCV.signal(); } requestExitAndWait(); }
void BootAnimation::binderDied(const wp<IBinder>&) { // woah, surfaceflinger died! ALOGD("SurfaceFlinger died, exiting..."); // calling requestExit() is not enough here because the Surface code // might be blocked on a condition variable that will never be updated. kill( getpid(), SIGKILL ); requestExit(); }
void Exit() { { Mutex::Autolock _l(m_LockCondition); LOGI("[VTMAL][SendThread]@Thread Exit--start"); requestExit(); LOGI("[VTMAL][SendThread]@Thread Exit--end"); m_sentSignal = true; mWaitWork.signal(); } requestExitAndWait(); LOGI("[VTMAL][SendThread]@Thread Exit--real exit"); }
status_t LivePhotoSource::stop() { ALOGD("+"); bool bStopSource = false; { Mutex::Autolock _lock(mLock); if(mSourceStarted && !mLivePhotoStarted) { bStopSource = true; mSourceStarted = false; ALOGD("signal to stop writer read"); mFrameAvailableCond.signal(); //mWriterReadEndCond.wait(mLock); } else if(mLivePhotoStarted) { ALOGD("wait writer read end"); mWriterReadEndCond.wait(mLock); } } status_t err = OK; if(bStopSource) { { Mutex::Autolock _lock(mLock); if(mIsThreadExit) { ALOGD("thread exited, no need wait"); } else { ALOGD("wait thread exit"); mThreadExitCond.wait(mLock); } } requestExit(); requestExitAndWait(); if(mSource != NULL) { ALOGD("mSource stop()"); err = mSource->stop(); } } ALOGD("-"); return err; }
bool IntroState::update(sf::Time dt) { mAge += dt; if (mAge >= mpTimeSteps[mCurrent]) { mAge = sf::Time::Zero; mCurrent++; if (mCurrent<mCount){ // valid frame -> change image and text mText.setString(mpStrings[mCurrent]); mBackgroundSprite.setTextureRect(sf::IntRect((mCurrent+22) % 6 * 1024, (mCurrent+22) / 6 * 768, 1024, 768)); } else { printf("logostate r exit: mCurrent=%d", mCurrent); requestExit(); } } return true; }
status_t Thread::requestExitAndWait() { if (mThread == getThreadId()) { LOGW( "Thread (this=%p): don't call waitForExit() from this " "Thread object's thread. It's a guaranteed deadlock!", this); return WOULD_BLOCK; } requestExit(); Mutex::Autolock _l(mLock); while (mRunning == true) { mThreadExitedCondition.wait(mLock); } mExitPending = false; return mStatus; }
status_t LivePhotoSource::startLivePhoto() { ALOGD("+"); bool bStopSource = false; { Mutex::Autolock _lock(mLock); if(mSourceStarted && !mLivePhotoStarted) { bStopSource = true; mLivePhotoStarted = true; //mSourceStarted = false; // move before source stop()?? ALOGD("wait read source end"); } else if(mLivePhotoStarted) { ALOGD("live photo has been started"); return OK; } else return UNKNOWN_ERROR; } status_t err = OK; if(bStopSource) { { Mutex::Autolock _lock(mLock); ALOGD("wait thread exit"); mThreadExitCond.wait(mLock); } requestExit(); requestExitAndWait(); if(mSource != NULL) { ALOGD("mSource stop()"); err = mSource->stop(); } } ALOGD("-"); return err; }
void Component::run() { try { std::cerr << "starting component " << name << "..." << std::endl; startIO(); std::cerr << " ... " << name << " ready." << std::endl; } catch (std::exception & ex) { log->error("Cannot startup component:", &ex); try { state = STATE_FAILURE; meta.reportState(state, "Cannot startup component:", &ex); } catch (CMSException & me) { log->error("cannot report failure state", & me); } requestExit(); } while (!exitRequested()) { // Report that we are alive before we check system ready status, // (in case we were stalled due to a long act() or react() this // means we "report back" to the rest of the system) meta.IamAlive(); //printf("run %i\n",exitRequested()); // Check at every loop that the total system is ready bool exitFlag = false; synchronized (&meta) { if (!meta.isSystemReady()) { log->info("waiting for system to become ready"); } while (!meta.isSystemReady()) { try { meta.wait(1000); } catch (decaf::lang::Exception & ie) { ie.printStackTrace(); } if (meta.isSystemReady()) { log->info("system ready - let's go"); } if (exitRequested()) { exitFlag = true; break; } } } if (exitFlag) break; try { // Check if we should do something proactively: long long before = System::currentTimeMillis(); act(); long long timeSpentInAct = System::currentTimeMillis() - before; meta.statistics()->actTime((long)timeSpentInAct); } catch (std::exception & e) { log->error("error when trying to act", & e); try { state = STATE_FAILURE; meta.reportState(state, "error when trying to act", &e); } catch (CMSException & me) { log->error("cannot report failure state", & me); } requestExit(); return; } Receiver * r = NULL; synchronized (&mutex) { if (inputWaiting.empty()) { // block until input becomes available mutex.wait(waitingTime); } // check again if (!inputWaiting.empty()) { r = inputWaiting.front(); inputWaiting.pop(); } } if (r == NULL) continue; //assert(receivers.contains(r)); // the receiver that alerted us is not one of our receivers; SEMAINEMessage * message = r->getMessage(); assert(message != NULL); // Receiver alerted me but has no message meta.statistics()->countMessageReceived(); try { // time that the message travelled, in "user" time (ms since system startup -- this should be independent of clock asynchrony) long long timeMessageTravelled = meta.getTime() - message->getUsertime(); meta.statistics()->transmitTime((long)timeMessageTravelled); // Now, do something meaningful with the message, // and possibly send output via the Senders. long long before = System::currentTimeMillis(); react(message); delete message; long long timeSpentInReact = System::currentTimeMillis() - before; meta.statistics()->reactTime((long)timeSpentInReact); } catch (std::exception & e) { log->error("error when trying to react", &e); try { state = STATE_FAILURE; std::string errMsg = CMSLogger::toLogMessageText("error when trying to react", &e) + "(message was: " + CMSLogger::message2logString(message) + ")"; meta.reportState(state, errMsg); } catch (CMSException & me) { log->error("cannot report failure state", & me); } requestExit(); return; } } }
MainWindow::MainWindow() : QMainWindow() { setWindowTitle("Miroslav Beta 7"); menuBar(); fileMenu = menuBar()->addMenu(tr("File")); settingsMenu = menuBar()->addMenu(tr("Settings")); connectAction = new QAction(tr("Connect..."), this); reconnectAction = new QAction(tr("Reconnect"), this); disconnectAction = new QAction(tr("Disconnect"), this); disconnectAction->setEnabled(false); closeWindowAction = new QAction(tr("Close Window"), this); quitAction = new QAction(tr("Quit"), this); fileMenu->addAction(connectAction); fileMenu->addAction(reconnectAction); fileMenu->addAction(disconnectAction); fileMenu->addSeparator(); fileMenu->addAction(closeWindowAction); fileMenu->addAction(quitAction); changeNickAction = new QAction(tr("Change Nickname..."), this); changeNickAction->setEnabled(false); changeColorAction = new QAction(tr("Change Text Color..."), this); changeColorAction->setEnabled(false); settingsMenu->addAction(changeNickAction); settingsMenu->addAction(changeColorAction); mainWidget = new MainWidget(this); setCentralWidget(mainWidget); resize(600,350); trayIcon = new TrayIcon(this); // Menu connections connect(connectAction, SIGNAL(triggered()), mainWidget, SLOT(requestConnection())); connect(reconnectAction, SIGNAL(triggered()), mainWidget, SLOT(loadSettings())); connect(disconnectAction, SIGNAL(triggered()), mainWidget, SLOT(requestDisconnect())); connect(closeWindowAction, SIGNAL(triggered()), trayIcon, SLOT(showHideWindow())); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(changeNickAction, SIGNAL(triggered()), mainWidget, SLOT(requestChangeNick())); connect(changeColorAction, SIGNAL(triggered()), mainWidget, SLOT(requestChangeColor())); // Menu activate connections connect(mainWidget, SIGNAL(canConnect(bool)), this, SLOT(canConnect(bool))); connect(mainWidget, SIGNAL(canDisconnect(bool)), this, SLOT(canDisconnect(bool))); connect(mainWidget, SIGNAL(canChangeNick(bool)), this, SLOT(canChangeNick(bool))); connect(mainWidget, SIGNAL(canChangeColor(bool)), this, SLOT(canChangeColor(bool))); // Tray Icon connections connect(trayIcon, SIGNAL(requestExit()), qApp, SLOT(quit())); connect(trayIcon, SIGNAL(showChatWindow(bool)), this, SLOT(setVisible(bool))); connect(mainWidget, SIGNAL(newMessage(QString, QString)), this, SLOT(newMessage(QString, QString))); mainWidget->loadSettings(); show(); }
void TaskManager::WorkerThread::exit() { requestExit(); mSignal.signal(); }
void AudioDaemon::binderDied(const wp<IBinder>& who) { requestExit(); }
connect(this, SIGNAL(requestStopSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(stopSound(const QString&))); connect(this, SIGNAL(requestDropSound(const QString&)), StelApp::getInstance().getStelAudioMgr(), SLOT(dropSound(const QString&))); connect(this, SIGNAL(requestLoadVideo(const QString&, const QString&, float, float, bool, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(loadVideo(const QString&, const QString&, float, float, bool, float))); connect(this, SIGNAL(requestPlayVideo(const QString&, const bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(playVideo(const QString&, const bool))); connect(this, SIGNAL(requestPlayVideoPopout(QString,float,float,float,float,float,float,float,bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(playVideoPopout(QString,float,float,float,float,float,float,float,bool))); connect(this, SIGNAL(requestPauseVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(pauseVideo(const QString&))); connect(this, SIGNAL(requestStopVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(stopVideo(const QString&))); connect(this, SIGNAL(requestDropVideo(const QString&)), StelApp::getInstance().getStelVideoMgr(), SLOT(dropVideo(const QString&))); connect(this, SIGNAL(requestSeekVideo(const QString&, qint64, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(seekVideo(const QString&, qint64, bool))); connect(this, SIGNAL(requestSetVideoXY(const QString&, float, float, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(setVideoXY(const QString&, float, float, bool))); connect(this, SIGNAL(requestSetVideoAlpha(const QString&, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(setVideoAlpha(const QString&, float))); connect(this, SIGNAL(requestResizeVideo(const QString&, float, float)), StelApp::getInstance().getStelVideoMgr(), SLOT(resizeVideo(const QString&, float, float))); connect(this, SIGNAL(requestShowVideo(const QString&, bool)), StelApp::getInstance().getStelVideoMgr(), SLOT(showVideo(const QString&, bool))); connect(this, SIGNAL(requestExit()), this->parent(), SLOT(stopScript())); connect(this, SIGNAL(requestSetNightMode(bool)), &StelApp::getInstance(), SLOT(setVisionModeNight(bool))); connect(this, SIGNAL(requestSetProjectionMode(QString)), StelApp::getInstance().getCore(), SLOT(setCurrentProjectionTypeKey(QString))); connect(this, SIGNAL(requestSetSkyCulture(QString)), &StelApp::getInstance().getSkyCultureMgr(), SLOT(setCurrentSkyCultureID(QString))); connect(this, SIGNAL(requestSetDiskViewport(bool)), StelApp::getInstance().getMainScriptAPIProxy(), SLOT(setDiskViewport(bool))); connect(this, SIGNAL(requestSetHomePosition()), StelApp::getInstance().getCore(), SLOT(returnToHome())); } StelMainScriptAPI::~StelMainScriptAPI() { } //! Set the current date in Julian Day //! @param JD the Julian Date (UT) void StelMainScriptAPI::setJDay(double JD) {