1 #include "stateobject.hpp"
8 std::map
<void*, void*>* states
;
10 void* _get(void* obj
, void* (*create
)())
12 if(!lock
) lock
= new threads::lock
;
13 threads::alock
h(*lock
);
14 if(!states
) states
= new std::map
<void*, void*>;
15 if(!states
->count(obj
)) {
16 (*states
)[obj
] = NULL
;
18 (*states
)[obj
] = create();
24 return (*states
)[obj
];
27 void* _get_soft(void* obj
)
29 if(!lock
) return NULL
;
30 threads::alock
h(*lock
);
31 if(!states
) return NULL
;
32 if(states
->count(obj
))
33 return (*states
)[obj
];
37 void _clear(void* obj
, void (*destroy
)(void* obj
))
40 threads::alock
h(*lock
);
42 if(!states
->count(obj
)) return;
43 destroy((*states
)[obj
]);