|
|
@@ -32,7 +32,7 @@ TypeRegistry *TypeRegistry::_global_pointer = NULL;
|
|
|
*/
|
|
|
bool TypeRegistry::
|
|
|
register_type(TypeHandle &type_handle, const string &name) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
if (type_handle != TypeHandle::none()) {
|
|
|
// Here's a type that was already registered. Just make sure everything's
|
|
|
@@ -40,7 +40,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
TypeRegistryNode *rnode = look_up(type_handle, NULL);
|
|
|
if (&type_handle == &rnode->_ref) {
|
|
|
// No problem.
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
assert(rnode->_name == name);
|
|
|
return false;
|
|
|
}
|
|
|
@@ -62,7 +62,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
_derivations_fresh = false;
|
|
|
|
|
|
type_handle = new_handle;
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return true;
|
|
|
}
|
|
|
TypeRegistryNode *rnode = (*ri).second;
|
|
|
@@ -78,7 +78,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
|
|
|
if (type_handle == rnode->_handle) {
|
|
|
// No problem.
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return false;
|
|
|
}
|
|
|
// But wait--the type_handle has changed! We kept a reference to the
|
|
|
@@ -87,7 +87,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
// time, but now it's different! Bad juju.
|
|
|
cerr << "Reregistering " << name << "\n";
|
|
|
type_handle = rnode->_handle;
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -103,7 +103,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
|
|
|
type_handle = rnode->_handle;
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -114,7 +114,7 @@ register_type(TypeHandle &type_handle, const string &name) {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
register_dynamic_type(const string &name) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
NameRegistry::iterator ri;
|
|
|
ri = _name_registry.find(name);
|
|
|
@@ -134,14 +134,14 @@ register_dynamic_type(const string &name) {
|
|
|
_name_registry[name] = rnode;
|
|
|
_derivations_fresh = false;
|
|
|
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return *new_handle;
|
|
|
}
|
|
|
|
|
|
// Return the TypeHandle previously obtained.
|
|
|
TypeRegistryNode *rnode = (*ri).second;
|
|
|
TypeHandle handle = rnode->_handle;
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return handle;
|
|
|
}
|
|
|
|
|
|
@@ -152,7 +152,7 @@ register_dynamic_type(const string &name) {
|
|
|
*/
|
|
|
void TypeRegistry::
|
|
|
record_derivation(TypeHandle child, TypeHandle parent) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
TypeRegistryNode *cnode = look_up(child, NULL);
|
|
|
assert(cnode != (TypeRegistryNode *)NULL);
|
|
|
@@ -171,7 +171,7 @@ record_derivation(TypeHandle child, TypeHandle parent) {
|
|
|
_derivations_fresh = false;
|
|
|
}
|
|
|
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -182,7 +182,7 @@ record_derivation(TypeHandle child, TypeHandle parent) {
|
|
|
*/
|
|
|
void TypeRegistry::
|
|
|
record_alternate_name(TypeHandle type, const string &name) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
TypeRegistryNode *rnode = look_up(type, (TypedObject *)NULL);
|
|
|
if (rnode != (TypeRegistryNode *)NULL) {
|
|
|
@@ -190,7 +190,7 @@ record_alternate_name(TypeHandle type, const string &name) {
|
|
|
_name_registry.insert(NameRegistry::value_type(name, rnode)).first;
|
|
|
|
|
|
if ((*ri).second != rnode) {
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
cerr
|
|
|
<< "Name " << name << " already assigned to TypeHandle "
|
|
|
<< rnode->_name << "; cannot reassign to " << type << "\n";
|
|
|
@@ -199,7 +199,7 @@ record_alternate_name(TypeHandle type, const string &name) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -208,7 +208,7 @@ record_alternate_name(TypeHandle type, const string &name) {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
find_type(const string &name) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
TypeHandle handle = TypeHandle::none();
|
|
|
NameRegistry::const_iterator ri;
|
|
|
@@ -216,7 +216,7 @@ find_type(const string &name) const {
|
|
|
if (ri != _name_registry.end()) {
|
|
|
handle = (*ri).second->_handle;
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
|
|
|
return handle;
|
|
|
}
|
|
|
@@ -248,11 +248,11 @@ find_type_by_id(int id) const {
|
|
|
*/
|
|
|
string TypeRegistry::
|
|
|
get_name(TypeHandle type, TypedObject *object) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeRegistryNode *rnode = look_up(type, object);
|
|
|
assert(rnode != (TypeRegistryNode *)NULL);
|
|
|
string name = rnode->_name;
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
|
|
|
return name;
|
|
|
}
|
|
|
@@ -273,7 +273,7 @@ get_name(TypeHandle type, TypedObject *object) const {
|
|
|
bool TypeRegistry::
|
|
|
is_derived_from(TypeHandle child, TypeHandle base,
|
|
|
TypedObject *child_object) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
const TypeRegistryNode *child_node = look_up(child, child_object);
|
|
|
const TypeRegistryNode *base_node = look_up(base, (TypedObject *)NULL);
|
|
|
@@ -284,7 +284,7 @@ is_derived_from(TypeHandle child, TypeHandle base,
|
|
|
freshen_derivations();
|
|
|
|
|
|
bool result = TypeRegistryNode::is_derived_from(child_node, base_node);
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -293,9 +293,9 @@ is_derived_from(TypeHandle child, TypeHandle base,
|
|
|
*/
|
|
|
int TypeRegistry::
|
|
|
get_num_typehandles() {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
int num_types = (int)_handle_registry.size();
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return num_types;
|
|
|
}
|
|
|
|
|
|
@@ -304,12 +304,12 @@ get_num_typehandles() {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
get_typehandle(int n) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeRegistryNode *rnode = NULL;
|
|
|
if (n >= 0 && n < (int)_handle_registry.size()) {
|
|
|
rnode = _handle_registry[n];
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
|
|
|
if (rnode != (TypeRegistryNode *)NULL) {
|
|
|
return rnode->_handle;
|
|
|
@@ -324,10 +324,10 @@ get_typehandle(int n) {
|
|
|
*/
|
|
|
int TypeRegistry::
|
|
|
get_num_root_classes() {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
freshen_derivations();
|
|
|
int num_roots = (int)_root_classes.size();
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return num_roots;
|
|
|
}
|
|
|
|
|
|
@@ -336,7 +336,7 @@ get_num_root_classes() {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
get_root_class(int n) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
freshen_derivations();
|
|
|
TypeHandle handle;
|
|
|
if (n >= 0 && n < (int)_root_classes.size()) {
|
|
|
@@ -344,7 +344,7 @@ get_root_class(int n) {
|
|
|
} else {
|
|
|
handle = TypeHandle::none();
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
|
|
|
return handle;
|
|
|
}
|
|
|
@@ -362,11 +362,11 @@ get_root_class(int n) {
|
|
|
*/
|
|
|
int TypeRegistry::
|
|
|
get_num_parent_classes(TypeHandle child, TypedObject *child_object) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeRegistryNode *rnode = look_up(child, child_object);
|
|
|
assert(rnode != (TypeRegistryNode *)NULL);
|
|
|
int num_parents = (int)rnode->_parent_classes.size();
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return num_parents;
|
|
|
}
|
|
|
|
|
|
@@ -376,7 +376,7 @@ get_num_parent_classes(TypeHandle child, TypedObject *child_object) const {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
get_parent_class(TypeHandle child, int index) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeHandle handle;
|
|
|
TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL);
|
|
|
assert(rnode != (TypeRegistryNode *)NULL);
|
|
|
@@ -385,7 +385,7 @@ get_parent_class(TypeHandle child, int index) const {
|
|
|
} else {
|
|
|
handle = TypeHandle::none();
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return handle;
|
|
|
}
|
|
|
|
|
|
@@ -399,11 +399,11 @@ get_parent_class(TypeHandle child, int index) const {
|
|
|
*/
|
|
|
int TypeRegistry::
|
|
|
get_num_child_classes(TypeHandle child, TypedObject *child_object) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeRegistryNode *rnode = look_up(child, child_object);
|
|
|
assert(rnode != (TypeRegistryNode *)NULL);
|
|
|
int num_children = (int)rnode->_child_classes.size();
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return num_children;
|
|
|
}
|
|
|
|
|
|
@@ -413,7 +413,7 @@ get_num_child_classes(TypeHandle child, TypedObject *child_object) const {
|
|
|
*/
|
|
|
TypeHandle TypeRegistry::
|
|
|
get_child_class(TypeHandle child, int index) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeHandle handle;
|
|
|
TypeRegistryNode *rnode = look_up(child, (TypedObject *)NULL);
|
|
|
assert(rnode != (TypeRegistryNode *)NULL);
|
|
|
@@ -422,7 +422,7 @@ get_child_class(TypeHandle child, int index) const {
|
|
|
} else {
|
|
|
handle = TypeHandle::none();
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return handle;
|
|
|
}
|
|
|
|
|
|
@@ -439,7 +439,7 @@ get_child_class(TypeHandle child, int index) const {
|
|
|
TypeHandle TypeRegistry::
|
|
|
get_parent_towards(TypeHandle child, TypeHandle base,
|
|
|
TypedObject *child_object) {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
TypeHandle handle;
|
|
|
const TypeRegistryNode *child_node = look_up(child, child_object);
|
|
|
const TypeRegistryNode *base_node = look_up(base, NULL);
|
|
|
@@ -447,7 +447,7 @@ get_parent_towards(TypeHandle child, TypeHandle base,
|
|
|
base_node != (TypeRegistryNode *)NULL);
|
|
|
freshen_derivations();
|
|
|
handle = TypeRegistryNode::get_parent_towards(child_node, base_node);
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
return handle;
|
|
|
}
|
|
|
|
|
|
@@ -462,7 +462,7 @@ get_parent_towards(TypeHandle child, TypeHandle base,
|
|
|
void TypeRegistry::
|
|
|
reregister_types() {
|
|
|
init_lock();
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
HandleRegistry::iterator ri;
|
|
|
TypeRegistry *reg = ptr();
|
|
|
for (ri = reg->_handle_registry.begin();
|
|
|
@@ -473,7 +473,7 @@ reregister_types() {
|
|
|
cerr << "Reregistering " << rnode->_name << "\n";
|
|
|
}
|
|
|
}
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -483,9 +483,9 @@ reregister_types() {
|
|
|
*/
|
|
|
void TypeRegistry::
|
|
|
write(ostream &out) const {
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
do_write(out);
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -613,9 +613,9 @@ look_up_invalid(TypeHandle handle, TypedObject *object) const {
|
|
|
// But we're lucky enough to have a TypedObject pointer handy! Maybe we
|
|
|
// can use it to resolve the error. We have to drop the lock while we
|
|
|
// do this, so we don't get a recursive lock.
|
|
|
- _lock->release();
|
|
|
+ _lock->unlock();
|
|
|
handle = object->force_init_type();
|
|
|
- _lock->acquire();
|
|
|
+ _lock->lock();
|
|
|
|
|
|
if (handle._index == 0) {
|
|
|
// Strange.
|