From 616b7afb724a32df41eebfaf95402d008c60b411 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 8 Sep 2010 19:13:49 -0700 Subject: Tidy up the sync dir, remove dead or mis-designed code in favour of OS primitives, switch rust_kernel to use a lock/signal pair and wait rather than spin. --- src/rt/sync/lock_and_signal.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/rt/sync/lock_and_signal.h (limited to 'src/rt/sync/lock_and_signal.h') diff --git a/src/rt/sync/lock_and_signal.h b/src/rt/sync/lock_and_signal.h new file mode 100644 index 00000000..5a852d9d --- /dev/null +++ b/src/rt/sync/lock_and_signal.h @@ -0,0 +1,23 @@ +#ifndef LOCK_AND_SIGNAL_H +#define LOCK_AND_SIGNAL_H + +class lock_and_signal { +#if defined(__WIN32__) + HANDLE _event; + CRITICAL_SECTION _cs; +#else + pthread_cond_t _cond; + pthread_mutex_t _mutex; +#endif +public: + lock_and_signal(); + virtual ~lock_and_signal(); + + void lock(); + void unlock(); + void wait(); + void timed_wait(size_t timeout_in_ns); + void signal(); +}; + +#endif /* LOCK_AND_SIGNAL_H */ -- cgit v1.2.3