Skip to content

Commit 14fd9bd

Browse files
committed
Merge branch 'iOSMutexFix' of https://git01.codeplex.com/forks/les1966/casablanca into staging
2 parents c3953d7 + 709a378 commit 14fd9bd

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

Release/include/pplx/pplxlinux.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,29 @@
3535
#ifndef _MS_WINDOWS
3636

3737
#include <signal.h>
38-
#include <mutex>
39-
#include <condition_variable>
4038
#include "pthread.h"
4139

4240
#if defined(__APPLE__)
4341
#include "compat/apple_compat.h"
4442
#include <dispatch/dispatch.h>
43+
#include <boost/thread/mutex.hpp>
44+
#include <boost/thread/condition_variable.hpp>
4545
#else
4646
#include "compat/linux_compat.h"
47+
#include <mutex>
48+
#include <condition_variable>
4749
#endif
4850

4951
#include "pplx/pplxinterface.h"
5052

5153

5254
namespace pplx
5355
{
56+
#if defined(__APPLE__)
57+
namespace cpprest_synchronization = ::boost;
58+
#else
59+
namespace cpprest_synchronization = ::std;
60+
#endif
5461
namespace details
5562
{
5663
namespace platform
@@ -80,8 +87,8 @@ namespace platform
8087
class event_impl
8188
{
8289
private:
83-
std::mutex _lock;
84-
std::condition_variable _condition;
90+
cpprest_synchronization::mutex _lock;
91+
cpprest_synchronization::condition_variable _condition;
8592
bool _signaled;
8693
public:
8794

@@ -94,28 +101,28 @@ namespace platform
94101

95102
void set()
96103
{
97-
std::lock_guard<std::mutex> lock(_lock);
104+
cpprest_synchronization::lock_guard<cpprest_synchronization::mutex> lock(_lock);
98105
_signaled = true;
99106
_condition.notify_all();
100107
}
101108

102109
void reset()
103110
{
104-
std::lock_guard<std::mutex> lock(_lock);
111+
cpprest_synchronization::lock_guard<cpprest_synchronization::mutex> lock(_lock);
105112
_signaled = false;
106113
}
107114

108115
unsigned int wait(unsigned int timeout)
109116
{
110-
std::unique_lock<std::mutex> lock(_lock);
117+
cpprest_synchronization::unique_lock<cpprest_synchronization::mutex> lock(_lock);
111118
if (timeout == event_impl::timeout_infinite)
112119
{
113120
_condition.wait(lock, [this]() -> bool { return _signaled; });
114121
return 0;
115122
}
116123
else
117124
{
118-
std::chrono::milliseconds period(timeout);
125+
cpprest_synchronization::chrono::milliseconds period(timeout);
119126
auto status = _condition.wait_for(lock, period, [this]() -> bool { return _signaled; });
120127
_ASSERTE(status == _signaled);
121128
// Return 0 if the wait completed as a result of signaling the event. Otherwise, return timeout_infinite
@@ -235,7 +242,7 @@ namespace platform
235242
}
236243

237244
private:
238-
::std::mutex _M_cs;
245+
cpprest_synchronization::mutex _M_cs;
239246
long _M_recursionCount;
240247
volatile long _M_owner;
241248
};
@@ -257,8 +264,8 @@ namespace platform
257264
} // namespace details
258265

259266
/// <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
262269
/// </summary>
263270
template<class _Lock>
264271
class scoped_lock
@@ -286,7 +293,7 @@ namespace extensibility
286293
{
287294
typedef ::pplx::details::event_impl event_t;
288295

289-
typedef ::std::mutex critical_section_t;
296+
typedef cpprest_synchronization::mutex critical_section_t;
290297
typedef scoped_lock<critical_section_t> scoped_critical_section_t;
291298

292299
typedef ::pplx::details::reader_writer_lock_impl reader_writer_lock_t;

0 commit comments

Comments
 (0)