Commit de2dba8e authored by Dmitriy Morozov's avatar Dmitriy Morozov

Update DIY: don't use TinyThread++ under C++11

parent b6e3eb29
......@@ -3,6 +3,14 @@
namespace diy
{
// TODO: when not running under C++11, i.e., when lock_guard is TinyThread's
// lock_guard, and not C++11's unique_lock, this implementation might
// be buggy since the copy constructor is invoked when
// critical_resource::access() returns an instance of this class. Once
// the temporary is destroyed the mutex is unlocked. I'm not 100%
// certain of this because I'd expect a deadlock on copy constructor,
// but it's clearly not happening -- so I may be missing something.
// (This issue will take care of itself in DIY3 once we switch to C++11 completely.)
template<class T, class Mutex>
class resource_accessor
{
......
......@@ -4,9 +4,30 @@
#ifdef DIY_NO_THREADS
#include "no-thread.hpp"
#else
#include "thread/tinythread.h"
#include "thread/fast_mutex.h"
#if __cplusplus > 199711L // C++11
#include <thread>
#include <mutex>
namespace diy
{
using std::thread;
using std::mutex;
using std::recursive_mutex;
namespace this_thread = std::this_thread;
// TODO: replace with our own implementation using std::atomic_flag
using fast_mutex = tthread::fast_mutex;
template<class Mutex>
using lock_guard = std::unique_lock<Mutex>;
}
#else
#include "thread/tinythread.h"
namespace diy
{
using tthread::thread;
......@@ -17,6 +38,7 @@ namespace diy
namespace this_thread = tthread::this_thread;
}
#endif
#endif
#include "critical-resource.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment