2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-13 12:52:11 +00:00

New mutex implementations, more akin to C++0x

[SVN r39784]
This commit is contained in:
Anthony Williams
2007-10-08 15:41:05 +00:00
parent a706d1df00
commit 9d4c55161a
17 changed files with 1524 additions and 386 deletions

View File

@@ -342,6 +342,9 @@ condition_impl::condition_impl()
res = pthread_cond_init(&m_condition, 0);
if (res != 0)
throw thread_resource_error();
res = pthread_mutex_init(&m_mutex, 0);
if (res != 0)
throw thread_resource_error();
}
condition_impl::~condition_impl()
@@ -349,20 +352,30 @@ condition_impl::~condition_impl()
int res = 0;
res = pthread_cond_destroy(&m_condition);
assert(res == 0);
res = pthread_mutex_destroy(&m_mutex);
assert(res == 0);
}
void condition_impl::notify_one()
{
int res = 0;
res = pthread_mutex_lock(&m_mutex);
assert(res == 0);
res = pthread_cond_signal(&m_condition);
assert(res == 0);
res = pthread_mutex_unlock(&m_mutex);
assert(res == 0);
}
void condition_impl::notify_all()
{
int res = 0;
res = pthread_mutex_lock(&m_mutex);
assert(res == 0);
res = pthread_cond_broadcast(&m_condition);
assert(res == 0);
res = pthread_mutex_unlock(&m_mutex);
assert(res == 0);
}
void condition_impl::do_wait(pthread_mutex_t* pmutex)