From: Braden M. <br...@us...> - 2007-05-21 03:37:03
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25952/src/libopenvrml/openvrml Modified Files: browser.cpp browser.h Log Message: Replaced the browser-wide recursive mutex with several read-write mutexes. Index: browser.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v retrieving revision 1.213 retrieving revision 1.214 diff -C2 -d -r1.213 -r1.214 *** browser.cpp 15 May 2007 04:06:11 -0000 1.213 --- browser.cpp 21 May 2007 03:37:01 -0000 1.214 *************** *** 5062,5066 **** /** ! * @var openvrml::browser::Vrml97Parser * * @brief VRML97 parser generated by ANTLR. --- 5062,5072 ---- /** ! * @var class openvrml::browser::scene ! * ! * @brief The scene. ! */ ! ! /** ! * @var class openvrml::browser::Vrml97Parser * * @brief VRML97 parser generated by ANTLR. *************** *** 5068,5072 **** /** ! * @var openvrml::browser::X3DVrmlParser * * @brief X3D VRML parser generated by ANTLR. --- 5074,5078 ---- /** ! * @var class openvrml::browser::X3DVrmlParser * * @brief X3D VRML parser generated by ANTLR. *************** *** 5416,5419 **** --- 5422,5442 ---- * @internal * + * @var openvrml::resource_fetcher & openvrml::browser::fetcher_ + * + * @brief A reference to the @c resource_fetcher associated with the + * @c browser. + */ + + /** + * @internal + * + * @var openvrml::read_write_mutex openvrml::browser::scene_mutex_ + * + * @brief Mutex protecting @c #scene_. + */ + + /** + * @internal + * * @var openvrml::scene * openvrml::browser::scene_ * *************** *** 5433,5436 **** --- 5456,5467 ---- * @internal * + * @var openvrml::read_write_mutex openvrml::browser::active_viewpoint_mutex_ + * + * @brief Mutex protecting @c #active_viewpoint_. + */ + + /** + * @internal + * * @var openvrml::viewpoint_node * openvrml::browser::active_viewpoint_ * *************** *** 5450,5453 **** --- 5481,5492 ---- * @internal * + * @var openvrml::read_write_mutex openvrml::browser::active_navigation_info_mutex_ + * + * @brief Mutex protecting @c #active_navigation_info_. + */ + + /** + * @internal + * * @var openvrml::navigation_info_node * openvrml::browser::active_navigation_info_ * *************** *** 5458,5462 **** * @internal * ! * @var std::list<openvrml::viewpoint_node *> openvrml::browser::viewpoint_list * * @brief A list of all the Viewpoint @c node%s in the @c browser. --- 5497,5509 ---- * @internal * ! * @var openvrml::read_write_mutex openvrml::browser::viewpoint_list_mutex_ ! * ! * @brief Mutex protecting @c #viewpoint_list_. ! */ ! ! /** ! * @internal ! * ! * @var std::list<openvrml::viewpoint_node *> openvrml::browser::viewpoint_list_ * * @brief A list of all the Viewpoint @c node%s in the @c browser. *************** *** 5466,5470 **** * @internal * ! * @var std::list<openvrml::node *> openvrml::browser::scoped_lights * * @brief A list of all the scoped light @c node%s in the @c browser. --- 5513,5525 ---- * @internal * ! * @var openvrml::read_write_mutex openvrml::browser::scoped_lights_mutex_ ! * ! * @brief Mutex protecting @c #scoped_lights_. ! */ ! ! /** ! * @internal ! * ! * @var std::list<openvrml::node *> openvrml::browser::scoped_lights_ * * @brief A list of all the scoped light @c node%s in the @c browser. *************** *** 5474,5478 **** * @internal * ! * @var std::list<openvrml::script_node *> openvrml::browser::scripts * * @brief A list of all the Script @c node%s in the @c browser. --- 5529,5541 ---- * @internal * ! * @var openvrml::read_write_mutex openvrml::browser::scripts_mutex_ ! * ! * @brief Mutex protecting @c #scripts_. ! */ ! ! /** ! * @internal ! * ! * @var std::list<openvrml::script_node *> openvrml::browser::scripts_ * * @brief A list of all the Script @c node%s in the @c browser. *************** *** 5482,5486 **** * @internal * ! * @var std::list<openvrml::time_dependent_node *> openvrml::browser::timers * * @brief A list of all the TimeSensor @c node%s in the @c browser. --- 5545,5557 ---- * @internal * ! * @var openvrml::read_write_mutex openvrml::browser::timers_mutex_ ! * ! * @brief Mutex protecting @c #timers_. ! */ ! ! /** ! * @internal ! * ! * @var std::list<openvrml::time_dependent_node *> openvrml::browser::timers_ * * @brief A list of all the TimeSensor @c node%s in the @c browser. *************** *** 5520,5523 **** --- 5591,5596 ---- /** + * @internal + * * @var bool openvrml::browser::new_view * *************** *** 5526,5529 **** --- 5599,5612 ---- /** + * @internal + * + * @var openvrml::read_write_mutex openvrml::browser::delta_time_mutex_ + * + * @brief Mutex protecting @c #delta_time. + */ + + /** + * @internal + * * @var double openvrml::browser::delta_time * *************** *** 5532,5535 **** --- 5615,5628 ---- /** + * @internal + * + * @var openvrml::read_write_mutex openvrml::browser::viewer_mutex_ + * + * @brief Mutex protecting @c #viewer_. + */ + + /** + * @internal + * * @var openvrml::openvrml::viewer * openvrml::browser::viewer_ * *************** *** 5538,5541 **** --- 5631,5644 ---- /** + * @internal + * + * @var openvrml::read_write_mutex openvrml::browser::frame_rate_mutex_ + * + * @brief Mutex protecting @c #frame_rate_. + */ + + /** + * @internal + * * @var double openvrml::browser::frame_rate_ * *************** *** 5640,5643 **** --- 5743,5747 ---- null_node_type_(new null_node_type(*null_node_metatype_)), script_node_metatype_(*this), + fetcher_(fetcher), scene_(new scene(*this)), default_viewpoint_(new default_viewpoint(*null_node_type_)), *************** *** 5650,5657 **** viewer_(0), modified_(false), ! fetcher_(fetcher), out_(&out), err_(&err), - frame_rate_(0.0), flags_need_updating(false) { --- 5754,5760 ---- viewer_(0), modified_(false), ! frame_rate_(0.0), out_(&out), err_(&err), flags_need_updating(false) { *************** *** 5673,5683 **** const double now = browser::current_time(); if (this->scene_) { this->scene_->shutdown(now); } this->node_metatype_map_.shutdown(now); ! assert(this->viewpoint_list.empty()); ! assert(this->scoped_lights.empty()); ! assert(this->scripts.empty()); ! assert(this->timers.empty()); } --- 5776,5787 ---- const double now = browser::current_time(); + read_write_mutex::scoped_read_lock scene_lock(this->scene_mutex_); if (this->scene_) { this->scene_->shutdown(now); } this->node_metatype_map_.shutdown(now); ! assert(this->viewpoint_list_.empty()); ! assert(this->scoped_lights_.empty()); ! assert(this->scripts_.empty()); ! assert(this->timers_.empty()); } *************** *** 5733,5737 **** openvrml::scene * openvrml::browser::root_scene() const OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return this->scene_.get(); } --- 5837,5841 ---- openvrml::scene * openvrml::browser::root_scene() const OPENVRML_NOTHROW { ! read_write_mutex::scoped_read_lock lock(this->scene_mutex_); return this->scene_.get(); } *************** *** 5751,5755 **** OPENVRML_THROW1(std::bad_alloc) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); assert(this->scene_); --- 5855,5859 ---- OPENVRML_THROW1(std::bad_alloc) { ! read_write_mutex::scoped_read_lock lock(this->scene_mutex_); assert(this->scene_); *************** *** 5797,5801 **** OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return *this->active_viewpoint_; } --- 5901,5905 ---- OPENVRML_NOTHROW { ! read_write_mutex::scoped_read_lock lock(this->active_viewpoint_mutex_); return *this->active_viewpoint_; } *************** *** 5809,5813 **** OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); this->active_viewpoint_ = &viewpoint; } --- 5913,5917 ---- OPENVRML_NOTHROW { ! read_write_mutex::scoped_write_lock lock(this->active_viewpoint_mutex_); this->active_viewpoint_ = &viewpoint; } *************** *** 5818,5822 **** void openvrml::browser::reset_default_viewpoint() OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); assert(this->default_viewpoint_); this->active_viewpoint_ = --- 5922,5926 ---- void openvrml::browser::reset_default_viewpoint() OPENVRML_NOTHROW { ! read_write_mutex::scoped_write_lock lock(this->active_viewpoint_mutex_); assert(this->default_viewpoint_); this->active_viewpoint_ = *************** *** 5836,5840 **** openvrml::browser::active_navigation_info() const OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return *this->active_navigation_info_; } --- 5940,5945 ---- openvrml::browser::active_navigation_info() const OPENVRML_NOTHROW { ! read_write_mutex::scoped_read_lock ! lock(this->active_navigation_info_mutex_); return *this->active_navigation_info_; } *************** *** 5848,5852 **** OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); this->active_navigation_info_ = &nav_info; } --- 5953,5958 ---- OPENVRML_NOTHROW { ! read_write_mutex::scoped_write_lock ! lock(this->active_navigation_info_mutex_); this->active_navigation_info_ = &nav_info; } *************** *** 5857,5861 **** void openvrml::browser::reset_default_navigation_info() OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); assert(this->default_navigation_info_); this->active_navigation_info_ = --- 5963,5968 ---- void openvrml::browser::reset_default_navigation_info() OPENVRML_NOTHROW { ! read_write_mutex::scoped_write_lock ! lock(this->active_navigation_info_mutex_); assert(this->default_navigation_info_); this->active_navigation_info_ = *************** *** 5879,5886 **** OPENVRML_THROW1(std::bad_alloc) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(std::find(this->viewpoint_list.begin(), this->viewpoint_list.end(), ! &viewpoint) == this->viewpoint_list.end()); ! this->viewpoint_list.push_back(&viewpoint); } --- 5986,5993 ---- OPENVRML_THROW1(std::bad_alloc) { ! read_write_mutex::scoped_write_lock lock(this->viewpoint_list_mutex_); ! assert(std::find(this->viewpoint_list_.begin(), this->viewpoint_list_.end(), ! &viewpoint) == this->viewpoint_list_.end()); ! this->viewpoint_list_.push_back(&viewpoint); } *************** *** 5896,5907 **** OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(!this->viewpoint_list.empty()); typedef std::list<viewpoint_node *> viewpoint_list_t; ! const viewpoint_list_t::iterator end = this->viewpoint_list.end(); const viewpoint_list_t::iterator pos = ! std::find(this->viewpoint_list.begin(), end, &viewpoint); assert(pos != end); ! this->viewpoint_list.erase(pos); } --- 6003,6014 ---- OPENVRML_NOTHROW { ! read_write_mutex::scoped_write_lock lock(this->viewpoint_list_mutex_); ! assert(!this->viewpoint_list_.empty()); typedef std::list<viewpoint_node *> viewpoint_list_t; ! const viewpoint_list_t::iterator end = this->viewpoint_list_.end(); const viewpoint_list_t::iterator pos = ! std::find(this->viewpoint_list_.begin(), end, &viewpoint); assert(pos != end); ! this->viewpoint_list_.erase(pos); } *************** *** 5911,5919 **** * @return the list of @c viewpoint_node%s for the world. */ ! const std::list<openvrml::viewpoint_node *> & openvrml::browser::viewpoints() const OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! return this->viewpoint_list; } --- 6018,6026 ---- * @return the list of @c viewpoint_node%s for the world. */ ! const std::list<openvrml::viewpoint_node *> openvrml::browser::viewpoints() const OPENVRML_NOTHROW { ! read_write_mutex::scoped_read_lock lock(this->viewpoint_list_mutex_); ! return this->viewpoint_list_; } *************** *** 5929,5933 **** OPENVRML_THROW1(viewer_in_use) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); if (v && v->browser_) { throw viewer_in_use(); } if (this->viewer_) { this->viewer_->browser_ = 0; } --- 6036,6040 ---- OPENVRML_THROW1(viewer_in_use) { ! read_write_mutex::scoped_write_lock lock(this->viewer_mutex_); if (v && v->browser_) { throw viewer_in_use(); } if (this->viewer_) { this->viewer_->browser_ = 0; } *************** *** 5943,5947 **** openvrml::viewer * openvrml::browser::viewer() const OPENVRML_NOTHROW { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return this->viewer_; } --- 6050,6054 ---- openvrml::viewer * openvrml::browser::viewer() const OPENVRML_NOTHROW { ! read_write_mutex::scoped_read_lock lock(this->viewer_mutex_); return this->viewer_; } *************** *** 5978,5982 **** float openvrml::browser::current_speed() { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); navigation_info_node & nav_info = this->active_navigation_info(); return nav_info.speed(); --- 6085,6090 ---- float openvrml::browser::current_speed() { ! read_write_mutex::scoped_read_lock ! lock(this->active_navigation_info_mutex_); navigation_info_node & nav_info = this->active_navigation_info(); return nav_info.speed(); *************** *** 5991,5995 **** OPENVRML_THROW1(std::bad_alloc) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); assert(this->scene_); return this->scene_->url(); // Throws std::bad_alloc. --- 6099,6103 ---- OPENVRML_THROW1(std::bad_alloc) { ! read_write_mutex::scoped_read_lock lock(this->scene_mutex_); assert(this->scene_); return this->scene_->url(); // Throws std::bad_alloc. *************** *** 6008,6012 **** { { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); using std::for_each; --- 6116,6122 ---- { { ! read_write_mutex::scoped_write_lock ! scene_lock(this->scene_mutex_), ! active_viewpoint_lock(this->active_viewpoint_mutex_); using std::for_each; *************** *** 6029,6036 **** this->active_viewpoint_ = node_cast<viewpoint_node *>(this->default_viewpoint_.get()); ! assert(this->viewpoint_list.empty()); ! assert(this->scoped_lights.empty()); ! assert(this->scripts.empty()); ! assert(this->timers.empty()); // --- 6139,6146 ---- this->active_viewpoint_ = node_cast<viewpoint_node *>(this->default_viewpoint_.get()); ! assert(this->viewpoint_list_.empty()); ! assert(this->scoped_lights_.empty()); ! assert(this->scripts_.empty()); ! assert(this->timers_.empty()); // *************** *** 6102,6106 **** const std::vector<boost::intrusive_ptr<node> > & nodes) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); const double now = browser::current_time(); this->scene_->nodes(nodes); --- 6212,6216 ---- const std::vector<boost::intrusive_ptr<node> > & nodes) { ! read_write_mutex::scoped_read_lock lock(this->scene_mutex_); const double now = browser::current_time(); this->scene_->nodes(nodes); *************** *** 6130,6136 **** try { ! boost::recursive_mutex::scoped_lock lock(browser.mutex_); ! std::auto_ptr<resource_istream> in = ! browser.scene_->get_resource(this->url_); if (!(*in)) { throw unreachable_url(); } browser.set_world(*in); --- 6240,6249 ---- try { ! std::auto_ptr<resource_istream> in; ! { ! read_write_mutex::scoped_read_lock ! lock(browser.scene_mutex_); ! in = browser.scene_->get_resource(this->url_); ! } if (!(*in)) { throw unreachable_url(); } browser.set_world(*in); *************** *** 6242,6245 **** --- 6355,6359 ---- std::vector<boost::intrusive_ptr<node> > nodes; try { + read_write_mutex::scoped_read_lock lock(this->scene_mutex_); assert(this->scene_); std::map<string, string> meta; *************** *** 6279,6282 **** --- 6393,6397 ---- boost::thread_resource_error) { + read_write_mutex::scoped_read_lock lock(this->scene_mutex_); assert(this->scene_); this->scene_->create_vrml_from_url(url, node, event); *************** *** 6324,6328 **** double openvrml::browser::frame_rate() const { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return this->frame_rate_; } --- 6439,6443 ---- double openvrml::browser::frame_rate() const { ! read_write_mutex::scoped_read_lock lock(this->frame_rate_mutex_); return this->frame_rate_; } *************** *** 6339,6343 **** const double (&point)[3]) { - boost::recursive_mutex::scoped_lock lock(this->mutex_); if (n) { if (pointing_device_sensor_node * pointing_device_sensor = --- 6454,6457 ---- *************** *** 6371,6375 **** using std::for_each; ! boost::recursive_mutex::scoped_lock lock(this->mutex_); if (current_time <= 0.0) { current_time = browser::current_time(); } --- 6485,6491 ---- using std::for_each; ! read_write_mutex::scoped_read_lock ! timers_lock(this->timers_mutex_), ! scripts_lock(this->scripts_mutex_); if (current_time <= 0.0) { current_time = browser::current_time(); } *************** *** 6380,6384 **** // Update each of the timers. // ! for_each(this->timers.begin(), this->timers.end(), boost::bind2nd(boost::mem_fun(&time_dependent_node::update), current_time)); --- 6496,6500 ---- // Update each of the timers. // ! for_each(this->timers_.begin(), this->timers_.end(), boost::bind2nd(boost::mem_fun(&time_dependent_node::update), current_time)); *************** *** 6387,6391 **** // Update each of the scripts. // ! for_each(this->scripts.begin(), this->scripts.end(), boost::bind2nd(boost::mem_fun(&script_node::update), current_time)); --- 6503,6507 ---- // Update each of the scripts. // ! for_each(this->scripts_.begin(), this->scripts_.end(), boost::bind2nd(boost::mem_fun(&script_node::update), current_time)); *************** *** 6411,6415 **** void openvrml::browser::render() { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); if (!this->viewer_) { return; } --- 6527,6534 ---- void openvrml::browser::render() { ! read_write_mutex::scoped_read_lock ! scene_lock(this->scene_mutex_), ! active_viewpoint_lock_(this->active_viewpoint_mutex_); ! if (!this->viewer_) { return; } *************** *** 6469,6476 **** // Do the browser-level lights (Points and Spots) ! std::for_each(this->scoped_lights.begin(), this->scoped_lights.end(), ! boost::bind2nd( ! boost::mem_fun(&scoped_light_node::render_scoped_light), ! *this->viewer_)); // --- 6588,6600 ---- // Do the browser-level lights (Points and Spots) ! { ! using std::for_each; ! read_write_mutex::scoped_read_lock ! scoped_lights_lock(this->scoped_lights_mutex_); ! for_each(this->scoped_lights_.begin(), this->scoped_lights_.end(), ! boost::bind2nd( ! boost::mem_fun(&scoped_light_node::render_scoped_light), ! *this->viewer_)); ! } // *************** *** 6484,6487 **** --- 6608,6613 ---- // This is actually one frame late... + read_write_mutex::scoped_write_lock + frame_rate_lock(this->frame_rate_mutex_); this->frame_rate_ = this->viewer_->frame_rate(); *************** *** 6520,6524 **** void openvrml::browser::delta(const double d) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); if (d < this->delta_time) { this->delta_time = d; } } --- 6646,6650 ---- void openvrml::browser::delta(const double d) { ! read_write_mutex::scoped_write_lock lock(this->delta_time_mutex_); if (d < this->delta_time) { this->delta_time = d; } } *************** *** 6531,6535 **** double openvrml::browser::delta() const { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); return this->delta_time; } --- 6657,6661 ---- double openvrml::browser::delta() const { ! read_write_mutex::scoped_read_lock lock(this->delta_time_mutex_); return this->delta_time; } *************** *** 6545,6552 **** openvrml::browser::add_scoped_light(scoped_light_node & light) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(std::find(this->scoped_lights.begin(), this->scoped_lights.end(), ! &light) == this->scoped_lights.end()); ! this->scoped_lights.push_back(&light); } --- 6671,6678 ---- openvrml::browser::add_scoped_light(scoped_light_node & light) { ! read_write_mutex::scoped_write_lock lock(this->scoped_lights_mutex_); ! assert(std::find(this->scoped_lights_.begin(), this->scoped_lights_.end(), ! &light) == this->scoped_lights_.end()); ! this->scoped_lights_.push_back(&light); } *************** *** 6559,6573 **** */ void ! openvrml::browser:: ! remove_scoped_light(scoped_light_node & light) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(!this->scoped_lights.empty()); const std::list<scoped_light_node *>::iterator end = ! this->scoped_lights.end(); const std::list<scoped_light_node *>::iterator pos = ! std::find(this->scoped_lights.begin(), end, &light); assert(pos != end); ! this->scoped_lights.erase(pos); } --- 6685,6698 ---- */ void ! openvrml::browser::remove_scoped_light(scoped_light_node & light) { ! read_write_mutex::scoped_write_lock lock(this->scoped_lights_mutex_); ! assert(!this->scoped_lights_.empty()); const std::list<scoped_light_node *>::iterator end = ! this->scoped_lights_.end(); const std::list<scoped_light_node *>::iterator pos = ! std::find(this->scoped_lights_.begin(), end, &light); assert(pos != end); ! this->scoped_lights_.erase(pos); } *************** *** 6581,6588 **** void openvrml::browser::add_script(script_node & script) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(std::find(this->scripts.begin(), this->scripts.end(), &script) ! == this->scripts.end()); ! this->scripts.push_back(&script); } --- 6706,6713 ---- void openvrml::browser::add_script(script_node & script) { ! read_write_mutex::scoped_write_lock lock(this->scripts_mutex_); ! assert(std::find(this->scripts_.begin(), this->scripts_.end(), &script) ! == this->scripts_.end()); ! this->scripts_.push_back(&script); } *************** *** 6596,6607 **** void openvrml::browser::remove_script(script_node & script) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(!this->scripts.empty()); typedef std::list<script_node *> script_node_list_t; ! const script_node_list_t::iterator end = this->scripts.end(); const script_node_list_t::iterator pos = ! std::find(this->scripts.begin(), end, &script); assert(pos != end); ! this->scripts.erase(pos); } --- 6721,6732 ---- void openvrml::browser::remove_script(script_node & script) { ! read_write_mutex::scoped_write_lock lock(this->scripts_mutex_); ! assert(!this->scripts_.empty()); typedef std::list<script_node *> script_node_list_t; ! const script_node_list_t::iterator end = this->scripts_.end(); const script_node_list_t::iterator pos = ! std::find(this->scripts_.begin(), end, &script); assert(pos != end); ! this->scripts_.erase(pos); } *************** *** 6615,6622 **** void openvrml::browser::add_time_dependent(time_dependent_node & n) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(std::find(this->timers.begin(), this->timers.end(), &n) ! == this->timers.end()); ! this->timers.push_back(&n); } --- 6740,6747 ---- void openvrml::browser::add_time_dependent(time_dependent_node & n) { ! read_write_mutex::scoped_write_lock lock(this->timers_mutex_); ! assert(std::find(this->timers_.begin(), this->timers_.end(), &n) ! == this->timers_.end()); ! this->timers_.push_back(&n); } *************** *** 6631,6641 **** openvrml::browser::remove_time_dependent(time_dependent_node & n) { ! boost::recursive_mutex::scoped_lock lock(this->mutex_); ! assert(!this->timers.empty()); ! const std::list<time_dependent_node *>::iterator end = this->timers.end(); const std::list<time_dependent_node *>::iterator pos = ! std::find(this->timers.begin(), end, &n); assert(pos != end); ! this->timers.erase(pos); } --- 6756,6766 ---- openvrml::browser::remove_time_dependent(time_dependent_node & n) { ! read_write_mutex::scoped_write_lock lock(this->timers_mutex_); ! assert(!this->timers_.empty()); ! const std::list<time_dependent_node *>::iterator end = this->timers_.end(); const std::list<time_dependent_node *>::iterator pos = ! std::find(this->timers_.begin(), end, &n); assert(pos != end); ! this->timers_.erase(pos); } Index: browser.h =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** browser.h 18 May 2007 02:17:40 -0000 1.68 --- browser.h 21 May 2007 03:37:01 -0000 1.69 *************** *** 228,232 **** }; - mutable boost::recursive_mutex mutex_; const boost::scoped_ptr<null_node_metatype> null_node_metatype_; const boost::scoped_ptr<null_node_type> null_node_type_; --- 228,231 ---- *************** *** 235,247 **** node_metatype_map node_metatype_map_; script_node_metatype script_node_metatype_; boost::scoped_ptr<scene> scene_; const boost::intrusive_ptr<node> default_viewpoint_; viewpoint_node * active_viewpoint_; const boost::intrusive_ptr<node> default_navigation_info_; navigation_info_node * active_navigation_info_; ! std::list<viewpoint_node *> viewpoint_list; ! std::list<scoped_light_node *> scoped_lights; ! std::list<script_node *> scripts; ! std::list<time_dependent_node *> timers; read_write_mutex listeners_mutex_; --- 234,263 ---- node_metatype_map node_metatype_map_; script_node_metatype script_node_metatype_; + resource_fetcher & fetcher_; + + mutable read_write_mutex scene_mutex_; boost::scoped_ptr<scene> scene_; + const boost::intrusive_ptr<node> default_viewpoint_; + + mutable read_write_mutex active_viewpoint_mutex_; viewpoint_node * active_viewpoint_; + const boost::intrusive_ptr<node> default_navigation_info_; + + mutable read_write_mutex active_navigation_info_mutex_; navigation_info_node * active_navigation_info_; ! ! mutable read_write_mutex viewpoint_list_mutex_; ! std::list<viewpoint_node *> viewpoint_list_; ! ! read_write_mutex scoped_lights_mutex_; ! std::list<scoped_light_node *> scoped_lights_; ! ! read_write_mutex scripts_mutex_; ! std::list<script_node *> scripts_; ! ! read_write_mutex timers_mutex_; ! std::list<time_dependent_node *> timers_; read_write_mutex listeners_mutex_; *************** *** 249,253 **** --- 265,273 ---- bool new_view; + + mutable read_write_mutex delta_time_mutex_; double delta_time; + + mutable read_write_mutex viewer_mutex_; openvrml::viewer * viewer_; *************** *** 255,259 **** mutable read_write_mutex modified_mutex_; ! resource_fetcher & fetcher_; mutable boost::mutex out_mutex_; --- 275,280 ---- mutable read_write_mutex modified_mutex_; ! mutable read_write_mutex frame_rate_mutex_; ! double frame_rate_; mutable boost::mutex out_mutex_; *************** *** 263,269 **** std::ostream * const err_; - protected: - double frame_rate_; - public: static double current_time() OPENVRML_NOTHROW; --- 284,287 ---- *************** *** 298,303 **** OPENVRML_THROW1(std::bad_alloc); void remove_viewpoint(viewpoint_node & viewpoint) OPENVRML_NOTHROW; ! const std::list<viewpoint_node *> & viewpoints() const ! OPENVRML_NOTHROW; void viewer(openvrml::viewer * v) OPENVRML_THROW1(viewer_in_use); openvrml::viewer * viewer() const OPENVRML_NOTHROW; --- 316,320 ---- OPENVRML_THROW1(std::bad_alloc); void remove_viewpoint(viewpoint_node & viewpoint) OPENVRML_NOTHROW; ! const std::list<viewpoint_node *> viewpoints() const OPENVRML_NOTHROW; void viewer(openvrml::viewer * v) OPENVRML_THROW1(viewer_in_use); openvrml::viewer * viewer() const OPENVRML_NOTHROW; |