summaryrefslogtreecommitdiff
path: root/tests/synch.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-10-19 15:16:25 -0700
committerGarrett D'Amore <garrett@damore.org>2017-10-19 17:56:49 -0700
commit4e668fdd5b5da0d46f97d835249dbe5f0ea319a7 (patch)
tree0aaad8a672024b3a510763150b167320be6f1f5b /tests/synch.c
parentd7e39a2423212a31c5ef62dcb0b7a5b4bf9f34df (diff)
downloadnng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.tar.gz
nng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.tar.bz2
nng-4e668fdd5b5da0d46f97d835249dbe5f0ea319a7.zip
fixes #84 Consider using msec for durations
There is now a public nng_duration type. We have also updated the zerotier work to work with the signed int64_t's that the latst ZeroTier dev branch is using.
Diffstat (limited to 'tests/synch.c')
-rw-r--r--tests/synch.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/tests/synch.c b/tests/synch.c
index d861f04d..b1d0d66a 100644
--- a/tests/synch.c
+++ b/tests/synch.c
@@ -14,10 +14,10 @@
// Notify tests for verifying condvars.
struct notifyarg {
- int did;
- int when;
- nni_mtx mx;
- nni_cv cv;
+ int did;
+ nng_duration when;
+ nni_mtx mx;
+ nni_cv cv;
};
#ifdef NNG_PLATFORM_POSIX
@@ -31,7 +31,7 @@ notifyafter(void *arg)
{
struct notifyarg *na = arg;
- nni_usleep(na->when);
+ nni_msleep(na->when);
nni_mtx_lock(&na->mx);
na->did = 1;
nni_cv_wake(&na->cv);
@@ -71,10 +71,10 @@ test_sync(void)
arg.when = 0;
nni_mtx_lock(&arg.mx);
nni_thr_run(&thr);
- nng_usleep(10000);
+ nng_msleep(10);
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
- nng_usleep(10000);
+ nng_msleep(10);
nni_mtx_lock(&arg.mx);
while (!arg.did) {
nni_cv_wait(&arg.cv);
@@ -103,7 +103,7 @@ test_sync(void)
Convey("Notification works", {
arg.did = 0;
- arg.when = 10000;
+ arg.when = 10;
nni_thr_run(&thr);
nni_mtx_lock(&arg.mx);
@@ -117,11 +117,11 @@ test_sync(void)
Convey("Timeout works", {
arg.did = 0;
- arg.when = 200000;
+ arg.when = 200;
nni_thr_run(&thr);
nni_mtx_lock(&arg.mx);
if (!arg.did) {
- nni_cv_until(&arg.cv, nni_clock() + 10000);
+ nni_cv_until(&arg.cv, nni_clock() + 10);
}
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
@@ -139,7 +139,7 @@ test_sync(void)
arg.when = 1;
nni_mtx_lock(&arg.mx);
if (!arg.did) {
- nni_cv_until(&arg.cv, nni_clock() + 10000);
+ nni_cv_until(&arg.cv, nni_clock() + 10);
}
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
@@ -184,10 +184,10 @@ test_sync_fallback(void)
arg.when = 0;
nni_mtx_lock(&arg.mx);
nni_thr_run(&thr);
- nng_usleep(10000);
+ nng_msleep(10);
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
- nng_usleep(10000);
+ nng_msleep(10);
nni_mtx_lock(&arg.mx);
while (!arg.did) {
nni_cv_wait(&arg.cv);
@@ -216,7 +216,7 @@ test_sync_fallback(void)
Convey("Notification works", {
arg.did = 0;
- arg.when = 10000;
+ arg.when = 10;
nni_thr_run(&thr);
nni_mtx_lock(&arg.mx);
@@ -230,11 +230,11 @@ test_sync_fallback(void)
Convey("Timeout works", {
arg.did = 0;
- arg.when = 200000;
+ arg.when = 200;
nni_thr_run(&thr);
nni_mtx_lock(&arg.mx);
if (!arg.did) {
- nni_cv_until(&arg.cv, nni_clock() + 10000);
+ nni_cv_until(&arg.cv, nni_clock() + 10);
}
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
@@ -252,7 +252,7 @@ test_sync_fallback(void)
arg.when = 1;
nni_mtx_lock(&arg.mx);
if (!arg.did) {
- nni_cv_until(&arg.cv, nni_clock() + 10000);
+ nni_cv_until(&arg.cv, nni_clock() + 10);
}
So(arg.did == 0);
nni_mtx_unlock(&arg.mx);
@@ -278,7 +278,7 @@ TestMain("Synchronization", {
So(nni_thr_init(&thr, notifyafter, &arg) == 0);
arg.did = 0;
- arg.when = 10000;
+ arg.when = 10;
nni_thr_run(&thr);
nni_mtx_lock(&arg.mx);