Skip to content

Commit 43f6f34

Browse files
authored
Use C++11 synchronization classes under macOS too (#1342)
There doesn't seem to be any reason to prefer using Boost libraries to standard C++ classes under macOS, so use the latter ones unconditionally on this platform too, just as it was already done for the other Unix systems. This notably avoids dependencies on the compiled Boost libraries, which don't have to be compiled before building C++ REST SDK any more.
1 parent 23e4c61 commit 43f6f34

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

Release/include/pplx/pplxlinux.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,14 @@
2323
#include "pthread.h"
2424
#include <signal.h>
2525

26-
#if defined(__APPLE__)
27-
#include <boost/thread/condition_variable.hpp>
28-
#include <boost/thread/mutex.hpp>
29-
#include <dispatch/dispatch.h>
30-
#else
3126
#include <atomic>
3227
#include <condition_variable>
3328
#include <mutex>
34-
#endif
3529

3630
#include "pplx/pplxinterface.h"
3731

3832
namespace pplx
3933
{
40-
#if defined(__APPLE__)
41-
namespace cpprest_synchronization = ::boost;
42-
#else
43-
namespace cpprest_synchronization = ::std;
44-
#endif
4534
namespace details
4635
{
4736
namespace platform
@@ -68,8 +57,8 @@ __declspec(noinline) inline static size_t CaptureCallstack(void**, size_t, size_
6857
class event_impl
6958
{
7059
private:
71-
cpprest_synchronization::mutex _lock;
72-
cpprest_synchronization::condition_variable _condition;
60+
std::mutex _lock;
61+
std::condition_variable _condition;
7362
bool _signaled;
7463

7564
public:
@@ -79,28 +68,28 @@ class event_impl
7968

8069
void set()
8170
{
82-
cpprest_synchronization::lock_guard<cpprest_synchronization::mutex> lock(_lock);
71+
std::lock_guard<std::mutex> lock(_lock);
8372
_signaled = true;
8473
_condition.notify_all();
8574
}
8675

8776
void reset()
8877
{
89-
cpprest_synchronization::lock_guard<cpprest_synchronization::mutex> lock(_lock);
78+
std::lock_guard<std::mutex> lock(_lock);
9079
_signaled = false;
9180
}
9281

9382
unsigned int wait(unsigned int timeout)
9483
{
95-
cpprest_synchronization::unique_lock<cpprest_synchronization::mutex> lock(_lock);
84+
std::unique_lock<std::mutex> lock(_lock);
9685
if (timeout == event_impl::timeout_infinite)
9786
{
9887
_condition.wait(lock, [this]() -> bool { return _signaled; });
9988
return 0;
10089
}
10190
else
10291
{
103-
cpprest_synchronization::chrono::milliseconds period(timeout);
92+
std::chrono::milliseconds period(timeout);
10493
auto status = _condition.wait_for(lock, period, [this]() -> bool { return _signaled; });
10594
_ASSERTE(status == _signaled);
10695
// Return 0 if the wait completed as a result of signaling the event. Otherwise, return timeout_infinite
@@ -195,7 +184,7 @@ class recursive_lock_impl
195184
}
196185

197186
private:
198-
cpprest_synchronization::mutex _M_cs;
187+
std::mutex _M_cs;
199188
std::atomic<long> _M_owner;
200189
long _M_recursionCount;
201190
};
@@ -219,7 +208,7 @@ class linux_scheduler : public pplx::scheduler_interface
219208

220209
/// <summary>
221210
/// A generic RAII wrapper for locks that implements the critical_section interface
222-
/// cpprest_synchronization::lock_guard
211+
/// std::lock_guard
223212
/// </summary>
224213
template<class _Lock>
225214
class scoped_lock
@@ -244,7 +233,7 @@ namespace extensibility
244233
{
245234
typedef ::pplx::details::event_impl event_t;
246235

247-
typedef cpprest_synchronization::mutex critical_section_t;
236+
typedef std::mutex critical_section_t;
248237
typedef scoped_lock<critical_section_t> scoped_critical_section_t;
249238

250239
typedef ::pplx::details::reader_writer_lock_impl reader_writer_lock_t;

0 commit comments

Comments
 (0)