From: Braden M. <br...@us...> - 2006-07-28 07:04:36
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv18785/src/libopenvrml/openvrml Modified Files: Vrml97Parser.g browser.cpp browser.h Log Message: Require that all threads loading EXTERNPROTO implementations are joined before destroying the browser. (Otherwise, we deadlock.) Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.185 retrieving revision 1.186 diff -C2 -d -r1.185 -r1.186 *** browser.cpp 27 Jul 2006 00:32:37 -0000 1.185 --- browser.cpp 28 Jul 2006 07:04:19 -0000 1.186 *************** *** 2306,2315 **** bool externproto_node_types_cleared_; ! boost::scoped_ptr<boost::thread> load_proto_thread_; public: ! externproto_node_metatype(const openvrml::node_metatype_id & id, ! const openvrml::scene & scene, ! const std::vector<std::string> & uris) OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc); virtual ~externproto_node_metatype() OPENVRML_NOTHROW; --- 2306,2317 ---- bool externproto_node_types_cleared_; ! boost::thread * const load_proto_thread_; public: ! externproto_node_metatype( ! const openvrml::node_metatype_id & id, ! const openvrml::scene & scene, ! const std::vector<std::string> & uris, ! boost::thread_group & load_proto_thread_group) OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc); virtual ~externproto_node_metatype() OPENVRML_NOTHROW; *************** *** 4287,4296 **** externproto_node_metatype(const openvrml::node_metatype_id & id, const openvrml::scene & scene, ! const std::vector<std::string> & uris) OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc): node_metatype(id, scene.browser()), externproto_node_types_cleared_(false), load_proto_thread_( ! new boost::thread( boost::function0<void>(load_proto(*this, scene, uris)))) {} --- 4289,4299 ---- externproto_node_metatype(const openvrml::node_metatype_id & id, const openvrml::scene & scene, ! const std::vector<std::string> & uris, ! boost::thread_group & load_proto_thread_group) OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc): node_metatype(id, scene.browser()), externproto_node_types_cleared_(false), load_proto_thread_( ! load_proto_thread_group.create_thread( boost::function0<void>(load_proto(*this, scene, uris)))) {} *************** *** 5793,5798 **** * @brief Insert a @c node_metatype. * ! * This operation will “fail” silently. That is, if a @c ! * node_metatype corresponding to @p id already exists in the map, the * existing element will simply be returned. * --- 5796,5801 ---- * @brief Insert a @c node_metatype. * ! * This operation will “fail” silently. That is, if a ! * @c node_metatype corresponding to @p id already exists in the map, the * existing element will simply be returned. * *************** *** 5827,5831 **** * @brief Find a @c node_metatype. * ! * @param[in] id an implementation id. * * @return the @c node_metatype corresponding to @p id, or a null --- 5830,5834 ---- * @brief Find a @c node_metatype. * ! * @param[in] id an implementation identifier. * * @return the @c node_metatype corresponding to @p id, or a null *************** *** 5954,5957 **** --- 5957,5970 ---- * @internal * + * @var boost::thread_group openvrml::browser::load_proto_thread_group_ + * + * @brief The threads that load EXTERNPROTO implementations. + * + * These threads @b must be joined by the browser before it is destroyed. + */ + + /** + * @internal + * * @var openvrml::browser::node_metatype_map openvrml::browser::node_metatype_map_ * *************** *** 6208,6211 **** --- 6221,6226 ---- openvrml::browser::~browser() OPENVRML_NOTHROW { + this->load_proto_thread_group_.join_all(); + const double now = browser::current_time(); *************** *** 6687,6690 **** --- 6702,6706 ---- // Clear out the current scene. // + this->load_proto_thread_group_.join_all(); double now = browser::current_time(); if (this->scene_) { this->scene_->shutdown(now); } Index: browser.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** browser.h 19 May 2006 21:55:08 -0000 1.60 --- browser.h 28 Jul 2006 07:04:19 -0000 1.61 *************** *** 24,27 **** --- 24,28 ---- # define OPENVRML_BROWSER_H + # include <boost/thread.hpp> # include <openvrml/script.h> *************** *** 220,223 **** --- 221,225 ---- std::auto_ptr<null_node_metatype> null_node_metatype_; std::auto_ptr<null_node_type> null_node_type_; + boost::thread_group load_proto_thread_group_; node_metatype_map node_metatype_map_; script_node_metatype script_node_metatype_; Index: Vrml97Parser.g =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/Vrml97Parser.g,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Vrml97Parser.g 26 Jul 2006 15:56:40 -0000 1.66 --- Vrml97Parser.g 28 Jul 2006 07:04:18 -0000 1.67 *************** *** 987,991 **** path(*scope) + '#' + id->getText(), scene, ! alt_uris)); scene.browser().add_node_metatype(externproto_class->id(), --- 987,992 ---- path(*scope) + '#' + id->getText(), scene, ! alt_uris, ! scene.browser().load_proto_thread_group_)); scene.browser().add_node_metatype(externproto_class->id(), |