2019-07-27 22:44:32 +08:00
|
|
|
|
#pragma once
|
2018-12-12 11:16:12 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
|
|
|
|
#include "../stdlib/atomic.hpp"
|
2019-05-09 13:57:51 +08:00
|
|
|
|
#include "../stdlib/noncopyable.hpp"
|
2018-12-12 11:16:12 +08:00
|
|
|
|
|
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
2019-05-09 13:57:51 +08:00
|
|
|
|
class ACL_CPP_API event_mutex : public noncopyable
|
2018-12-12 11:16:12 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
event_mutex(bool recursive = true);
|
|
|
|
|
~event_mutex(void);
|
|
|
|
|
|
|
|
|
|
bool lock(void);
|
|
|
|
|
bool unlock(void);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool recursive_;
|
|
|
|
|
unsigned int nested_;
|
|
|
|
|
#if defined(_WIN32) || defined(_WIN64)
|
|
|
|
|
SOCKET in_;
|
|
|
|
|
SOCKET out_;
|
|
|
|
|
#else
|
|
|
|
|
int in_;
|
|
|
|
|
int out_;
|
|
|
|
|
#endif
|
|
|
|
|
atomic_long count_;
|
|
|
|
|
unsigned long tid_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|