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:
Relintai 2021-11-12 10:00:41 +01:00
parent 5872d9d74f
commit b6cae73521
2 changed files with 38 additions and 0 deletions

15
core/shared_resource.cpp Normal file
View 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
View 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