diff options
author | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-02-17 14:29:14 +0700 |
---|---|---|
committer | Bruce Mitchener <bruce.mitchener@gmail.com> | 2013-03-25 00:34:11 +0700 |
commit | 59ff5a6a3c3e1f5255c5cf29f98df633a77b89b3 (patch) | |
tree | c7660fa62600366e3479dbf6b2fd1d25709af1b5 /system/lib/libcxx/condition_variable.cpp | |
parent | 80fd6f0bce2b95db6ec539c9275ce24585550e7c (diff) |
Update to current libcxx.
This doesn't work yet as it needs to be customized for use with
emscripten still.
Diffstat (limited to 'system/lib/libcxx/condition_variable.cpp')
-rw-r--r-- | system/lib/libcxx/condition_variable.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/system/lib/libcxx/condition_variable.cpp b/system/lib/libcxx/condition_variable.cpp index ca1dca32..de0f6f47 100644 --- a/system/lib/libcxx/condition_variable.cpp +++ b/system/lib/libcxx/condition_variable.cpp @@ -16,18 +16,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD condition_variable::~condition_variable() { - int e = pthread_cond_destroy(&__cv_); -// assert(e == 0); + pthread_cond_destroy(&__cv_); } void -condition_variable::notify_one() +condition_variable::notify_one() _NOEXCEPT { pthread_cond_signal(&__cv_); } void -condition_variable::notify_all() +condition_variable::notify_all() _NOEXCEPT { pthread_cond_broadcast(&__cv_); } @@ -52,10 +51,22 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk, __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked"); nanoseconds d = tp.time_since_epoch(); + if (d > nanoseconds(0x59682F000000E941)) + d = nanoseconds(0x59682F000000E941); timespec ts; seconds s = duration_cast<seconds>(d); - ts.tv_sec = static_cast<decltype(ts.tv_sec)>(s.count()); - ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + typedef decltype(ts.tv_sec) ts_sec; + _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max(); + if (s.count() < ts_sec_max) + { + ts.tv_sec = static_cast<ts_sec>(s.count()); + ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count()); + } + else + { + ts.tv_sec = ts_sec_max; + ts.tv_nsec = giga::num - 1; + } int ec = pthread_cond_timedwait(&__cv_, lk.mutex()->native_handle(), &ts); if (ec != 0 && ec != ETIMEDOUT) __throw_system_error(ec, "condition_variable timed_wait failed"); |