void TRI_ReleaseConnectionStatistics (TRI_connection_statistics_t* statistics) { if (statistics == nullptr) { return; } { MUTEX_LOCKER(ConnectionDataLock); if (statistics->_http) { if (statistics->_connStart != 0.0) { if (statistics->_connEnd == 0.0) { TRI_HttpConnectionsStatistics.incCounter(); } else { TRI_HttpConnectionsStatistics.decCounter(); double totalTime = statistics->_connEnd - statistics->_connStart; TRI_ConnectionTimeDistributionStatistics->addFigure(totalTime); } } } } // clear statistics statistics->reset(); // put statistics item back onto the freelist #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = ConnectionFreeList.push(statistics); TRI_ASSERT(ok); #else ConnectionFreeList.push(statistics); #endif }
static void ProcessRequestStatistics (TRI_request_statistics_t* statistics) { { MUTEX_LOCKER(RequestDataLock); TRI_TotalRequestsStatistics.incCounter(); if (statistics->_async) { TRI_AsyncRequestsStatistics.incCounter(); } TRI_MethodRequestsStatistics[(int) statistics->_requestType].incCounter(); // check that the request was completely received and transmitted if (statistics->_readStart != 0.0 && statistics->_writeEnd != 0.0) { double totalTime = statistics->_writeEnd - statistics->_readStart; TRI_TotalTimeDistributionStatistics->addFigure(totalTime); double requestTime = statistics->_requestEnd - statistics->_requestStart; TRI_RequestTimeDistributionStatistics->addFigure(requestTime); double queueTime = 0.0; if (statistics->_queueStart != 0.0 && statistics->_queueEnd != 0.0) { queueTime = statistics->_queueEnd - statistics->_queueStart; TRI_QueueTimeDistributionStatistics->addFigure(queueTime); } double ioTime = totalTime - requestTime - queueTime; if (ioTime >= 0.0) { TRI_IoTimeDistributionStatistics->addFigure(ioTime); } TRI_BytesSentDistributionStatistics->addFigure(statistics->_sentBytes); TRI_BytesReceivedDistributionStatistics->addFigure(statistics->_receivedBytes); } } // clear statistics statistics->reset(); // put statistics item back onto the freelist #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = RequestFreeList.push(statistics); TRI_ASSERT(ok); #else RequestFreeList.push(statistics); #endif }
bool ElmoDriver::iPA(float degree) { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; int temp = (int) (2000.0*degree/180.0*gear_m); //cout << "angle = " << temp << endl; BYTE value[4]; memcpy(value, &temp, sizeof(int)); message.DATA[0] = 'O'; message.DATA[1] = 'V'; message.DATA[2] = 0x13; message.DATA[3] = 0; for(int i=0; i<4; i++) message.DATA[4+i] = value[i]; return CAN_Write_Queue.push(message); }
bool ElmoDriver::TCEqualMinusOne() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; float temp = -0.5; BYTE current[4]; memcpy(current, &temp, sizeof(float)); message.DATA[0] = 'T'; message.DATA[1] = 'C'; message.DATA[2] = 0x0; message.DATA[3] = 128; //for(int i=0; i<3; i++) // message.DATA[4+i] = current[i]; message.DATA[4] = current[0]; message.DATA[5] = current[1]; message.DATA[6] = current[2]; message.DATA[7] = current[3]; return CAN_Write_Queue.push(message); }
bool ElmoDriver::SetIPMode() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'O'; message.DATA[1] = 'F'; message.DATA[2] = 0x07; for(int i=3; i<8; i++) message.DATA[i] = (i == 4 ? 0x07 : 0); /* CAN_Write_Queue.push(message); message.DATA[0] = 'O'; message.DATA[1] = 'V'; message.DATA[2] = 0x17; for(int i=3; i<8; i++) message.DATA[i] = (i == 4 ? 0x0A : 0); */ return CAN_Write_Queue.push(message); }
bool ElmoDriver::GetCurrent() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 4; message.DATA[0] = 'I'; message.DATA[1] = 'Q'; message.DATA[2] = 0; message.DATA[3] = 0; return CAN_Write_Queue.push(message); /* int temppos = 0x00; if (data1[0]=='I' && data1[1]=='Q') { temppos |= (data1[7] << 24); temppos |= (data1[6] << 16); temppos |= (data1[5] << 8); temppos |= (data1[4]); val= *(float *)&temppos; return 1; } val=temppos; return 0; */ }
bool ElmoDriver::DC(float dcc, bool set) { static TPCANMsg message; message.ID = 6*128+id; if (set == true) { message.LEN = 8; int temp = (int) (dcc*gear_m); BYTE value[4]; memcpy(value, &temp, sizeof(int)); for(int i=0; i<4; i++) message.DATA[4+i] = value[i]; } else { message.LEN = 4; } message.DATA[0] = 'D'; message.DATA[1] = 'C'; message.DATA[2] = 0; message.DATA[3] = 0; return CAN_Write_Queue.push(message); }
/* Push a work, it will run automatically. */ bool push_work(work_t w) { if (w->c && work_queue.push(w)) { cv.notify_one(); return true; } return false; }
bool ElmoDriver::PA(int count) { // float deg = (float) degree; // return PA(deg); static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; int temp = count; //cout << "angle = " << temp << endl; BYTE value[4]; memcpy(value, &temp, sizeof(int)); message.DATA[0] = 'P'; message.DATA[1] = 'A'; message.DATA[2] = 0; message.DATA[3] = 0; for(int i=0; i<4; i++) message.DATA[4+i] = value[i]; return CAN_Write_Queue.push(message); }
bool ElmoDriver::MotorOn() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'M'; message.DATA[1] = 'O'; //for(int i=2; i<8; i++) // message.DATA[i] = (i == 4 ? 1 : 0); message.DATA[2] = 0; message.DATA[3] = 0; message.DATA[4] = 1; message.DATA[5] = 0; message.DATA[6] = 0; message.DATA[7] = 0; return CAN_Write_Queue.push(message); }
bool ElmoDriver::TCEqualZero() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; float temp = 0.0; BYTE current[4]; memcpy(current, &temp, sizeof(float)); message.DATA[0] = 'T'; message.DATA[1] = 'C'; message.DATA[2] = 0x0; message.DATA[3] = 128; for(int i=0; i<3; i++) message.DATA[4+i] = current[i]; return CAN_Write_Queue.push(message); }
void producer(void) { for (int i = 0; i != iterations; ++i) { int value = ++producer_count; while (!queue.push(value)) ; } }
void producer(void) { for(int i=0; i < iterations; ++i) { //原子计数---多线程不存在计数不上的情况 int value = ++p_count; cout<<"+"<<endl; //观察生产类型: 纯生产还是同时有消费者的情况 while(!queue.push(value)); } }
bool FT_Sensor::RequestData() { static TPCANMsg message; message.ID = id; message.LEN = 1; message.DATA[0] = 0x02; if (!handle) return CAN_ERRMASK_ILLHANDLE; return CAN_Write_Queue.push(message); }
bool ElmoDriver::GotoOpMode() { static TPCANMsg message; message.ID = 0; message.LEN = 2; message.DATA[0] = 1; message.DATA[1] = 0; return CAN_Write_Queue.push(message); }
bool ElmoDriver::ResetComm() { static TPCANMsg message; message.ID = 0; message.LEN = 2; message.DATA[0] = 130; message.DATA[1] = id; return CAN_Write_Queue.push(message); }
void allocate(void) { for (long i = 0; i != operations_per_thread; ++i) { for (;;) { dummy * node = fl.template construct<true, bounded>(); if (node) { bool success = working_set.insert(node); assert(success); allocated_nodes.push(node); break; } } } }
void TRI_ReleaseRequestStatistics (TRI_request_statistics_t* statistics) { if (statistics == nullptr) { return; } if (! statistics->_ignore) { #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = RequestFinishedList.push(statistics); TRI_ASSERT(ok); #else RequestFinishedList.push(statistics); #endif } else { statistics->reset(); #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = RequestFreeList.push(statistics); TRI_ASSERT(ok); #else RequestFreeList.push(statistics); #endif } }
bool ElmoDriver::UMEqualFive() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'U'; message.DATA[1] = 'M'; for(int i=2; i<8; i++) message.DATA[i] = (i == 4 ? 5 : 0); return CAN_Write_Queue.push(message); }
bool ElmoDriver::BG() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'B'; message.DATA[1] = 'G'; for(int i=2; i<4; i++) message.DATA[i] = (i==4 ? 1 : 0); return CAN_Write_Queue.push(message); }
bool ElmoDriver::CW() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'C'; message.DATA[1] = 'W'; for(int i=2; i<8; i++) message.DATA[i] = (i == 4 ? 0x1F : 0); return CAN_Write_Queue.push(message); }
//TPCANMsg message; bool AbsoluteEncoder::RequestData() { static TPCANMsg message; message.ID = id; message.LEN = 1; message.DATA[0] = 2; // for (int i=0; i<8; i++) // message.DATA[i] = (i==0 ? 0x02 : 0); if (!handle) return CAN_ERRMASK_ILLHANDLE; //return CAN_Write(handle, &message); return CAN_Write_Queue.push(message); }
bool ElmoDriver::MotorOff() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'M'; message.DATA[1] = 'O'; for(int i=2; i<8; i++) message.DATA[i] = 0; return CAN_Write_Queue.push(message); }
bool ElmoDriver::ResetNode() { static TPCANMsg message; message.ID = 0; message.LEN = 2; message.DATA[0] = 129; message.DATA[1] = id; cout << "in reset nod id = " << id << endl; return CAN_Write_Queue.push(message); }
bool ElmoDriver::ProfilePositionMode() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; message.DATA[0] = 'O'; message.DATA[1] = 'F'; message.DATA[2] = 0x07; for(int i=3; i<8; i++) message.DATA[i] = (i == 4 ? 1 : 0); return CAN_Write_Queue.push(message); }
bool ElmoDriver::PA() { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; int temp = 2000; BYTE value[4]; memcpy(value, &temp, sizeof(int)); message.DATA[0] = 'P'; message.DATA[1] = 'A'; message.DATA[2] = 0; message.DATA[3] = 0; for(int i=0; i<4; i++) message.DATA[4+i] = value[i]; return CAN_Write_Queue.push(message); }
bool ElmoDriver::PR(float degree) { static TPCANMsg message; message.ID = 6*128+id; message.LEN = 8; int temp = (int) (2000.0*degree/180.0*gear_m); BYTE value[4]; memcpy(value, &temp, sizeof(int)); message.DATA[0] = 'P'; message.DATA[1] = 'R'; message.DATA[2] = 0; message.DATA[3] = 0; for(int i=0; i<4; i++) message.DATA[4+i] = value[i]; return CAN_Write_Queue.push(message); }
void return_memory( void* c ) { while ( !stack_.push(c) ); }
void TRI_InitializeStatistics () { TRI_ServerStatistics._startTime = TRI_microtime(); // ............................................................................. // sets up the statistics // ............................................................................. TRI_ConnectionTimeDistributionVectorStatistics << (0.1) << (1.0) << (60.0); TRI_BytesSentDistributionVectorStatistics << (250) << (1000) << (2 * 1000) << (5 * 1000) << (10 * 1000); TRI_BytesReceivedDistributionVectorStatistics << (250) << (1000) << (2 * 1000) << (5 * 1000) << (10 * 1000); TRI_RequestTimeDistributionVectorStatistics << (0.01) << (0.05) << (0.1) << (0.2) << (0.5) << (1.0); TRI_ConnectionTimeDistributionStatistics = new StatisticsDistribution(TRI_ConnectionTimeDistributionVectorStatistics); TRI_TotalTimeDistributionStatistics = new StatisticsDistribution(TRI_RequestTimeDistributionVectorStatistics); TRI_RequestTimeDistributionStatistics = new StatisticsDistribution(TRI_RequestTimeDistributionVectorStatistics); TRI_QueueTimeDistributionStatistics = new StatisticsDistribution(TRI_RequestTimeDistributionVectorStatistics); TRI_IoTimeDistributionStatistics = new StatisticsDistribution(TRI_RequestTimeDistributionVectorStatistics); TRI_BytesSentDistributionStatistics = new StatisticsDistribution(TRI_BytesSentDistributionVectorStatistics); TRI_BytesReceivedDistributionStatistics = new StatisticsDistribution(TRI_BytesReceivedDistributionVectorStatistics); // initialize counters for all HTTP request types TRI_MethodRequestsStatistics.clear(); for (int i = 0; i < ((int) triagens::rest::HttpRequest::HTTP_REQUEST_ILLEGAL) + 1; ++i) { StatisticsCounter c; TRI_MethodRequestsStatistics.emplace_back(c); } // ............................................................................. // generate the request statistics queue // ............................................................................. for (size_t i = 0; i < QUEUE_SIZE; ++i) { auto entry = new TRI_request_statistics_t; #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = RequestFreeList.push(entry); TRI_ASSERT(ok); #else RequestFreeList.push(entry); #endif } // ............................................................................. // generate the connection statistics queue // ............................................................................. for (size_t i = 0; i < QUEUE_SIZE; ++i) { auto entry = new TRI_connection_statistics_t; #ifdef TRI_ENABLE_MAINTAINER_MODE bool ok = ConnectionFreeList.push(entry); TRI_ASSERT(ok); #else ConnectionFreeList.push(entry); #endif } // ............................................................................. // use a separate thread for statistics // ............................................................................. Shutdown = false; TRI_StartThread(&StatisticsThread, nullptr, "[statistics]", StatisticsQueueWorker, 0); }