2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2018-11-30 14:38:22 +08:00
|
|
|
|
#include "fiber_cpp_define.hpp"
|
|
|
|
|
|
2022-11-07 18:28:28 +08:00
|
|
|
|
struct ACL_FIBER_LOCK;
|
2018-11-30 14:38:22 +08:00
|
|
|
|
struct ACL_FIBER_RWLOCK;
|
|
|
|
|
|
|
|
|
|
namespace acl {
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD>߳<EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
2022-11-07 18:28:28 +08:00
|
|
|
|
class FIBER_CPP_API fiber_lock
|
2018-11-30 14:38:22 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
2022-11-07 18:28:28 +08:00
|
|
|
|
fiber_lock(void);
|
|
|
|
|
~fiber_lock(void);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
bool lock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>Եȴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>ռ<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
bool trylock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֪ͨ<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ֪ͨ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ڲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
bool unlock(void);
|
|
|
|
|
|
|
|
|
|
private:
|
2022-11-07 18:28:28 +08:00
|
|
|
|
ACL_FIBER_LOCK* lock_;
|
2020-06-24 16:46:05 +08:00
|
|
|
|
|
2022-11-07 18:28:28 +08:00
|
|
|
|
fiber_lock(const fiber_lock&);
|
|
|
|
|
void operator=(const fiber_lock&);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬһ<EFBFBD>߳<EFBFBD><EFBFBD>ڵ<EFBFBD>Э<EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD>д<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
2020-06-24 16:46:05 +08:00
|
|
|
|
class FIBER_CPP_API fiber_rwlock
|
2018-11-30 14:38:22 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
fiber_rwlock(void);
|
|
|
|
|
~fiber_rwlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void rlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ԼӶ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>ռ<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
bool tryrlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void runlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void wlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>д<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD>ռ<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
bool trywlock(void);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>
|
2018-11-30 14:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
void wunlock(void);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ACL_FIBER_RWLOCK* rwlk_;
|
2020-06-24 16:46:05 +08:00
|
|
|
|
|
|
|
|
|
fiber_rwlock(const fiber_rwlock&);
|
|
|
|
|
void operator=(const fiber_rwlock&);
|
2018-11-30 14:38:22 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|