void MpiLauncher::destroy(bool force) { pid_t pid=0; int status=0; string pidFile; { ScopedMutexLock lock(_mutex); if (_pid == 0 || _waiting) { throw (InvalidStateException(REL_FILE, __FUNCTION__, __LINE__) << " MPI launcher already destroyed"); } _waiting = true; pid = _pid; status = _status; pidFile = mpi::getLauncherPidFile(_installPath, _queryId, _launchId); if (pid > 0) { if (!force) { scheduleKillTimer(); } else { // kill right away boost::shared_ptr<boost::asio::deadline_timer> dummyTimer; boost::system::error_code dummyErr; handleKillTimeout(dummyTimer, dummyErr); } } if (force) { _inError=true; } } if (pid < 0) { completeLaunch(-pid, pidFile, status); return; } bool rc = waitForExit(pid,&status); assert(rc); rc=rc; { ScopedMutexLock lock(_mutex); if (!_waiting || pid != _pid) { throw InvalidStateException(REL_FILE, __FUNCTION__, __LINE__) << " MPI launcher is corrupted after collecting process exit code"; } _pid = -pid; _status = status; if (_killTimer) { size_t n = _killTimer->cancel(); assert(n<2); n=n; } } completeLaunch(pid, pidFile, status); }
void FireworkObjectImplementation::launch(CreatureObject* player, int removeDelay) { if (player == NULL) return; if(getDelay() == 0) { completeLaunch(player, removeDelay); return; } Reference<FireworkLaunchEvent*> launchEvent = new FireworkLaunchEvent(player, _this.getReferenceUnsafeStaticCast(), removeDelay); launchEvent->schedule(delay * 1000); }