From 99c5d9283622a0b37ee80f83ff4875c059fc5990 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 27 Aug 2009 10:54:28 +0200 Subject: pipes added --- src/app_thread.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/app_thread.cpp') diff --git a/src/app_thread.cpp b/src/app_thread.cpp index 74ba357..db73ec1 100644 --- a/src/app_thread.cpp +++ b/src/app_thread.cpp @@ -77,7 +77,7 @@ bool zmq::app_thread_t::make_current () return true; } -void zmq::app_thread_t::process_commands (bool block_) +void zmq::app_thread_t::process_commands (bool block_, bool throttle_) { ypollset_t::signals_t signals; if (block_) @@ -91,24 +91,26 @@ void zmq::app_thread_t::process_commands (bool block_) // depending on CPU speed: It's ~1ms on 3GHz CPU, ~2ms on 1.5GHz CPU // etc. The optimisation makes sense only on platforms where getting // a timestamp is a very cheap operation (tens of nanoseconds). + if (throttle_) { - // Get timestamp counter. + // Get timestamp counter. #if defined __GNUC__ - uint32_t low; - uint32_t high; - __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); - uint64_t current_time = (uint64_t) high << 32 | low; + uint32_t low; + uint32_t high; + __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high)); + uint64_t current_time = (uint64_t) high << 32 | low; #elif defined _MSC_VER - uint64_t current_time = __rdtsc (); + uint64_t current_time = __rdtsc (); #else #error #endif - // Check whether certain time have elapsed since last command - // processing. - if (current_time - last_processing_time <= max_command_delay) - return; - last_processing_time = current_time; + // Check whether certain time have elapsed since last command + // processing. + if (current_time - last_processing_time <= max_command_delay) + return; + last_processing_time = current_time; + } #endif // Check whether there are any commands pending for this thread. -- cgit v1.2.3