2021-11-12 10:00:41 +01:00
|
|
|
#ifndef SHARED_RESOURCE_H
|
|
|
|
#define SHARED_RESOURCE_H
|
|
|
|
|
|
|
|
#include "core/string.h"
|
|
|
|
|
|
|
|
#include "resource.h"
|
2022-02-04 13:53:30 +01:00
|
|
|
#include "core/threading/rw_lock.h"
|
2021-11-12 10:00:41 +01:00
|
|
|
|
|
|
|
class SharedResource : public Resource {
|
|
|
|
RCPP_OBJECT(SharedResource, Resource);
|
|
|
|
|
|
|
|
public:
|
2022-02-04 13:53:30 +01:00
|
|
|
void read_lock();
|
|
|
|
void read_unlock();
|
|
|
|
Error read_try_lock();
|
|
|
|
|
|
|
|
void write_lock();
|
|
|
|
void write_unlock();
|
|
|
|
Error write_try_lock();
|
2021-11-12 10:00:41 +01:00
|
|
|
|
|
|
|
SharedResource();
|
|
|
|
~SharedResource();
|
|
|
|
|
|
|
|
private:
|
2022-02-04 13:53:30 +01:00
|
|
|
RWLock _lock;
|
2021-11-12 10:00:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|