35
35
#ifndef _MS_WINDOWS
36
36
37
37
#include < signal.h>
38
- #include < mutex>
39
- #include < condition_variable>
40
38
#include " pthread.h"
41
39
42
40
#if defined(__APPLE__)
43
41
#include " compat/apple_compat.h"
44
42
#include < dispatch/dispatch.h>
43
+ #include < boost/thread/mutex.hpp>
44
+ #include < boost/thread/condition_variable.hpp>
45
45
#else
46
46
#include " compat/linux_compat.h"
47
+ #include < mutex>
48
+ #include < condition_variable>
47
49
#endif
48
50
49
51
#include " pplx/pplxinterface.h"
50
52
51
53
52
54
namespace pplx
53
55
{
56
+ #if defined(__APPLE__)
57
+ namespace cpprest_synchronization = ::boost;
58
+ #else
59
+ namespace cpprest_synchronization = ::std;
60
+ #endif
54
61
namespace details
55
62
{
56
63
namespace platform
@@ -80,8 +87,8 @@ namespace platform
80
87
class event_impl
81
88
{
82
89
private:
83
- std ::mutex _lock;
84
- std ::condition_variable _condition;
90
+ cpprest_synchronization ::mutex _lock;
91
+ cpprest_synchronization ::condition_variable _condition;
85
92
bool _signaled;
86
93
public:
87
94
@@ -94,28 +101,28 @@ namespace platform
94
101
95
102
void set ()
96
103
{
97
- std ::lock_guard<std ::mutex> lock (_lock);
104
+ cpprest_synchronization ::lock_guard<cpprest_synchronization ::mutex> lock (_lock);
98
105
_signaled = true ;
99
106
_condition.notify_all ();
100
107
}
101
108
102
109
void reset ()
103
110
{
104
- std ::lock_guard<std ::mutex> lock (_lock);
111
+ cpprest_synchronization ::lock_guard<cpprest_synchronization ::mutex> lock (_lock);
105
112
_signaled = false ;
106
113
}
107
114
108
115
unsigned int wait (unsigned int timeout)
109
116
{
110
- std ::unique_lock<std ::mutex> lock (_lock);
117
+ cpprest_synchronization ::unique_lock<cpprest_synchronization ::mutex> lock (_lock);
111
118
if (timeout == event_impl::timeout_infinite)
112
119
{
113
120
_condition.wait (lock, [this ]() -> bool { return _signaled; });
114
121
return 0 ;
115
122
}
116
123
else
117
124
{
118
- std ::chrono::milliseconds period (timeout);
125
+ cpprest_synchronization ::chrono::milliseconds period (timeout);
119
126
auto status = _condition.wait_for (lock, period, [this ]() -> bool { return _signaled; });
120
127
_ASSERTE (status == _signaled);
121
128
// Return 0 if the wait completed as a result of signaling the event. Otherwise, return timeout_infinite
@@ -235,7 +242,7 @@ namespace platform
235
242
}
236
243
237
244
private:
238
- ::std ::mutex _M_cs;
245
+ cpprest_synchronization ::mutex _M_cs;
239
246
long _M_recursionCount;
240
247
volatile long _M_owner;
241
248
};
@@ -257,8 +264,8 @@ namespace platform
257
264
} // namespace details
258
265
259
266
// / <summary>
260
- // / A generic RAII wrapper for locks that implement the critical_section interface
261
- // / std ::lock_guard
267
+ // / A generic RAII wrapper for locks that implements the critical_section interface
268
+ // / cpprest_synchronization ::lock_guard
262
269
// / </summary>
263
270
template <class _Lock >
264
271
class scoped_lock
@@ -286,7 +293,7 @@ namespace extensibility
286
293
{
287
294
typedef ::pplx::details::event_impl event_t ;
288
295
289
- typedef ::std ::mutex critical_section_t ;
296
+ typedef cpprest_synchronization ::mutex critical_section_t ;
290
297
typedef scoped_lock<critical_section_t > scoped_critical_section_t ;
291
298
292
299
typedef ::pplx::details::reader_writer_lock_impl reader_writer_lock_t ;
0 commit comments