|
From: <br...@us...> - 2009-06-22 06:25:01
|
Revision: 3923
http://openvrml.svn.sourceforge.net/openvrml/?rev=3923&view=rev
Author: braden
Date: 2009-06-22 06:24:57 +0000 (Mon, 22 Jun 2009)
Log Message:
-----------
Use boost::shared_mutex instead of openvrml::read_write_mutex.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/libopenvrml/openvrml/browser.cpp
trunk/src/libopenvrml/openvrml/browser.h
trunk/src/libopenvrml/openvrml/event.cpp
trunk/src/libopenvrml/openvrml/event.h
trunk/src/libopenvrml/openvrml/field_value.cpp
trunk/src/libopenvrml/openvrml/field_value.h
trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.h
trunk/src/libopenvrml/openvrml/node.cpp
trunk/src/libopenvrml/openvrml/node.h
trunk/src/libopenvrml/openvrml/scene.cpp
trunk/src/libopenvrml/openvrml/scene.h
trunk/src/libopenvrml-control/openvrml_control/browser.cpp
trunk/src/libopenvrml-control/openvrml_control/browser.h
trunk/src/node/vrml97/image_stream_listener.cpp
trunk/src/node/vrml97/image_stream_listener.h
trunk/src/node/vrml97/image_texture.cpp
Removed Paths:
-------------
trunk/src/libopenvrml/openvrml/read_write_mutex.cpp
trunk/src/libopenvrml/openvrml/read_write_mutex.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/ChangeLog 2009-06-22 06:24:57 UTC (rev 3923)
@@ -1,3 +1,30 @@
+2009-06-22 Braden McDaniel <br...@en...>
+
+ Use boost::shared_mutex instead of openvrml::read_write_mutex.
+
+ * src/Makefile.am
+ (openvrml_include_HEADERS): Removed read_write_mutex.h.
+ (libopenvrml_libopenvrml_la_SOURCES): Removed read_write_mutex.cpp.
+ * src/libopenvrml/openvrml/browser.cpp
+ * src/libopenvrml/openvrml/browser.h
+ * src/libopenvrml/openvrml/event.cpp
+ * src/libopenvrml/openvrml/event.h
+ * src/libopenvrml/openvrml/field_value.cpp
+ * src/libopenvrml/openvrml/field_value.h
+ * src/libopenvrml/openvrml/node.cpp
+ * src/libopenvrml/openvrml/node.h
+ * src/libopenvrml/openvrml/read_write_mutex.cpp: Removed.
+ * src/libopenvrml/openvrml/read_write_mutex.h: Removed.
+ * src/libopenvrml/openvrml/scene.cpp
+ * src/libopenvrml/openvrml/scene.h
+ * src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
+ * src/libopenvrml/openvrml/local/node_metatype_registry_impl.h
+ * src/libopenvrml-control/openvrml_control/browser.cpp
+ * src/libopenvrml-control/openvrml_control/browser.h
+ * src/node/vrml97/image_stream_listener.cpp
+ * src/node/vrml97/image_stream_listener.h
+ * src/node/vrml97/image_texture.cpp
+
2009-06-21 Braden McDaniel <br...@en...>
The Web browser still wants the plug-in to have the NPN_* entry
@@ -16,7 +43,7 @@
(NPN_NewStream(NPP, NPMIMEType, const char *, NPStream **)):
Replaced.
(NPN_Write(NPP, NPStream *, int32, void *)): Replaced.
- (NPN_DestryStream(NPP, NPStream *, NPError)): Replaced.
+ (NPN_DestroyStream(NPP, NPStream *, NPError)): Replaced.
(NPN_Status(NPP, const char *)): Replaced.
(NPN_UserAgent(NPP)): Replaced.
(NPN_MemAlloc(uint32)): Replaced.
@@ -85,7 +112,7 @@
(NPN_NewStream(NPP, NPMIMEType, const char *, NPStream **)):
Removed.
(NPN_Write(NPP, NPStream *, int32, void *)): Removed.
- (NPN_DestryStream(NPP, NPStream *, NPError)): Removed.
+ (NPN_DestroyStream(NPP, NPStream *, NPError)): Removed.
(NPN_Status(NPP, const char *)): Removed.
(NPN_UserAgent(NPP)): Removed.
(NPN_MemAlloc(uint32)): Removed.
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/Makefile.am 2009-06-22 06:24:57 UTC (rev 3923)
@@ -23,7 +23,6 @@
libopenvrml/openvrml/basetypes.h \
libopenvrml/openvrml/vrml97_grammar.h \
libopenvrml/openvrml/x3d_vrml_grammar.h \
- libopenvrml/openvrml/read_write_mutex.h \
libopenvrml/openvrml/field_value.h \
libopenvrml/openvrml/event.h \
libopenvrml/openvrml/exposedfield.h \
@@ -81,7 +80,6 @@
libopenvrml/openvrml/bad_url.cpp \
libopenvrml/openvrml/vrml97_grammar.cpp \
libopenvrml/openvrml/x3d_vrml_grammar.cpp \
- libopenvrml/openvrml/read_write_mutex.cpp \
libopenvrml/openvrml/basetypes.cpp \
libopenvrml/openvrml/field_value.cpp \
libopenvrml/openvrml/event.cpp \
Modified: trunk/src/libopenvrml/openvrml/browser.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/browser.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/browser.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -1107,7 +1107,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::load_root_scene_thread_mutex_
+ * @var boost::shared_mutex openvrml::browser::load_root_scene_thread_mutex_
*
* @brief Mutex protecting @c #load_root_scene_thread_.
*/
@@ -1153,7 +1153,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::scene_mutex_
+ * @var boost::shared_mutex openvrml::browser::scene_mutex_
*
* @brief Mutex protecting @c #scene_.
*/
@@ -1178,7 +1178,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::active_viewpoint_mutex_
+ * @var boost::shared_mutex openvrml::browser::active_viewpoint_mutex_
*
* @brief Mutex protecting @c #active_viewpoint_.
*/
@@ -1203,7 +1203,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::active_navigation_info_mutex_
+ * @var boost::shared_mutex openvrml::browser::active_navigation_info_mutex_
*
* @brief Mutex protecting @c #active_navigation_info_.
*/
@@ -1219,7 +1219,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::viewpoint_list_mutex_
+ * @var boost::shared_mutex openvrml::browser::viewpoint_list_mutex_
*
* @brief Mutex protecting @c #viewpoint_list_.
*/
@@ -1235,7 +1235,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::scoped_lights_mutex_
+ * @var boost::shared_mutex openvrml::browser::scoped_lights_mutex_
*
* @brief Mutex protecting @c #scoped_lights_.
*/
@@ -1251,7 +1251,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::scripts_mutex_
+ * @var boost::shared_mutex openvrml::browser::scripts_mutex_
*
* @brief Mutex protecting @c #scripts_.
*/
@@ -1267,7 +1267,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::timers_mutex_
+ * @var boost::shared_mutex openvrml::browser::timers_mutex_
*
* @brief Mutex protecting @c #timers_.
*/
@@ -1307,7 +1307,7 @@
*/
/**
- * @var openvrml::read_write_mutex openvrml::browser::modified_mutex_
+ * @var boost::shared_mutex openvrml::browser::modified_mutex_
*
* @brief Mutex protecting @c #modified_.
*/
@@ -1323,7 +1323,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::delta_time_mutex_
+ * @var boost::shared_mutex openvrml::browser::delta_time_mutex_
*
* @brief Mutex protecting @c #delta_time.
*/
@@ -1339,7 +1339,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::viewer_mutex_
+ * @var boost::shared_mutex openvrml::browser::viewer_mutex_
*
* @brief Mutex protecting @c #viewer_.
*/
@@ -1355,7 +1355,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::browser::frame_rate_mutex_
+ * @var boost::shared_mutex openvrml::browser::frame_rate_mutex_
*
* @brief Mutex protecting @c #frame_rate_.
*/
@@ -1468,8 +1468,10 @@
*/
openvrml::browser::~browser() OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock
- lock(this->load_root_scene_thread_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+
+ shared_lock<shared_mutex> lock(this->load_root_scene_thread_mutex_);
if (this->load_root_scene_thread_) {
this->load_root_scene_thread_->join();
}
@@ -1478,7 +1480,7 @@
const double now = browser::current_time();
- read_write_mutex::scoped_read_lock scene_lock(this->scene_mutex_);
+ shared_lock<shared_mutex> scene_lock(this->scene_mutex_);
if (this->scene_) { this->scene_->shutdown(now); }
this->node_metatype_registry_->impl_->shutdown(now);
@@ -1536,7 +1538,9 @@
*/
openvrml::scene * openvrml::browser::root_scene() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
return this->scene_.get();
}
@@ -1554,7 +1558,9 @@
const openvrml::node_path openvrml::browser::find_node(const node & n) const
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
assert(this->scene_);
class FindNodeTraverser : public node_traverser {
@@ -1600,7 +1606,9 @@
openvrml::viewpoint_node & openvrml::browser::active_viewpoint() const
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->active_viewpoint_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->active_viewpoint_mutex_);
return *this->active_viewpoint_;
}
@@ -1614,8 +1622,11 @@
void openvrml::browser::active_viewpoint(viewpoint_node & viewpoint)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock scene_lock(this->scene_mutex_);
- read_write_mutex::scoped_write_lock
+ using boost::unique_lock;
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> scene_lock(this->scene_mutex_);
+ unique_lock<shared_mutex>
active_viewpoint_lock(this->active_viewpoint_mutex_);
# ifndef NDEBUG
scene * root_scene = 0;
@@ -1633,7 +1644,9 @@
*/
void openvrml::browser::reset_default_viewpoint() OPENVRML_NOTHROW
{
- read_write_mutex::scoped_write_lock lock(this->active_viewpoint_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->active_viewpoint_mutex_);
assert(this->default_viewpoint_);
this->active_viewpoint_ =
node_cast<viewpoint_node *>(this->default_viewpoint_.get());
@@ -1651,8 +1664,9 @@
openvrml::navigation_info_node &
openvrml::browser::active_navigation_info() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock
- lock(this->active_navigation_info_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->active_navigation_info_mutex_);
return *this->active_navigation_info_;
}
@@ -1666,8 +1680,11 @@
void openvrml::browser::active_navigation_info(navigation_info_node & nav_info)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock scene_lock(this->scene_mutex_);
- read_write_mutex::scoped_write_lock
+ using boost::unique_lock;
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> scene_lock(this->scene_mutex_);
+ unique_lock<shared_mutex>
active_navigation_info_lock(this->active_navigation_info_mutex_);
# ifndef NDEBUG
scene * root_scene = 0;
@@ -1685,8 +1702,9 @@
*/
void openvrml::browser::reset_default_navigation_info() OPENVRML_NOTHROW
{
- read_write_mutex::scoped_write_lock
- lock(this->active_navigation_info_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->active_navigation_info_mutex_);
assert(this->default_navigation_info_);
this->active_navigation_info_ =
node_cast<navigation_info_node *>(
@@ -1708,7 +1726,9 @@
void openvrml::browser::add_viewpoint(viewpoint_node & viewpoint)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_write_lock lock(this->viewpoint_list_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> 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);
@@ -1725,7 +1745,9 @@
void openvrml::browser::remove_viewpoint(viewpoint_node & viewpoint)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_write_lock lock(this->viewpoint_list_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> 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();
@@ -1743,7 +1765,9 @@
const std::list<openvrml::viewpoint_node *>
openvrml::browser::viewpoints() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->viewpoint_list_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->viewpoint_list_mutex_);
return this->viewpoint_list_;
}
@@ -1758,7 +1782,9 @@
void openvrml::browser::viewer(openvrml::viewer * v)
OPENVRML_THROW1(viewer_in_use)
{
- read_write_mutex::scoped_write_lock lock(this->viewer_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->viewer_mutex_);
if (v && v->browser_) { throw viewer_in_use(); }
if (this->viewer_) { this->viewer_->browser_ = 0; }
this->viewer_ = v;
@@ -1772,7 +1798,9 @@
*/
openvrml::viewer * openvrml::browser::viewer() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->viewer_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->viewer_mutex_);
return this->viewer_;
}
@@ -1807,8 +1835,9 @@
*/
float openvrml::browser::current_speed()
{
- read_write_mutex::scoped_read_lock
- lock(this->active_navigation_info_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->active_navigation_info_mutex_);
navigation_info_node & nav_info = this->active_navigation_info();
return nav_info.speed();
}
@@ -1821,7 +1850,9 @@
const std::string openvrml::browser::world_url() const
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
assert(this->scene_);
return this->scene_->url(); // Throws std::bad_alloc.
}
@@ -1838,12 +1869,16 @@
void openvrml::browser::set_world(resource_istream & in)
{
using std::for_each;
+ using boost::shared_lock;
+ using boost::shared_mutex;
{
- read_write_mutex::scoped_read_write_lock scene_lock(this->scene_mutex_);
-
using std::string;
+ using boost::upgrade_lock;
+ using boost::upgrade_to_unique_lock;
using local::uri;
+ upgrade_lock<shared_mutex> scene_lock(this->scene_mutex_);
+
//
// Clear out the current scene.
//
@@ -1851,29 +1886,29 @@
double now = browser::current_time();
if (this->scene_) { this->scene_->shutdown(now); }
this->node_metatype_registry_->impl_->shutdown(now);
- read_write_mutex::scoped_read_lock
- listeners_lock(this->listeners_mutex_);
+ shared_lock<shared_mutex> listeners_lock(this->listeners_mutex_);
for_each(this->listeners_.begin(), this->listeners_.end(),
boost::bind2nd(
boost::mem_fun(&browser_listener::browser_changed),
browser_event(*this, browser_event::shutdown)));
- scene_lock.promote();
+ {
+ upgrade_to_unique_lock<shared_mutex> scene_write_lock(scene_lock);
- this->scene_.reset();
- assert(this->viewpoint_list_.empty());
- assert(this->scoped_lights_.empty());
- assert(this->scripts_.empty());
- assert(this->timers_.empty());
+ this->scene_.reset();
+ assert(this->viewpoint_list_.empty());
+ assert(this->scoped_lights_.empty());
+ assert(this->scripts_.empty());
+ assert(this->timers_.empty());
- //
- // Create the new scene.
- //
- this->node_metatype_registry_.reset(new node_metatype_registry(*this));
- this->scene_.reset(new scene(*this));
+ //
+ // Create the new scene.
+ //
+ this->node_metatype_registry_.reset(
+ new node_metatype_registry(*this));
+ this->scene_.reset(new scene(*this));
+ }
- scene_lock.demote();
-
this->scene_->load(in);
//
@@ -1904,8 +1939,8 @@
this->node_metatype_registry_->impl_->init(initial_viewpoint, now);
if (!this->active_viewpoint_) {
- read_write_mutex::scoped_write_lock
- lock(this->active_viewpoint_mutex_);
+ using boost::unique_lock;
+ unique_lock<shared_mutex> lock(this->active_viewpoint_mutex_);
this->active_viewpoint_ = this->default_viewpoint_.get();
}
@@ -1913,8 +1948,7 @@
this->new_view = true; // Force resetUserNav
} // unlock this->scene_mutex_, this->active_viewpoint_mutex_
- read_write_mutex::scoped_read_lock
- listeners_lock(this->listeners_mutex_);
+ shared_lock<shared_mutex> listeners_lock(this->listeners_mutex_);
for_each(this->listeners_.begin(), this->listeners_.end(),
boost::bind2nd(boost::mem_fun(&browser_listener::browser_changed),
browser_event(*this, browser_event::initialized)));
@@ -1929,7 +1963,9 @@
openvrml::browser::replace_world(
const std::vector<boost::intrusive_ptr<node> > & nodes)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
const double now = browser::current_time();
this->scene_->nodes(nodes);
this->scene_->initialize(now);
@@ -1959,8 +1995,9 @@
try {
std::auto_ptr<resource_istream> in;
{
- read_write_mutex::scoped_read_lock
- lock(browser.scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(browser.scene_mutex_);
in = browser.scene_->get_resource(this->url_);
}
if (!(*in)) { throw unreachable_url(); }
@@ -2008,9 +2045,12 @@
const std::vector<std::string> &)
OPENVRML_THROW2(std::bad_alloc, boost::thread_resource_error)
{
+ using boost::unique_lock;
+ using boost::shared_mutex;
+
{
- read_write_mutex::scoped_read_lock
- lock(this->load_root_scene_thread_mutex_);
+ using boost::shared_lock;
+ shared_lock<shared_mutex> lock(this->load_root_scene_thread_mutex_);
if (this->load_root_scene_thread_) {
this->load_root_scene_thread_->join();
}
@@ -2018,8 +2058,7 @@
boost::function0<void> f = root_scene_loader(*this, url);
- read_write_mutex::scoped_write_lock
- lock(this->load_root_scene_thread_mutex_);
+ unique_lock<shared_mutex> lock(this->load_root_scene_thread_mutex_);
this->load_root_scene_thread_.reset(new boost::thread(f));
}
@@ -2086,7 +2125,9 @@
std::vector<boost::intrusive_ptr<node> > nodes;
try {
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
assert(this->scene_);
std::map<string, string> meta;
local::parse_vrml(in, stream_id.str(), type,
@@ -2125,7 +2166,9 @@
OPENVRML_THROW3(unsupported_interface, std::bad_cast,
boost::thread_resource_error)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
assert(this->scene_);
this->scene_->create_vrml_from_url(url, node, event);
}
@@ -2144,7 +2187,9 @@
bool openvrml::browser::add_listener(browser_listener & listener)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_write_lock lock(this->listeners_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->listeners_mutex_);
return this->listeners_.insert(&listener).second;
}
@@ -2160,7 +2205,9 @@
bool openvrml::browser::remove_listener(browser_listener & listener)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_write_lock lock(this->listeners_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->listeners_mutex_);
return this->listeners_.erase(&listener) > 0;
}
@@ -2171,7 +2218,9 @@
*/
double openvrml::browser::frame_rate() const
{
- read_write_mutex::scoped_read_lock lock(this->frame_rate_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->frame_rate_mutex_);
return this->frame_rate_;
}
@@ -2216,8 +2265,10 @@
bool openvrml::browser::update(double current_time)
{
using std::for_each;
+ using boost::shared_lock;
+ using boost::shared_mutex;
- read_write_mutex::scoped_read_lock
+ shared_lock<shared_mutex>
timers_lock(this->timers_mutex_),
scripts_lock(this->scripts_mutex_);
@@ -2259,7 +2310,10 @@
*/
void openvrml::browser::render()
{
- read_write_mutex::scoped_read_lock
+ using boost::shared_lock;
+ using boost::shared_mutex;
+
+ shared_lock<shared_mutex>
scene_lock(this->scene_mutex_),
active_viewpoint_lock_(this->active_viewpoint_mutex_);
@@ -2322,7 +2376,7 @@
// Do the browser-level lights (Points and Spots)
{
using std::for_each;
- read_write_mutex::scoped_read_lock
+ shared_lock<shared_mutex>
scoped_lights_lock(this->scoped_lights_mutex_);
for_each(this->scoped_lights_.begin(), this->scoped_lights_.end(),
boost::bind2nd(
@@ -2340,8 +2394,7 @@
this->viewer_->end_object();
// This is actually one frame late...
- read_write_mutex::scoped_write_lock
- frame_rate_lock(this->frame_rate_mutex_);
+ boost::unique_lock<shared_mutex> frame_rate_lock(this->frame_rate_mutex_);
this->frame_rate_ = this->viewer_->frame_rate();
this->modified(false);
@@ -2356,7 +2409,9 @@
*/
void openvrml::browser::modified(const bool value)
{
- read_write_mutex::scoped_write_lock lock(this->modified_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->modified_mutex_);
this->modified_ = value;
}
@@ -2367,7 +2422,9 @@
*/
bool openvrml::browser::modified() const
{
- read_write_mutex::scoped_read_lock lock(this->modified_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->modified_mutex_);
return this->modified_;
}
@@ -2378,7 +2435,9 @@
*/
void openvrml::browser::delta(const double d)
{
- read_write_mutex::scoped_write_lock lock(this->delta_time_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->delta_time_mutex_);
if (d < this->delta_time) { this->delta_time = d; }
}
@@ -2389,7 +2448,9 @@
*/
double openvrml::browser::delta() const
{
- read_write_mutex::scoped_read_lock lock(this->delta_time_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->delta_time_mutex_);
return this->delta_time;
}
@@ -2403,7 +2464,9 @@
void
openvrml::browser::add_scoped_light(scoped_light_node & light)
{
- read_write_mutex::scoped_write_lock lock(this->scoped_lights_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> 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);
@@ -2419,7 +2482,9 @@
void
openvrml::browser::remove_scoped_light(scoped_light_node & light)
{
- read_write_mutex::scoped_write_lock lock(this->scoped_lights_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->scoped_lights_mutex_);
assert(!this->scoped_lights_.empty());
const std::list<scoped_light_node *>::iterator end =
this->scoped_lights_.end();
@@ -2438,7 +2503,9 @@
*/
void openvrml::browser::add_script(script_node & script)
{
- read_write_mutex::scoped_write_lock lock(this->scripts_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->scripts_mutex_);
assert(std::find(this->scripts_.begin(), this->scripts_.end(), &script)
== this->scripts_.end());
this->scripts_.push_back(&script);
@@ -2453,7 +2520,9 @@
*/
void openvrml::browser::remove_script(script_node & script)
{
- read_write_mutex::scoped_write_lock lock(this->scripts_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> 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();
@@ -2472,7 +2541,9 @@
*/
void openvrml::browser::add_time_dependent(time_dependent_node & n)
{
- read_write_mutex::scoped_write_lock lock(this->timers_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->timers_mutex_);
assert(std::find(this->timers_.begin(), this->timers_.end(), &n)
== this->timers_.end());
this->timers_.push_back(&n);
@@ -2488,7 +2559,9 @@
void
openvrml::browser::remove_time_dependent(time_dependent_node & n)
{
- read_write_mutex::scoped_write_lock lock(this->timers_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> 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 =
Modified: trunk/src/libopenvrml/openvrml/browser.h
===================================================================
--- trunk/src/libopenvrml/openvrml/browser.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/browser.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -221,54 +221,54 @@
const boost::scoped_ptr<null_node_metatype> null_node_metatype_;
const boost::scoped_ptr<null_node_type> null_node_type_;
- read_write_mutex load_root_scene_thread_mutex_;
+ boost::shared_mutex load_root_scene_thread_mutex_;
boost::scoped_ptr<boost::thread> load_root_scene_thread_;
boost::thread_group load_proto_thread_group_;
script_node_metatype script_node_metatype_;
resource_fetcher & fetcher_;
- mutable read_write_mutex scene_mutex_;
+ mutable boost::shared_mutex scene_mutex_;
boost::scoped_ptr<scene> scene_;
const boost::intrusive_ptr<viewpoint_node> default_viewpoint_;
- mutable read_write_mutex active_viewpoint_mutex_;
+ mutable boost::shared_mutex active_viewpoint_mutex_;
viewpoint_node * active_viewpoint_;
const boost::intrusive_ptr<navigation_info_node>
default_navigation_info_;
- mutable read_write_mutex active_navigation_info_mutex_;
+ mutable boost::shared_mutex active_navigation_info_mutex_;
navigation_info_node * active_navigation_info_;
- mutable read_write_mutex viewpoint_list_mutex_;
+ mutable boost::shared_mutex viewpoint_list_mutex_;
std::list<viewpoint_node *> viewpoint_list_;
- read_write_mutex scoped_lights_mutex_;
+ boost::shared_mutex scoped_lights_mutex_;
std::list<scoped_light_node *> scoped_lights_;
- read_write_mutex scripts_mutex_;
+ boost::shared_mutex scripts_mutex_;
std::list<script_node *> scripts_;
- read_write_mutex timers_mutex_;
+ boost::shared_mutex timers_mutex_;
std::list<time_dependent_node *> timers_;
- read_write_mutex listeners_mutex_;
+ boost::shared_mutex listeners_mutex_;
std::set<browser_listener *> listeners_;
bool new_view;
- mutable read_write_mutex delta_time_mutex_;
+ mutable boost::shared_mutex delta_time_mutex_;
double delta_time;
- mutable read_write_mutex viewer_mutex_;
+ mutable boost::shared_mutex viewer_mutex_;
openvrml::viewer * viewer_;
bool modified_;
- mutable read_write_mutex modified_mutex_;
+ mutable boost::shared_mutex modified_mutex_;
- mutable read_write_mutex frame_rate_mutex_;
+ mutable boost::shared_mutex frame_rate_mutex_;
double frame_rate_;
mutable boost::mutex out_mutex_;
Modified: trunk/src/libopenvrml/openvrml/event.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/event.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/event.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -437,7 +437,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::event_emitter::listeners_mutex_
+ * @var boost::shared_mutex openvrml::event_emitter::listeners_mutex_
*
* @brief Mutex guarding @c #listeners_.
*/
@@ -453,7 +453,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::event_emitter::last_time_mutex_
+ * @var boost::shared_mutex openvrml::event_emitter::last_time_mutex_
*
* @brief Mutex guarding @c #last_time_.
*/
@@ -516,7 +516,9 @@
*/
double openvrml::event_emitter::last_time() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->last_time_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->last_time_mutex_);
return this->last_time_;
}
Modified: trunk/src/libopenvrml/openvrml/event.h
===================================================================
--- trunk/src/libopenvrml/openvrml/event.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/event.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -163,10 +163,10 @@
const field_value & value_;
std::set<event_listener *> listeners_;
- mutable read_write_mutex listeners_mutex_;
+ mutable boost::shared_mutex listeners_mutex_;
double last_time_;
- mutable read_write_mutex last_time_mutex_;
+ mutable boost::shared_mutex last_time_mutex_;
public:
typedef std::set<event_listener *> listener_set;
@@ -200,7 +200,9 @@
bool event_emitter::add(field_value_listener<FieldValue> & listener)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_write_lock lock(this->listeners_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->listeners_mutex_);
return this->listeners_.insert(&listener).second;
}
@@ -208,7 +210,9 @@
bool event_emitter::remove(field_value_listener<FieldValue> & listener)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_write_lock lock(this->listeners_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->listeners_mutex_);
return (this->listeners_.erase(&listener) > 0);
}
@@ -216,10 +220,10 @@
void event_emitter::emit_event(const double timestamp)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_lock
- listeners_lock(this->listeners_mutex_);
- read_write_mutex::scoped_write_lock
- last_time_lock(this->last_time_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> listeners_lock(this->listeners_mutex_);
+ shared_lock<shared_mutex> last_time_lock(this->last_time_mutex_);
for (typename listener_set::iterator listener =
this->listeners_.begin();
listener != this->listeners_.end();
Modified: trunk/src/libopenvrml/openvrml/field_value.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/field_value.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/field_value.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -114,9 +114,9 @@
*/
/**
- * @var boost::mutex openvrml::field_value::counted_impl::mutex_
+ * @var boost::shared_mutex openvrml::field_value::counted_impl::mutex_
*
- * @brief Mutex protecting @a value_.
+ * @brief Mutex protecting @c #value_.
*/
/**
Modified: trunk/src/libopenvrml/openvrml/field_value.h
===================================================================
--- trunk/src/libopenvrml/openvrml/field_value.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/field_value.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -31,8 +31,8 @@
# include <boost/scoped_ptr.hpp>
# include <boost/shared_ptr.hpp>
# include <boost/utility.hpp>
+# include <boost/thread/shared_mutex.hpp>
# include <openvrml/basetypes.h>
-# include <openvrml/read_write_mutex.h>
namespace openvrml {
@@ -59,7 +59,7 @@
template <typename ValueType>
class counted_impl : public counted_impl_base {
- mutable read_write_mutex mutex_;
+ mutable boost::shared_mutex mutex_;
boost::shared_ptr<ValueType> value_;
public:
@@ -175,7 +175,9 @@
counted_impl(const counted_impl<ValueType> & ci) OPENVRML_NOTHROW:
counted_impl_base()
{
- read_write_mutex::scoped_read_lock lock(ci.mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(ci.mutex_);
value_ = ci.value_;
}
@@ -187,7 +189,9 @@
const ValueType & field_value::counted_impl<ValueType>::value() const
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
assert(this->value_);
return *this->value_;
}
@@ -196,7 +200,9 @@
void field_value::counted_impl<ValueType>::value(const ValueType & val)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_write_lock lock(this->mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->mutex_);
assert(this->value_);
if (!this->value_.unique()) {
this->value_.reset(new ValueType(val));
Modified: trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -175,11 +175,14 @@
const boost::shared_ptr<node_metatype> & metatype)
OPENVRML_THROW2(std::invalid_argument, std::bad_alloc)
{
+ using boost::unique_lock;
+ using boost::shared_mutex;
+
if (!metatype.get()) {
throw std::invalid_argument(
"cannot register null node_metatype pointer");
}
- read_write_mutex::scoped_write_lock lock(this->mutex_);
+ unique_lock<shared_mutex> lock(this->mutex_);
this->node_metatype_map_[id] = metatype;
}
@@ -221,7 +224,9 @@
openvrml::local::node_metatype_registry_impl::
init(viewpoint_node * initial_viewpoint, const double timestamp)
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
std::for_each(this->node_metatype_map_.begin(),
this->node_metatype_map_.end(),
init_node_metatype(initial_viewpoint, timestamp));
@@ -238,7 +243,9 @@
const boost::shared_ptr<openvrml::node_metatype>
openvrml::local::node_metatype_registry_impl::find(const std::string & id) const
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
const node_metatype_map_t::const_iterator pos =
this->node_metatype_map_.find(id);
return (pos != this->node_metatype_map_.end())
@@ -258,7 +265,9 @@
node_metatype_ids(const openvrml::node_metatype & node_metatype) const
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
std::vector<node_metatype_id> ids;
for (node_metatype_map_t::const_iterator entry =
this->node_metatype_map_.begin();
@@ -297,7 +306,9 @@
void openvrml::local::node_metatype_registry_impl::
render(openvrml::viewer & v)
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
std::for_each(this->node_metatype_map_.begin(),
this->node_metatype_map_.end(),
render_node_metatype(v));
@@ -330,7 +341,9 @@
openvrml::local::node_metatype_registry_impl::shutdown(const double timestamp)
OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->mutex_);
std::for_each(this->node_metatype_map_.begin(),
this->node_metatype_map_.end(),
shutdown_node_metatype(timestamp));
Modified: trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.h
===================================================================
--- trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/local/node_metatype_registry_impl.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -38,7 +38,7 @@
class OPENVRML_LOCAL node_metatype_registry_impl : boost::noncopyable {
friend int (::openvrml_open_node_module)(const char * filename,
void * data);
- mutable read_write_mutex mutex_;
+ mutable boost::shared_mutex mutex_;
openvrml::browser & browser_;
Modified: trunk/src/libopenvrml/openvrml/node.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/node.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/node.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -1890,7 +1890,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::node::scene_mutex_
+ * @var boost::shared_mutex openvrml::node::scene_mutex_
*
* @brief Mutex protecting @c #scene_.
*/
@@ -1906,7 +1906,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::node::modified_mutex_
+ * @var boost::shared_mutex openvrml::node::modified_mutex_
*
* @brief Mutex protecting @c #modified_.
*/
@@ -2118,7 +2118,9 @@
*/
openvrml::scene * openvrml::node::scene() const OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex_);
return this->scene_;
}
@@ -2169,11 +2171,16 @@
const double timestamp)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_write_lock lock(this->scene_mutex_);
+ using boost::upgrade_lock;
+ using boost::shared_mutex;
+
+ upgrade_lock<shared_mutex> lock(this->scene_mutex_);
+
if (!this->scene_) {
- lock.promote();
- this->scene_ = &scene;
- lock.demote();
+ {
+ boost::upgrade_to_unique_lock<shared_mutex> upgraded_lock(lock);
+ this->scene_ = &scene;
+ }
this->do_initialize(timestamp);
const node_interface_set & interfaces = this->type_.interfaces();
@@ -2312,12 +2319,17 @@
*/
void openvrml::node::shutdown(const double timestamp) OPENVRML_NOTHROW
{
- read_write_mutex::scoped_read_write_lock lock(this->scene_mutex_);
+ using boost::upgrade_lock;
+ using boost::shared_mutex;
+
+ upgrade_lock<shared_mutex> lock(this->scene_mutex_);
+
if (this->scene_) {
this->do_shutdown(timestamp);
- lock.promote();
- this->scene_ = 0;
- lock.demote();
+ {
+ boost::upgrade_to_unique_lock<shared_mutex> upgraded_lock(lock);
+ this->scene_ = 0;
+ }
const node_interface_set & interfaces = this->type_.interfaces();
for (node_interface_set::const_iterator interface_(interfaces.begin());
@@ -2705,7 +2717,9 @@
void openvrml::node::modified(const bool value)
OPENVRML_THROW1(boost::thread_resource_error)
{
- read_write_mutex::scoped_write_lock lock(this->modified_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->modified_mutex_);
this->modified_ = value;
if (this->modified_) { this->type_.metatype().browser().modified(true); }
}
@@ -2725,7 +2739,9 @@
bool openvrml::node::modified() const
OPENVRML_THROW1(boost::thread_resource_error)
{
- read_write_mutex::scoped_read_lock lock(this->modified_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->modified_mutex_);
return this->modified_ || this->do_modified();
}
@@ -2766,7 +2782,7 @@
*
* @return the @c scene mutex.
*/
-openvrml::read_write_mutex & openvrml::node::scene_mutex()
+boost::shared_mutex & openvrml::node::scene_mutex()
{
return this->scene_mutex_;
}
@@ -3309,7 +3325,9 @@
void openvrml::appearance_node::render_appearance(viewer & v,
rendering_context context)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (this->scene()) {
this->do_render_appearance(v, context);
this->modified(false);
@@ -3407,7 +3425,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::bounded_volume_node::bounding_volume_dirty_mutex_
+ * @var boost::shared_mutex openvrml::bounded_volume_node::bounding_volume_dirty_mutex_
*
* @brief Mutex protecting @c #bounding_volume_dirty_.
*/
@@ -3457,9 +3475,10 @@
const openvrml::bounding_volume &
openvrml::bounded_volume_node::bounding_volume() const
{
+ using boost::unique_lock;
+ using boost::shared_mutex;
const openvrml::bounding_volume & bv = this->do_bounding_volume();
- read_write_mutex::scoped_write_lock
- lock(this->bounding_volume_dirty_mutex_);
+ unique_lock<shared_mutex> lock(this->bounding_volume_dirty_mutex_);
this->bounding_volume_dirty_ = false;
return bv;
}
@@ -3497,8 +3516,9 @@
*/
void openvrml::bounded_volume_node::bounding_volume_dirty(const bool value)
{
- read_write_mutex::scoped_write_lock
- lock(this->bounding_volume_dirty_mutex_);
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex> lock(this->bounding_volume_dirty_mutex_);
this->bounding_volume_dirty_ = value;
if (value) { // only if dirtying, not clearing
this->type().metatype().browser().flags_need_updating = true;
@@ -3513,8 +3533,9 @@
*/
bool openvrml::bounded_volume_node::bounding_volume_dirty() const
{
- read_write_mutex::scoped_read_lock
- lock(this->bounding_volume_dirty_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->bounding_volume_dirty_mutex_);
if (this->type().metatype().browser().flags_need_updating) {
this->type().metatype().browser().update_flags();
this->type().metatype().browser().flags_need_updating = false;
@@ -3611,7 +3632,9 @@
void openvrml::child_node::render_child(viewer & v,
const rendering_context context)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (this->scene()) {
this->do_render_child(v, context);
this->modified(false);
@@ -4354,7 +4377,9 @@
void openvrml::geometry_node::render_geometry(viewer & v,
rendering_context context)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (!this->scene()) { return; }
@@ -5112,7 +5137,9 @@
*/
void openvrml::scoped_light_node::render_scoped_light(viewer & v)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (this->scene()) {
this->do_render_scoped_light(v);
}
@@ -5207,7 +5234,9 @@
*/
void openvrml::texture_node::render_texture(viewer & v)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (!this->scene()) { return; }
@@ -5397,7 +5426,9 @@
*/
void openvrml::texture_transform_node::render_texture_transform(viewer & v)
{
- read_write_mutex::scoped_read_lock lock(this->scene_mutex());
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->scene_mutex());
if (this->scene()) {
this->do_render_texture_transform(v);
this->modified(false);
Modified: trunk/src/libopenvrml/openvrml/node.h
===================================================================
--- trunk/src/libopenvrml/openvrml/node.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/node.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -522,10 +522,10 @@
const node_type & type_;
const boost::shared_ptr<openvrml::scope> scope_;
- mutable read_write_mutex scene_mutex_;
+ mutable boost::shared_mutex scene_mutex_;
openvrml::scene * scene_;
- mutable read_write_mutex modified_mutex_;
+ mutable boost::shared_mutex modified_mutex_;
bool modified_;
public:
@@ -590,7 +590,7 @@
const boost::shared_ptr<openvrml::scope> & scope)
OPENVRML_NOTHROW;
- read_write_mutex & scene_mutex();
+ boost::shared_mutex & scene_mutex();
private:
virtual
@@ -955,7 +955,7 @@
class OPENVRML_API bounded_volume_node : public virtual node {
- mutable read_write_mutex bounding_volume_dirty_mutex_;
+ mutable boost::shared_mutex bounding_volume_dirty_mutex_;
mutable bool bounding_volume_dirty_;
public:
Deleted: trunk/src/libopenvrml/openvrml/read_write_mutex.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/read_write_mutex.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/read_write_mutex.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -1,298 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*-
-//
-// OpenVRML
-//
-// Copyright 2007 Braden McDaniel
-//
-// This library is free software; you can redistribute it and/or modify it
-// under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or (at your
-// option) any later version.
-//
-// This library is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-// License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this library; if not, see <http://www.gnu.org/licenses/>.
-//
-
-# ifdef HAVE_CONFIG_H
-# include <config.h>
-# endif
-
-#include "read_write_mutex.h"
-#include <cassert>
-
-/**
- * @file openvrml/read_write_mutex.h
- *
- * @brief A read/write mutex.
- */
-
-/**
- * @class openvrml::read_write_mutex openvrml/read_write_mutex.h
- *
- * @brief A read/write mutex with an interface that follows the
- * patterns established in the Boost thread library.
- *
- * This read/write mutex is implemented in terms of @c boost::mutex
- * and @c boost::condition.
- */
-
-/**
- * @internal
- *
- * @var boost::mutex openvrml::read_write_mutex::mutex_
- *
- * @brief The underlying mutex.
- */
-
-/**
- * @internal
- *
- * @var boost::condition openvrml::read_write_mutex::read_
- *
- * @brief When writing is done, this condition is signaled to indicate
- * that readers can acquire the lock.
- */
-
-/**
- * @internal
- *
- * @var boost::condition openvrml::read_write_mutex::write_
- *
- * @brief When reading is done, this condition is signaled to indicate
- * that a writer can acquire the lock.
- */
-
-/**
- * @internal
- *
- * @var std::size_t openvrml::read_write_mutex::readers_active_
- *
- * @brief The number of readers currently sharing the lock.
- */
-
-/**
- * @internal
- *
- * @var std::size_t openvrml::read_write_mutex::readers_waiting_
- *
- * @brief The number of readers currently waiting for the lock.
- */
-
-/**
- * @internal
- *
- * @var std::size_t openvrml::read_write_mutex::writers_waiting_
- *
- * @brief The number of writers currently waiting for the lock.
- */
-
-/**
- * @internal
- *
- * @var bool openvrml::read_write_mutex::writing_
- *
- * @brief @c true if a writer has the lock; @c false otherwise.
- */
-
-/**
- * @class openvrml::read_write_mutex::scoped_read_lock openvrml/read_write_mutex.h
- *
- * @brief Lock the mutex for read access.
- */
-
-/**
- * @internal
- *
- * @var openvrml::read_write_mutex & openvrml::read_write_mutex::scoped_read_lock::mutex_
- *
- * @brief The @c read_write_mutex being locked.
- */
-
-/**
- * @internal
- *
- * @var boost::mutex::scoped_lock openvrml::read_write_mutex::scoped_read_lock::lock_
- *
- * @brief A lock for @c read_write_mutex::mutex_.
- */
-
-/**
- * @brief Construct.
- *
- * Acquire the lock.
- *
- * @param[in] mutex a @c read_write_mutex.
- */
-openvrml::read_write_mutex::scoped_read_lock::
-scoped_read_lock(read_write_mutex & mutex):
- mutex_(mutex),
- lock_(mutex.mutex_)
-{
- if (this->mutex_.writing_) {
- ++this->mutex_.readers_waiting_;
- while (this->mutex_.writing_) {
- this->mutex_.read_.wait(this->lock_);
- }
- --this->mutex_.readers_waiting_;
- }
- ++this->mutex_.readers_active_;
- this->lock_.unlock();
-}
-
-/**
- * @brief Destroy.
- *
- * Release the lock.
- */
-openvrml::read_write_mutex::scoped_read_lock::~scoped_read_lock()
-{
- this->lock_.lock();
- --this->mutex_.readers_active_;
- if (this->mutex_.readers_active_ == 0
- && this->mutex_.writers_waiting_ != 0) {
- this->mutex_.write_.notify_one();
- }
-}
-
-/**
- * @class openvrml::read_write_mutex::scoped_write_lock openvrml/read_write_mutex.h
- *
- * @brief Lock the mutex for write access.
- */
-
-/**
- * @internal
- *
- * @var openvrml::read_write_mutex & openvrml::read_write_mutex::scoped_write_lock::mutex_
- *
- * @brief The @c read_write_mutex being locked.
- */
-
-/**
- * @internal
- *
- * @var boost::mutex::scoped_lock openvrml::read_write_mutex::scoped_write_lock::lock_
- *
- * @brief A lock for @c read_write_mutex::mutex_.
- */
-
-/**
- * @brief Construct.
- *
- * Acquire the lock.
- *
- * @param[in] mutex a @c read_write_mutex.
- */
-openvrml::read_write_mutex::scoped_write_lock::
-scoped_write_lock(read_write_mutex & mutex):
- mutex_(mutex),
- lock_(mutex.mutex_)
-{
- if (this->mutex_.writing_ || this->mutex_.readers_active_ != 0) {
- ++this->mutex_.writers_waiting_;
- while (this->mutex_.writing_ || this->mutex_.readers_active_ != 0) {
- this->mutex_.write_.wait(this->lock_);
- }
- --this->mutex_.writers_waiting_;
- }
- this->mutex_.writing_ = true;
- this->lock_.unlock();
-}
-
-/**
- * @brief Destroy.
- *
- * Release the lock.
- */
-openvrml::read_write_mutex::scoped_write_lock::~scoped_write_lock()
-{
- this->lock_.lock();
- this->mutex_.writing_ = false;
- if (this->mutex_.readers_waiting_ != 0) {
- this->mutex_.read_.notify_all();
- } else if (this->mutex_.writers_waiting_ != 0) {
- this->mutex_.write_.notify_one();
- }
-}
-
-/**
- * @brief Construct.
- */
-openvrml::read_write_mutex::read_write_mutex():
- readers_active_(0),
- readers_waiting_(0),
- writers_waiting_(0),
- writing_(false)
-{}
-
-
-/**
- * @class openvrml::read_write_mutex::scoped_read_write_lock openvrml/read_write_mutex.h
- *
- * @brief Lock the mutex for read/write access.
- *
- * Upon construction, the associated mutex is locked for reading. The lock
- * can be “promoted” to a write lock by calling @c #promote.
- */
-
-/**
- * @brief Construct.
- *
- * @param[in] mutex a @c read_write_mutex.
- */
-openvrml::read_write_mutex::scoped_read_write_lock::
-scoped_read_write_lock(read_write_mutex & mutex):
- scoped_read_lock(mutex)
-{}
-
-/**
- * @brief Destroy.
- */
-openvrml::read_write_mutex::scoped_read_write_lock::~scoped_read_write_lock()
-{
- this->demote();
-}
-
-/**
- * @brief Promote the lock to a write lock.
- */
-void openvrml::read_write_mutex::scoped_read_write_lock::promote()
-{
- this->lock_.lock();
- assert(!this->mutex_.writing_);
- --this->mutex_.readers_active_;
- if (this->mutex_.readers_active_ != 0) {
- ++this->mutex_.writers_waiting_;
- while (this->mutex_.readers_active_ != 0) {
- this->mutex_.write_.wait(this->lock_);
- }
- --this->mutex_.writers_waiting_;
- }
- this->mutex_.writing_ = true;
- this->lock_.unlock();
-}
-
-/**
- * @brief Demote the lock from a write lock back to a read lock.
- *
- * If the lock has not been promoted previously, this function has no effect.
- */
-void openvrml::read_write_mutex::scoped_read_write_lock::demote()
-{
- this->lock_.lock();
- if (this->mutex_.writing_) {
- ++this->mutex_.readers_active_;
- this->mutex_.writing_ = false;
- if (this->mutex_.readers_waiting_ != 0) {
- this->mutex_.read_.notify_all();
- } else if (this->mutex_.writers_waiting_ != 0) {
- this->mutex_.write_.notify_one();
- }
- }
- this->lock_.unlock();
-}
Deleted: trunk/src/libopenvrml/openvrml/read_write_mutex.h
===================================================================
--- trunk/src/libopenvrml/openvrml/read_write_mutex.h 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/read_write_mutex.h 2009-06-22 06:24:57 UTC (rev 3923)
@@ -1,72 +0,0 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 78 -*-
-//
-// OpenVRML
-//
-// Copyright 2007 Braden McDaniel
-//
-// This library is free software; you can redistribute it and/or modify it
-// under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or (at your
-// option) any later version.
-//
-// This library is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-// License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this library; if not, see <http://www.gnu.org/licenses/>.
-//
-
-# ifndef OPENVRML_READ_WRITE_MUTEX_H
-# define OPENVRML_READ_WRITE_MUTEX_H
-
-# include <openvrml-common.h>
-# include <boost/thread/mutex.hpp>
-# include <boost/thread/condition.hpp>
-
-namespace openvrml {
-
- class OPENVRML_API read_write_mutex : boost::noncopyable {
- boost::mutex mutex_;
- boost::condition read_, write_;
- std::size_t readers_active_, readers_waiting_, writers_waiting_;
- bool writing_;
-
- public:
- class scoped_read_write_lock;
-
- class OPENVRML_API scoped_read_lock : boost::noncopyable {
- friend class scoped_read_write_lock;
-
- read_write_mutex & mutex_;
- boost::mutex::scoped_lock lock_;
-
- public:
- explicit scoped_read_lock(read_write_mutex & mutex);
- ~scoped_read_lock();
- };
-
- class OPENVRML_API scoped_write_lock : boost::noncopyable {
- read_write_mutex & mutex_;
- boost::mutex::scoped_lock lock_;
-
- public:
- explicit scoped_write_lock(read_write_mutex & mutex);
- ~scoped_write_lock();
- };
-
- class OPENVRML_API scoped_read_write_lock : scoped_read_lock {
- public:
- explicit scoped_read_write_lock(read_write_mutex & mutex);
- ~scoped_read_write_lock();
-
- void promote();
- void demote();
- };
-
- read_write_mutex();
- };
-}
-
-# endif // OPENVRML_READ_WRITE_MUTEX_H
Modified: trunk/src/libopenvrml/openvrml/scene.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/scene.cpp 2009-06-22 01:14:04 UTC (rev 3922)
+++ trunk/src/libopenvrml/openvrml/scene.cpp 2009-06-22 06:24:57 UTC (rev 3923)
@@ -62,7 +62,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::scene::nodes_mutex_
+ * @var boost::shared_mutex openvrml::scene::nodes_mutex_
*
* @brief Mutex protecting @a nodes_.
*/
@@ -78,7 +78,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::scene::url_mutex_
+ * @var boost::shared_mutex openvrml::scene::url_mutex_
*
* @brief Mutex protecting @a url_.
*/
@@ -96,7 +96,7 @@
/**
* @internal
*
- * @var openvrml::read_write_mutex openvrml::scene::meta_mutex_
+ * @var boost::shared_mutex openvrml::scene::meta_mutex_
*
* @brief Mutex protecting @c #meta_.
*/
@@ -171,7 +171,9 @@
void openvrml::scene::load(resource_istream & in)
{
{
- read_write_mutex::scoped_write_lock
+ using boost::unique_lock;
+ using boost::shared_mutex;
+ unique_lock<shared_mutex>
nodes_lock(this->nodes_mutex_),
url_lock(this->url_mutex_),
meta_lock(this->meta_mutex_);
@@ -195,7 +197,9 @@
void openvrml::scene::initialize(const double timestamp)
OPENVRML_THROW1(std::bad_alloc)
{
- read_write_mutex::scoped_read_lock lock(this->nodes_mutex_);
+ using boost::shared_lock;
+ using boost::shared_mutex;
+ shared_lock<shared_mutex> lock(this->nodes_mutex_);
for (std::vector<boost::intrusive_ptr<node> >::iterator node(
this->nodes_.begin());
node != this->nodes_.end();
@@ -222,7 +226,9 @@
const std::...
[truncated message content] |