Exemple #1
0
 RedisReply* CoroRedisClient::SyncCall(RedisCommandFrame& cmd, int timeout)
 {
     Clear();
     m_expected_multi_reply_count = 1;
     m_ch->Write(cmd);
     CreateTimeoutTask(timeout);
     if (0 != WaitCoro())
     {
         return NULL;
     }
     if (!m_connect_success)
     {
         m_error_reply.SetErrorReason("client connection closed.");
         return &m_error_reply;
     }
     if (IsTimeout())
     {
         m_error_reply.SetErrorReason("server timeout");
         return &m_error_reply;
     }
     RedisReply* r = NULL;
     if (m_multi_replies.size() > 0)
     {
         r = m_multi_replies[0];
     }
     CancelTimeoutTask();
     return r;
 }
Exemple #2
0
 RedisReplyArray* CoroRedisClient::SyncMultiCall(RedisCommandFrameArray& cmds, int timeout)
 {
     Clear();
     m_expected_multi_reply_count = cmds.size();
     for (size_t i = 0; i < cmds.size(); i++)
     {
         m_ch->Write(cmds[i]);
     }
     CreateTimeoutTask(timeout);
     if (0 != WaitCoro())
     {
         return NULL;
     }
     if (!m_connect_success)
     {
         m_error_reply.SetErrorReason("client connection closed.");
         FillErrorReply();
         return &m_multi_replies;
     }
     if (IsTimeout())
     {
         m_error_reply.SetErrorReason("server timeout.");
         FillErrorReply();
         return &m_multi_replies;
     }
     CancelTimeoutTask();
     return &m_multi_replies;
 }
Exemple #3
0
 void CoroChannel::CreateTimeoutTask(int timeout)
 {
     CancelTimeoutTask();
     m_timeout = false;
     if (timeout > 0)
     {
         m_timeout_taskid = m_io_serv->GetTimer().Schedule(this, timeout, -1, MILLIS);
     }
 }
Exemple #4
0
void
TaskThrottler::CancelPendingTask(const MonitorAutoLock& aProofOfLock)
{
  if (mQueuedTask) {
    TASK_LOG("%p cancelling task %p\n", this, mQueuedTask.get());
    mQueuedTask->Cancel();
    mQueuedTask = nullptr;
    CancelTimeoutTask(aProofOfLock);
  }
}
Exemple #5
0
void
TaskThrottler::TaskComplete(const TimeStamp& aTimeStamp)
{
  MonitorAutoLock lock(mMonitor);

  if (!mOutstanding) {
    return;
  }

  mMean.insert(aTimeStamp - mStartTime);

  if (mQueuedTask) {
    RunQueuedTask(aTimeStamp, lock);
    CancelTimeoutTask(lock);
  } else {
    mOutstanding = false;
  }
}
Exemple #6
0
 CoroChannel::~CoroChannel()
 {
     CancelTimeoutTask();
     Close();
 }