2016-07-29 16:43:46 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-11-23 12:59:24 +08:00
|
|
|
struct ACL_FIBER_EVENT;
|
2016-07-29 16:43:46 +08:00
|
|
|
struct ACL_FIBER_RWLOCK;
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
2017-09-29 17:35:17 +08:00
|
|
|
class thread_mutex;
|
|
|
|
|
2016-07-29 16:43:46 +08:00
|
|
|
class fiber_mutex
|
|
|
|
{
|
|
|
|
public:
|
2017-11-23 12:59:24 +08:00
|
|
|
fiber_mutex(void);
|
2016-07-29 16:43:46 +08:00
|
|
|
~fiber_mutex(void);
|
|
|
|
|
2017-09-29 17:35:17 +08:00
|
|
|
bool lock(void);
|
|
|
|
bool unlock(void);
|
2016-07-29 16:43:46 +08:00
|
|
|
|
|
|
|
private:
|
2017-10-11 19:29:11 +08:00
|
|
|
unsigned long tid_;
|
2017-11-23 12:59:24 +08:00
|
|
|
ACL_FIBER_EVENT* lock_;
|
2016-07-29 16:43:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class fiber_rwlock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
fiber_rwlock(void);
|
|
|
|
~fiber_rwlock(void);
|
|
|
|
|
|
|
|
void rlock(void);
|
|
|
|
bool tryrlock(void);
|
|
|
|
void runlock(void);
|
|
|
|
|
|
|
|
void wlock(void);
|
|
|
|
bool trywlock(void);
|
|
|
|
void wunlock(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ACL_FIBER_RWLOCK* rwlk_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace acl
|