aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-11 10:10:39 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-11 10:10:39 -0700
commit183bd7e02c81bc09c17c6f4c0d3883d4d45221fc (patch)
tree4954056e769d8761eff75143b0cfc44050be0198 /src/core
parent910564d2f67eb81a07c0c6b2af0fc0878137308b (diff)
downloadnng-183bd7e02c81bc09c17c6f4c0d3883d4d45221fc.tar.gz
nng-183bd7e02c81bc09c17c6f4c0d3883d4d45221fc.tar.bz2
nng-183bd7e02c81bc09c17c6f4c0d3883d4d45221fc.zip
Eliminate the separate wrapping structure for platform mtx and cv.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/defs.h8
-rw-r--r--src/core/thread.c20
-rw-r--r--src/core/thread.h8
3 files changed, 14 insertions, 22 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index 98ff5b97..69fe4843 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -39,10 +39,10 @@ typedef struct nni_proto_sock_ops nni_proto_sock_ops;
typedef struct nni_proto_pipe_ops nni_proto_pipe_ops;
typedef struct nni_proto nni_proto;
-typedef struct nni_mtx nni_mtx;
-typedef struct nni_cv nni_cv;
-typedef struct nni_idhash nni_idhash;
-typedef struct nni_thr nni_thr;
+typedef struct nni_plat_mtx nni_mtx;
+typedef struct nni_plat_cv nni_cv;
+typedef struct nni_idhash nni_idhash;
+typedef struct nni_thr nni_thr;
typedef void (*nni_thr_func)(void *);
typedef int nni_signal; // Wakeup channel.
diff --git a/src/core/thread.c b/src/core/thread.c
index e603e32b..3cfdd83f 100644
--- a/src/core/thread.c
+++ b/src/core/thread.c
@@ -12,43 +12,43 @@
int
nni_mtx_init(nni_mtx *mtx)
{
- return (nni_plat_mtx_init(&mtx->mtx));
+ return (nni_plat_mtx_init(mtx));
}
void
nni_mtx_fini(nni_mtx *mtx)
{
- nni_plat_mtx_fini(&mtx->mtx);
+ nni_plat_mtx_fini(mtx);
}
void
nni_mtx_lock(nni_mtx *mtx)
{
- nni_plat_mtx_lock(&mtx->mtx);
+ nni_plat_mtx_lock(mtx);
}
void
nni_mtx_unlock(nni_mtx *mtx)
{
- nni_plat_mtx_unlock(&mtx->mtx);
+ nni_plat_mtx_unlock(mtx);
}
int
nni_cv_init(nni_cv *cv, nni_mtx *mtx)
{
- return (nni_plat_cv_init(&cv->cv, &mtx->mtx));
+ return (nni_plat_cv_init(cv, mtx));
}
void
nni_cv_fini(nni_cv *cv)
{
- nni_plat_cv_fini(&cv->cv);
+ nni_plat_cv_fini(cv);
}
void
nni_cv_wait(nni_cv *cv)
{
- nni_plat_cv_wait(&cv->cv);
+ nni_plat_cv_wait(cv);
}
int
@@ -57,20 +57,20 @@ nni_cv_until(nni_cv *cv, nni_time until)
// Some special cases for times. Catching these here means that
// platforms can assume a valid time is presented to them.
if (until == NNI_TIME_NEVER) {
- nni_plat_cv_wait(&cv->cv);
+ nni_plat_cv_wait(cv);
return (0);
}
if (until == NNI_TIME_ZERO) {
return (NNG_EAGAIN);
}
- return (nni_plat_cv_until(&cv->cv, until));
+ return (nni_plat_cv_until(cv, until));
}
void
nni_cv_wake(nni_cv *cv)
{
- nni_plat_cv_wake(&cv->cv);
+ nni_plat_cv_wake(cv);
}
static void
diff --git a/src/core/thread.h b/src/core/thread.h
index ebd8db83..b528af2c 100644
--- a/src/core/thread.h
+++ b/src/core/thread.h
@@ -13,14 +13,6 @@
#include "core/defs.h"
#include "core/platform.h"
-struct nni_mtx {
- nni_plat_mtx mtx;
-};
-
-struct nni_cv {
- nni_plat_cv cv;
-};
-
struct nni_thr {
nni_plat_thr thr;
nni_plat_mtx mtx;