diff options
| author | Graydon Hoare <[email protected]> | 2010-09-08 19:13:49 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-09-08 19:13:49 -0700 |
| commit | 616b7afb724a32df41eebfaf95402d008c60b411 (patch) | |
| tree | 03e13578e8b43b9001cef983d1117800a6f93e65 /src/rt/sync/lock_and_signal.h | |
| parent | XFAIL many.rs since it crashes on win32, and add a time-slice sleep to the ke... (diff) | |
| download | rust-616b7afb724a32df41eebfaf95402d008c60b411.tar.xz rust-616b7afb724a32df41eebfaf95402d008c60b411.zip | |
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.
Diffstat (limited to 'src/rt/sync/lock_and_signal.h')
| -rw-r--r-- | src/rt/sync/lock_and_signal.h | 23 |
1 files changed, 23 insertions, 0 deletions
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 */ |