2
0
mirror of https://github.com/boostorg/thread.git synced 2026-02-03 09:42:16 +00:00

Thread: name type for pthread/once epoch so that we can choose better an /atomic/ type for it

[SVN r79984]
This commit is contained in:
Vicente J. Botet Escriba
2012-08-12 18:31:09 +00:00
parent 1ac7e7129d
commit 8334f4e68a
2 changed files with 19 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ namespace boost
{
namespace detail
{
BOOST_THREAD_DECL boost::uintmax_t once_global_epoch=UINTMAX_C(~0);
BOOST_THREAD_DECL thread_detail::uintmax_atomic_t once_global_epoch=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C(~0);
BOOST_THREAD_DECL pthread_mutex_t once_epoch_mutex=PTHREAD_MUTEX_INITIALIZER;
BOOST_THREAD_DECL pthread_cond_t once_epoch_cv = PTHREAD_COND_INITIALIZER;
@@ -55,17 +55,17 @@ namespace boost
#endif
}
boost::uintmax_t& get_once_per_thread_epoch()
thread_detail::uintmax_atomic_t& get_once_per_thread_epoch()
{
BOOST_VERIFY(!pthread_once(&epoch_tss_key_flag,create_epoch_tss_key));
void* data=pthread_getspecific(epoch_tss_key);
if(!data)
{
data=malloc(sizeof(boost::uintmax_t));
data=malloc(sizeof(thread_detail::uintmax_atomic_t));
BOOST_VERIFY(!pthread_setspecific(epoch_tss_key,data));
*static_cast<boost::uintmax_t*>(data)=UINTMAX_C(~0);
*static_cast<thread_detail::uintmax_atomic_t*>(data)=BOOST_THREAD_DETAIL_UINTMAX_ATOMIC_C(~0);
}
return *static_cast<boost::uintmax_t*>(data);
return *static_cast<thread_detail::uintmax_atomic_t*>(data);
}
}