diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-01 13:32:32 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-01 13:32:32 -0800 |
| commit | f0bf079dca01acb6dfc07af03226a0cae7a90010 (patch) | |
| tree | 6cddec8c026c31d88b5659a8ba89801c421158bc /src/core/thread.h | |
| parent | 4c7e52ff0a5ad05164c05a4fbf99de1cdb4090bc (diff) | |
| download | nng-f0bf079dca01acb6dfc07af03226a0cae7a90010.tar.gz nng-f0bf079dca01acb6dfc07af03226a0cae7a90010.tar.bz2 nng-f0bf079dca01acb6dfc07af03226a0cae7a90010.zip | |
New thread infrastructure -- not used anywhere yet, but tested.
Diffstat (limited to 'src/core/thread.h')
| -rw-r--r-- | src/core/thread.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/core/thread.h b/src/core/thread.h new file mode 100644 index 00000000..062941a1 --- /dev/null +++ b/src/core/thread.h @@ -0,0 +1,52 @@ +// +// Copyright 2016 Garrett D'Amore <garrett@damore.org> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#ifndef CORE_THREAD_H +#define CORE_THREAD_H + +#include "core/nng_impl.h" + +typedef struct { + nni_plat_mtx mtx; +} nni_mtx; + +typedef struct { + nni_plat_cv cv; +} nni_cv; + +typedef void (*nni_thr_func)(void *); + +typedef struct { + nni_plat_thr thr; + nni_plat_mtx mtx; + nni_plat_cv cv; + nni_thr_func fn; + void *arg; + int start; + int stop; + int done; +} nni_thr; + +extern int nni_mtx_init(nni_mtx *mtx); +extern void nni_mtx_fini(nni_mtx *mtx); +extern void nni_mtx_lock(nni_mtx *mtx); +extern void nni_mtx_unlock(nni_mtx *mtx); +extern int nni_mtx_trylock(nni_mtx *mtx); + +extern int nni_cv_init(nni_cv *cv, nni_mtx *); +extern void nni_cv_fini(nni_cv *cv); +extern void nni_cv_wake(nni_cv *cv); +extern void nni_cv_wait(nni_cv *cv); +extern int nni_cv_until(nni_cv *cv, nni_time when); + +extern int nni_thr_init(nni_thr *thr, nni_thr_func fn, void *arg); +extern void nni_thr_fini(nni_thr *thr); +extern void nni_thr_run(nni_thr *thr); + +#endif CORE_THREAD_H
\ No newline at end of file |
