aboutsummaryrefslogtreecommitdiff
path: root/src/core/platform.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/platform.h')
-rw-r--r--src/core/platform.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/core/platform.h b/src/core/platform.h
index 35d42339..5739811f 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
@@ -88,9 +88,11 @@ extern void *nni_zalloc(size_t);
// Most implementations can just call free() here.
extern void nni_free(void *, size_t);
-typedef struct nni_plat_mtx nni_plat_mtx;
-typedef struct nni_plat_cv nni_plat_cv;
-typedef struct nni_plat_thr nni_plat_thr;
+typedef struct nni_plat_mtx nni_plat_mtx;
+typedef struct nni_plat_rwlock nni_plat_rwlock;
+typedef struct nni_plat_cv nni_plat_cv;
+typedef struct nni_plat_thr nni_plat_thr;
+typedef struct nni_rwlock nni_rwlock;
//
// Threading & Synchronization Support
@@ -112,6 +114,15 @@ extern void nni_plat_mtx_lock(nni_plat_mtx *);
// thread that owned the mutex.
extern void nni_plat_mtx_unlock(nni_plat_mtx *);
+// read/write locks - these work like mutexes except that multiple readers
+// can acquire the lock. These are not safe for recursive use, and it is
+// unspecified whether any measures are provided to prevent starvation.
+extern void nni_rwlock_init(nni_rwlock *);
+extern void nni_rwlock_fini(nni_rwlock *);
+extern void nni_rwlock_rdlock(nni_rwlock *);
+extern void nni_rwlock_wrlock(nni_rwlock *);
+extern void nni_rwlock_unlock(nni_rwlock *);
+
// nni_plat_cv_init initializes a condition variable. We require a mutex be
// supplied with it, and that mutex must always be held when performing any
// operations on the condition variable (other than fini.) As with mutexes, an
@@ -161,6 +172,7 @@ extern bool nni_plat_thr_is_self(nni_plat_thr *);
// should be a short ASCII string. It may or may not be supported --
// this is intended to facilitate debugging.
extern void nni_plat_thr_set_name(nni_plat_thr *, const char *);
+
//
// Atomics support. This will evolve over time.
//