acl/lib_fiber/cpp/include/fiber/fiber_lock.hpp

92 lines
1.4 KiB
C++
Raw Normal View History

#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 {
/**
* <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
/**
* <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);
/**
* <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);
/**
* <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_;
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
};
/**
* <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
*/
class FIBER_CPP_API fiber_rwlock
2018-11-30 14:38:22 +08:00
{
public:
fiber_rwlock(void);
~fiber_rwlock(void);
/**
* <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
2018-11-30 14:38:22 +08:00
*/
void rlock(void);
/**
* <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);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-11-30 14:38:22 +08:00
*/
void runlock(void);
/**
* <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>
2018-11-30 14:38:22 +08:00
*/
void wlock(void);
/**
* <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);
/**
* <EFBFBD><EFBFBD>д<EFBFBD><EFBFBD>
2018-11-30 14:38:22 +08:00
*/
void wunlock(void);
private:
ACL_FIBER_RWLOCK* rwlk_;
fiber_rwlock(const fiber_rwlock&);
void operator=(const fiber_rwlock&);
2018-11-30 14:38:22 +08:00
};
} // namespace acl