mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-17 23:07:17 +01:00
Added an RWLock to User.
This commit is contained in:
parent
0ef9dc8fcf
commit
589844c827
@ -93,6 +93,19 @@ void User::save() {
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
void User::read_lock() {
|
||||
_rw_lock.read_lock();
|
||||
}
|
||||
void User::read_unlock() {
|
||||
_rw_lock.read_unlock();
|
||||
}
|
||||
void User::write_lock() {
|
||||
_rw_lock.write_lock();
|
||||
}
|
||||
void User::write_unlock() {
|
||||
_rw_lock.write_unlock();
|
||||
}
|
||||
|
||||
User::User() {
|
||||
_rank = 0;
|
||||
_banned = false;
|
||||
@ -153,6 +166,11 @@ void User::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("save"), &User::save);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("read_lock"), &User::read_lock);
|
||||
ClassDB::bind_method(D_METHOD("read_unlock"), &User::read_unlock);
|
||||
ClassDB::bind_method(D_METHOD("write_lock"), &User::write_lock);
|
||||
ClassDB::bind_method(D_METHOD("write_unlock"), &User::write_unlock);
|
||||
|
||||
BIND_ENUM_CONSTANT(PERMISSION_CREATE);
|
||||
BIND_ENUM_CONSTANT(PERMISSION_READ);
|
||||
BIND_ENUM_CONSTANT(PERMISSION_UPDATE);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef USER_H
|
||||
#define USER_H
|
||||
|
||||
#include "core/os/rw_lock.h"
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "core/resource.h"
|
||||
@ -58,6 +59,11 @@ public:
|
||||
|
||||
void save();
|
||||
|
||||
void read_lock();
|
||||
void read_unlock();
|
||||
void write_lock();
|
||||
void write_unlock();
|
||||
|
||||
User();
|
||||
~User();
|
||||
|
||||
@ -73,6 +79,8 @@ protected:
|
||||
bool _banned;
|
||||
String _password_reset_token;
|
||||
bool _locked;
|
||||
|
||||
RWLock _rw_lock;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(User::Permissions);
|
||||
|
Loading…
Reference in New Issue
Block a user