mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
SharedResource is now using an RWLock.
This commit is contained in:
parent
f434d1ff6c
commit
a05ca2e261
@ -1,10 +1,23 @@
|
||||
#include "shared_resource.h"
|
||||
|
||||
void SharedResource::lock() {
|
||||
_mutex.lock();
|
||||
void SharedResource::read_lock() {
|
||||
_lock.read_lock();
|
||||
}
|
||||
void SharedResource::unlock() {
|
||||
_mutex.unlock();
|
||||
void SharedResource::read_unlock() {
|
||||
_lock.read_unlock();
|
||||
}
|
||||
Error SharedResource::read_try_lock() {
|
||||
return _lock.read_try_lock();
|
||||
}
|
||||
|
||||
void SharedResource::write_lock() {
|
||||
_lock.write_lock();
|
||||
}
|
||||
void SharedResource::write_unlock() {
|
||||
_lock.write_unlock();
|
||||
}
|
||||
Error SharedResource::write_try_lock() {
|
||||
return _lock.write_try_lock();
|
||||
}
|
||||
|
||||
SharedResource::SharedResource() :
|
||||
|
@ -4,21 +4,25 @@
|
||||
#include "core/string.h"
|
||||
|
||||
#include "resource.h"
|
||||
#include "core/threading/mutex.h"
|
||||
#include "core/threading/rw_lock.h"
|
||||
|
||||
class SharedResource : public Resource {
|
||||
RCPP_OBJECT(SharedResource, Resource);
|
||||
|
||||
public:
|
||||
void lock();
|
||||
void unlock();
|
||||
void read_lock();
|
||||
void read_unlock();
|
||||
Error read_try_lock();
|
||||
|
||||
void write_lock();
|
||||
void write_unlock();
|
||||
Error write_try_lock();
|
||||
|
||||
SharedResource();
|
||||
~SharedResource();
|
||||
|
||||
private:
|
||||
//todo add read write lock instead of this
|
||||
Mutex _mutex;
|
||||
RWLock _lock;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user