mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-02 13:47:56 +02:00
Added a new SharedResource class. It contains a mutex over Resource (for now). These can be used as a base for classes that you don't intend to just query from a database every time. E.g. rbac rank data.
This commit is contained in:
parent
5872d9d74f
commit
b6cae73521
15
core/shared_resource.cpp
Normal file
15
core/shared_resource.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "shared_resource.h"
|
||||||
|
|
||||||
|
void SharedResource::lock() {
|
||||||
|
_mutex.lock();
|
||||||
|
}
|
||||||
|
void SharedResource::unlock() {
|
||||||
|
_mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedResource::SharedResource() :
|
||||||
|
Resource() {
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedResource::~SharedResource() {
|
||||||
|
}
|
23
core/shared_resource.h
Normal file
23
core/shared_resource.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef SHARED_RESOURCE_H
|
||||||
|
#define SHARED_RESOURCE_H
|
||||||
|
|
||||||
|
#include "core/string.h"
|
||||||
|
|
||||||
|
#include "resource.h"
|
||||||
|
#include "core/threading/mutex.h"
|
||||||
|
|
||||||
|
class SharedResource : public Resource {
|
||||||
|
RCPP_OBJECT(SharedResource, Resource);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void lock();
|
||||||
|
void unlock();
|
||||||
|
|
||||||
|
SharedResource();
|
||||||
|
~SharedResource();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Mutex _mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user