Commit 8b263d58 authored by sigiesec's avatar sigiesec

Problem: test_timers.cpp sleep_ duplicates msleep from testutil

Solution: replace sleep_ my msleep
parent 8f3113b2
...@@ -29,17 +29,6 @@ ...@@ -29,17 +29,6 @@
#include "testutil.hpp" #include "testutil.hpp"
void sleep_ (long timeout_)
{
#if defined ZMQ_HAVE_WINDOWS
Sleep (timeout_ > 0 ? timeout_ : INFINITE);
#elif defined ZMQ_HAVE_ANDROID
usleep (timeout_ * 1000);
#else
usleep (timeout_ * 1000);
#endif
}
void handler (int timer_id, void* arg) void handler (int timer_id, void* arg)
{ {
(void) timer_id; // Stop 'unused' compiler warnings (void) timer_id; // Stop 'unused' compiler warnings
...@@ -52,7 +41,7 @@ int sleep_and_execute(void *timers_) ...@@ -52,7 +41,7 @@ int sleep_and_execute(void *timers_)
// Sleep methods are inaccurate, so we sleep in a loop until time arrived // Sleep methods are inaccurate, so we sleep in a loop until time arrived
while (timeout > 0) { while (timeout > 0) {
sleep_ (timeout); msleep (timeout);
timeout = zmq_timers_timeout(timers_); timeout = zmq_timers_timeout(timers_);
} }
...@@ -77,7 +66,7 @@ int main (void) ...@@ -77,7 +66,7 @@ int main (void)
assert (!timer_invoked); assert (!timer_invoked);
// Wait half the time and check again // Wait half the time and check again
sleep_ (zmq_timers_timeout (timers) / 2); msleep (zmq_timers_timeout (timers) / 2);
rc = zmq_timers_execute (timers); rc = zmq_timers_execute (timers);
assert (rc == 0); assert (rc == 0);
assert (!timer_invoked); assert (!timer_invoked);
...@@ -90,14 +79,14 @@ int main (void) ...@@ -90,14 +79,14 @@ int main (void)
// Wait half the time and check again // Wait half the time and check again
long timeout = zmq_timers_timeout (timers); long timeout = zmq_timers_timeout (timers);
sleep_ (timeout / 2); msleep (timeout / 2);
rc = zmq_timers_execute (timers); rc = zmq_timers_execute (timers);
assert (rc == 0); assert (rc == 0);
assert (!timer_invoked); assert (!timer_invoked);
// Reset timer and wait half of the time left // Reset timer and wait half of the time left
rc = zmq_timers_reset (timers, timer_id); rc = zmq_timers_reset (timers, timer_id);
sleep_ (timeout / 2); msleep (timeout / 2);
rc = zmq_timers_execute (timers); rc = zmq_timers_execute (timers);
assert (rc == 0); assert (rc == 0);
assert (!timer_invoked); assert (!timer_invoked);
...@@ -118,7 +107,7 @@ int main (void) ...@@ -118,7 +107,7 @@ int main (void)
// cancel timer // cancel timer
timeout = zmq_timers_timeout (timers); timeout = zmq_timers_timeout (timers);
zmq_timers_cancel (timers, timer_id); zmq_timers_cancel (timers, timer_id);
sleep_ (timeout * 2); msleep (timeout * 2);
rc = zmq_timers_execute (timers); rc = zmq_timers_execute (timers);
assert (rc == 0); assert (rc == 0);
assert (!timer_invoked); assert (!timer_invoked);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment