From d1a9c84a6b375cb25a8b7475957130e364b41753 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 2 Jul 2018 22:36:08 -0700 Subject: fixes #572 Several locking errors found fixes #573 atomic flags could help This introduces a new atomic flag, and reduces some of the global locking. The lock refactoring work is not yet complete, but this is a positive step forward, and should help with certain things. While here we also fixed a compile warning due to incorrect types. --- src/core/platform.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/core/platform.h') diff --git a/src/core/platform.h b/src/core/platform.h index b709e3ba..607c3827 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -146,6 +146,18 @@ extern void nni_plat_thr_fini(nni_plat_thr *); // prevention in callbacks, for example.) extern bool nni_plat_thr_is_self(nni_plat_thr *); +// +// Atomics support. This will evolve over time. +// + +// nni_atomic_flag supports only test-and-set and reset operations. +// This can be implemented without locks on any reasonable system, and +// it corresponds to C11 atomic flag. +typedef struct nni_atomic_flag nni_atomic_flag; + +extern bool nni_atomic_flag_test_and_set(nni_atomic_flag *); +extern void nni_atomic_flag_reset(nni_atomic_flag *); + // // Clock Support // -- cgit v1.2.3-70-g09d2