void TNonblockingIOThread::setCurrentThreadHighPriority(bool value) { #ifdef HAVE_SCHED_H // Start out with a standard, low-priority setup for the sched params. struct sched_param sp; bzero((void*) &sp, sizeof(sp)); int policy = SCHED_OTHER; // If desired, set up high-priority sched params structure. if (value) { // FIFO scheduler, ranked above default SCHED_OTHER queue policy = SCHED_FIFO; // The priority only compares us to other SCHED_FIFO threads, so we // just pick a random priority halfway between min & max. const int priority = (sched_get_priority_max(policy) + sched_get_priority_min(policy)) / 2; sp.sched_priority = priority; } // Actually set the sched params for the current thread. if (0 == pthread_setschedparam(pthread_self(), policy, &sp)) { GlobalOutput.printf( "TNonblocking: IO Thread #%d using high-priority scheduler!", number_); } else { GlobalOutput.perror("TNonblocking: pthread_setschedparam(): ", THRIFT_GET_SOCKET_ERROR); } #else THRIFT_UNUSED_VARIABLE(value); #endif }
int64_t Util::currentTimeTicks(int64_t ticksPerSec) { int64_t result; struct timeval now; int ret = THRIFT_GETTIMEOFDAY(&now, NULL); assert(ret == 0); THRIFT_UNUSED_VARIABLE(ret); // squelching "unused variable" warning toTicks(result, now, ticksPerSec); return result; }