33 #include "safe_refcount.h" 35 #include "os/memory.h" 53 _FORCE_INLINE_ ID get_id()
const {
return _id; }
54 bool operator==(
const RID& p_rid)
const {
56 return _id==p_rid._id;
58 _FORCE_INLINE_
bool operator<(
const RID& p_rid)
const {
60 return _id < p_rid._id;
62 _FORCE_INLINE_
bool operator<=(
const RID& p_rid)
const {
64 return _id <= p_rid._id;
66 _FORCE_INLINE_
bool operator>(
const RID& p_rid)
const {
68 return _id > p_rid._id;
70 bool operator!=(
const RID& p_rid)
const {
72 return _id!=p_rid._id;
74 _FORCE_INLINE_
bool is_valid()
const {
return _id>0; }
76 operator const void*()
const {
77 return is_valid() ?
this : 0;
80 _FORCE_INLINE_
RID() {
90 void set_id(
RID& p_rid, ID p_id)
const { p_rid._id=p_id; }
91 void set_ownage(
RID& p_rid)
const { p_rid.owner=
const_cast<RID_OwnerBase*
>(
this); }
95 virtual bool owns(
const RID& p_rid)
const=0;
96 virtual void get_owned_list(
List<RID> *p_owned)
const=0;
98 static void init_rid();
103 template<
class T,
bool thread_safe=false>
107 typedef void (*ReleaseNotifyFunc)(
void*user,T *p_data);
115 RID make_rid(T * p_data) {
134 _FORCE_INLINE_ T *
get(
const RID& p_rid) {
140 T**elem = id_map.
getptr(p_rid.get_id());
146 ERR_FAIL_COND_V(!elem,NULL);
152 virtual bool owns(
const RID& p_rid)
const {
158 T**elem = id_map.
getptr(p_rid.get_id());
167 virtual void free(
RID p_rid) {
172 ERR_FAIL_COND(!owns(p_rid));
173 id_map.
erase(p_rid.get_id());
175 virtual void get_owned_list(
List<RID> *p_owned)
const {
182 while((
id=id_map.
next(
id))) {
Element * push_back(const T &value)
Definition: list.h:220
virtual void unlock()=0
Unlock the mutex, let other threads continue.
virtual void lock()=0
Lock the mutex, block if locked by someone else.
const TKey * next(const TKey *p_key) const
Definition: hash_map.h:514
static Mutex * create(bool p_recursive=true)
Create a mutex.
Definition: mutex.cpp:37
bool erase(const TKey &p_key)
Definition: hash_map.h:431
_FORCE_INLINE_ TData * getptr(const TKey &p_key)
Definition: hash_map.h:341