Example #1
0
void consumer(void)
{
    int value;
    while (!done) {
        while (queue.pop(value))
            ++consumer_count;
    }

    while (queue.pop(value))
        ++consumer_count;
}
Example #2
0
  // Must NOT be called without first calling wait()
  T get_withoutWaiting(){
    T ret = 0;
    
    R_ASSERT(queue.pop(ret));

    return ret;
  }
void consumer(void)
{
    int value;
    //当没有生产完毕,则边消费边生产
    while(!done)
    {
        while(queue.pop(value))
        {
            cout<<"-"<<endl;
            ++c_count;
        }
    }
    //如果生产完毕则消费
    while(queue.pop(value))
    {
        ++c_count;
    }
}
Example #4
0
TRI_connection_statistics_t* TRI_AcquireConnectionStatistics () {
  TRI_connection_statistics_t* statistics = nullptr;

  if (TRI_ENABLE_STATISTICS && ConnectionFreeList.pop(statistics)) {
    return statistics;
  }

  return nullptr;
}
Example #5
0
TRI_request_statistics_t* TRI_AcquireRequestStatistics () {
  TRI_request_statistics_t* statistics = nullptr;

  if (TRI_ENABLE_STATISTICS && RequestFreeList.pop(statistics)) {
    return statistics;
  }

  return nullptr;
}
Example #6
0
static void StatisticsQueueWorker (void* data) {
  while (! Shutdown && TRI_ENABLE_STATISTICS) {
    size_t count = ProcessAllRequestStatistics();

    if (count == 0) {
      usleep(100 * 1000);
    }
    else if (count < 10) {
      usleep(10 * 1000);
    }
    else if (count < 100) {
      usleep(1 * 1000);
    }
  }

  delete TRI_ConnectionTimeDistributionStatistics;
  delete TRI_TotalTimeDistributionStatistics;
  delete TRI_RequestTimeDistributionStatistics;
  delete TRI_QueueTimeDistributionStatistics;
  delete TRI_IoTimeDistributionStatistics;
  delete TRI_BytesSentDistributionStatistics;
  delete TRI_BytesReceivedDistributionStatistics;

  {
    TRI_request_statistics_t* entry = nullptr;
    while (RequestFreeList.pop(entry)) {
      delete entry;
    }
  }

  {
    TRI_request_statistics_t* entry = nullptr;
    while (RequestFinishedList.pop(entry)) {
      delete entry;
    }
  }

  {
    TRI_connection_statistics_t* entry = nullptr;
    while (ConnectionFreeList.pop(entry)) {
      delete entry;
    }
  }
}
Example #7
0
    void deallocate(void)
    {
        for (;;) {
            dummy * node;
            if (allocated_nodes.pop(node)) {
                bool success = working_set.erase(node);
                assert(success);
                fl.template destruct<true>(node);
            }

            if (running.load() == false)
                break;
        }

        dummy * node;
        while (allocated_nodes.pop(node)) {
            bool success = working_set.erase(node);
            assert(success);
            fl.template destruct<true>(node);
        }
    }
Example #8
0
static size_t ProcessAllRequestStatistics () {
  TRI_request_statistics_t* statistics = nullptr;
  size_t count = 0;

  while (RequestFinishedList.pop(statistics)) {
    if (statistics != nullptr) {
      ProcessRequestStatistics(statistics);
      ++count;
    }
  }

  return count;
}
Example #9
0
    /* 
     * The worker_thread blocks in this loop. 
     * As a member function, it must be binded with this ptr.
     */
    void worker_thread() {

        for (;;) {
            boost::mutex::scoped_lock lock(this->tp_mutex);
            cv.wait(lock);
            if (work_queue.empty())
                continue;
            work_t w;
            if (work_queue.pop(w))
                w->run();
            else
                thread_run_error();
        }

    }
Example #10
0
  // sets success to false if failed, true if succeeded. Return value is undefined if "success" is false.
  T tryGet(bool &success){
    T ret = 0;
    
    if (ready.tryWait()) {
    
      R_ASSERT(queue.pop(ret));

      success = true;

    } else {

      success = false;

    }
    
    return ret;
  }
Example #11
0
void bConsume(int* x)
{
    int y;
    bQ.pop(y);
    *x = y;
}
 void* get()
 {
     void* r;
     if ( stack_.pop(r) ) return r;
     return znn_malloc(mem_size_);
 }