Esempio n. 1
0
void
AsyncClientWorker::run() {
  int loopCount = 0;
  std::list<AsyncRunner *> clients;
  std::list<AsyncRunner *>::iterator it;
  do {
    // Create a new connection
    int n_clients = getConfig()->getAsyncClients();
    // Determine how many operations to perform on this connection

    for (int i = 0; i < n_clients; i++) {
      std::shared_ptr<TAsyncSocket> socket;
      try {
        socket = createSocket();
      } catch (const std::exception& ex) {
        ErrorAction action = handleConnError(ex);
        if (action == EA_CONTINUE || action == EA_NEXT_CONNECTION) {
          // continue the next connection loop
          continue;
        } else if (action == EA_DROP_THREAD) {
          T_ERROR("worker %d exiting after connection error", getID());
          stopWorker();
          return;
        } else if (action == EA_ABORT) {
          T_ERROR("worker %d causing abort after connection error", getID());
          abort();
        } else {
          T_ERROR("worker %d received unknown conn error action %d; aborting",
                  getID(), action);
          abort();
        }
      }
    }

    eb_.loop();

    for (it = clients_.begin(); it != clients_.end(); ++it) {
      AsyncRunner *r = *it;
      r->stop();
      delete r;
    }
    clients_.clear();

  }
  while (MAX_LOOPS == 0 || ++loopCount < MAX_LOOPS);

  stopWorker();
}
int PedometerSensor::activate(int32_t handle, int en)
{
        int flags = en ? 1 : 0;
        int ret;

        LOGI("PedomterSensor - %s - enable=%d", __FUNCTION__, en);

        if (!isConnectToPSH() || !isResultPipeSetup()) {
                LOGE("Invalid status while enable");
                return -1;
        }

        if (mEnabled == en) {
                LOGI("Duplicate request");
                return -1;
        }

        mEnabled = en;

        if (0 == mEnabled) {
                stopWorker();
                mCurrentDelay = 0;
        }  // we start worker when setDelay

        return 0;
}
bool PedometerSensor::restartWorker(int64_t newDelay)
{
        {
                Mutex::Autolock _l(mDelayMutex);
                mCurrentDelay = newDelay;
        }
        stopWorker();
        return startWorker();
}
PedometerSensor::~PedometerSensor()
{
        LOGI("~PedomterSensor %d\n", mEnabled);

        stopWorker();
        // close connection
        disconnectFromPSH();
        // close pipes
        tearDownResultPipe();
}
Esempio n. 5
0
static void stopPlayer()
{
    DSFLUIDSYNTH_TRACE("stopPlayer: fsPlayer " << fsPlayer);
    if(!fsPlayer) return;

    if(!DMFluid_Driver())
    {
        // Destroy the sfx buffer.
        DENG_ASSERT(sfxBuf != 0);
        DSFLUIDSYNTH_TRACE("stopPlayer: Destroying SFX buffer " << sfxBuf);

        DMFluid_Sfx()->Destroy(sfxBuf);
        sfxBuf = 0;

        stopWorker();
    }

    delete_fluid_player(fsPlayer);
    fsPlayer = 0;

    blockBuffer->clear();
}
SQL_Connection::~SQL_Connection() {
	stopWorker();
}