Restructure and correct sleep utility for testing
This commit is contained in:
@@ -124,6 +124,7 @@ static const bool config_debug =
|
||||
#include "test/math.h"
|
||||
#include "test/mtx.h"
|
||||
#include "test/mq.h"
|
||||
#include "test/sleep.h"
|
||||
#include "test/test.h"
|
||||
#include "test/timer.h"
|
||||
#include "test/thd.h"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
void mq_nanosleep(unsigned ns);
|
||||
#include "test/sleep.h"
|
||||
|
||||
/*
|
||||
* Simple templated message queue implementation that relies on only mutexes for
|
||||
@@ -82,7 +82,7 @@ a_prefix##get(a_mq_type *mq) { \
|
||||
\
|
||||
ns = 1; \
|
||||
while (true) { \
|
||||
mq_nanosleep(ns); \
|
||||
sleep_ns(ns); \
|
||||
msg = a_prefix##tryget(mq); \
|
||||
if (msg != NULL) { \
|
||||
return msg; \
|
||||
|
1
test/include/test/sleep.h
Normal file
1
test/include/test/sleep.h
Normal file
@@ -0,0 +1 @@
|
||||
void sleep_ns(unsigned ns);
|
@@ -5,11 +5,11 @@
|
||||
* time is guaranteed.
|
||||
*/
|
||||
void
|
||||
mq_nanosleep(unsigned ns) {
|
||||
sleep_ns(unsigned ns) {
|
||||
assert(ns <= 1000*1000*1000);
|
||||
|
||||
#ifdef _WIN32
|
||||
Sleep(ns / 1000);
|
||||
Sleep(ns / 1000 / 1000);
|
||||
#else
|
||||
{
|
||||
struct timespec timeout;
|
Reference in New Issue
Block a user