diff --git a/dtool/Config.pp b/dtool/Config.pp index 782173e497..a35b2e1824 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -713,18 +713,6 @@ // overhead over plain single-threaded code. #define SIMPLE_THREADS -// If you are using SIMPLE_THREADS, you might further wish to disable -// mutexes altogether. In this mode, mutexes are compiled out (they -// become a no-op), and the only context switches happen at explicit -// calls to Thread::force_yield(), consider_yield(), and sleep(), as -// well as calls to ConditionVar::wait(), and certain I/O operations. -// This gives you control over when the context switch happens, and -// may make mutexes unnecessary, if you are somewhat careful in your -// code design. Disabling mutexes saves a tiny bit of runtime and -// memory overhead. NOT RECOMMENDED! Many internal Panda functions -// aren't quite secure enough to enable this mode for now. -#define SIMPLE_THREADS_NO_MUTEX - // Whether threading is defined or not, you might want to validate the // thread and synchronization operations. With threading enabled, // defining this will also enable deadlock detection and logging. diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index 3f8259449e..c97bac3195 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -299,7 +299,6 @@ $[cdefine HAVE_THREADS] /* Define if we want to use fast, user-space simulated threads. */ $[cdefine SIMPLE_THREADS] -$[cdefine SIMPLE_THREADS_NO_MUTEX] /* Define to enable deadlock detection, mutex recursion checks, etc. */ $[cdefine DEBUG_THREADS] diff --git a/panda/src/audiotraits/globalMilesManager.I b/panda/src/audiotraits/globalMilesManager.I index bb45714527..4d96642f84 100644 --- a/panda/src/audiotraits/globalMilesManager.I +++ b/panda/src/audiotraits/globalMilesManager.I @@ -32,7 +32,7 @@ is_open() const { //////////////////////////////////////////////////////////////////// INLINE int GlobalMilesManager:: get_num_samples() const { - MutexHolder holder(_samples_lock); + LightMutexHolder holder(_samples_lock); return _samples.size(); } @@ -44,6 +44,6 @@ get_num_samples() const { //////////////////////////////////////////////////////////////////// INLINE int GlobalMilesManager:: get_num_sequences() const { - MutexHolder holder(_sequences_lock); + LightMutexHolder holder(_sequences_lock); return _sequences.size(); } diff --git a/panda/src/audiotraits/globalMilesManager.cxx b/panda/src/audiotraits/globalMilesManager.cxx index b87cc25044..dc66f51cec 100644 --- a/panda/src/audiotraits/globalMilesManager.cxx +++ b/panda/src/audiotraits/globalMilesManager.cxx @@ -16,7 +16,7 @@ #ifdef HAVE_RAD_MSS //[ -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "milesAudioManager.h" #include "milesAudioSample.h" #include "milesAudioSequence.h" @@ -50,7 +50,7 @@ GlobalMilesManager() : //////////////////////////////////////////////////////////////////// void GlobalMilesManager:: add_manager(MilesAudioManager *manager) { - MutexHolder holder(_managers_lock); + LightMutexHolder holder(_managers_lock); _managers.insert(manager); if (!_is_open) { open_api(); @@ -66,7 +66,7 @@ add_manager(MilesAudioManager *manager) { //////////////////////////////////////////////////////////////////// void GlobalMilesManager:: remove_manager(MilesAudioManager *manager) { - MutexHolder holder(_managers_lock); + LightMutexHolder holder(_managers_lock); _managers.erase(manager); if (_managers.empty() && _is_open) { close_api(); @@ -81,7 +81,7 @@ remove_manager(MilesAudioManager *manager) { //////////////////////////////////////////////////////////////////// void GlobalMilesManager:: cleanup() { - MutexHolder holder(_managers_lock); + LightMutexHolder holder(_managers_lock); Managers::iterator mi; for (mi = _managers.begin(); mi != _managers.end(); ++mi) { (*mi)->cleanup(); @@ -105,7 +105,7 @@ cleanup() { //////////////////////////////////////////////////////////////////// bool GlobalMilesManager:: get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { - MutexHolder holder(_samples_lock); + LightMutexHolder holder(_samples_lock); for (size_t i = 0; i < _samples.size(); ++i) { SampleData &smp = _samples[i]; @@ -146,7 +146,7 @@ get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound) { //////////////////////////////////////////////////////////////////// void GlobalMilesManager:: release_sample(size_t index, MilesAudioSample *sound) { - MutexHolder holder(_samples_lock); + LightMutexHolder holder(_samples_lock); nassertv(index < _samples.size()); SampleData &smp = _samples[index]; @@ -172,7 +172,7 @@ release_sample(size_t index, MilesAudioSample *sound) { //////////////////////////////////////////////////////////////////// bool GlobalMilesManager:: get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { - MutexHolder holder(_sequences_lock); + LightMutexHolder holder(_sequences_lock); for (size_t i = 0; i < _sequences.size(); ++i) { SequenceData &seq = _sequences[i]; @@ -212,7 +212,7 @@ get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound) { //////////////////////////////////////////////////////////////////// void GlobalMilesManager:: release_sequence(size_t index, MilesAudioSequence *sound) { - MutexHolder holder(_sequences_lock); + LightMutexHolder holder(_sequences_lock); nassertv(index < _sequences.size()); SequenceData &seq = _sequences[index]; diff --git a/panda/src/audiotraits/globalMilesManager.h b/panda/src/audiotraits/globalMilesManager.h index c6af16cf9a..7dfa2cad6d 100644 --- a/panda/src/audiotraits/globalMilesManager.h +++ b/panda/src/audiotraits/globalMilesManager.h @@ -20,8 +20,8 @@ #include "mss.h" #include "pset.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" #ifndef UINTa #define UINTa U32 @@ -86,7 +86,7 @@ private: typedef pset Managers; Managers _managers; - Mutex _managers_lock; + LightMutex _managers_lock; class SampleData { public: @@ -96,7 +96,7 @@ private: typedef pvector Samples; Samples _samples; - Mutex _samples_lock; + LightMutex _samples_lock; class SequenceData { public: @@ -106,7 +106,7 @@ private: typedef pvector Sequences; Sequences _sequences; - Mutex _sequences_lock; + LightMutex _sequences_lock; static GlobalMilesManager *_global_ptr; }; diff --git a/panda/src/audiotraits/milesAudioManager.cxx b/panda/src/audiotraits/milesAudioManager.cxx index d39b53a359..875b7c7544 100644 --- a/panda/src/audiotraits/milesAudioManager.cxx +++ b/panda/src/audiotraits/milesAudioManager.cxx @@ -28,7 +28,7 @@ #include "nullAudioSound.h" #include "string_utils.h" #include "mutexHolder.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include @@ -125,7 +125,7 @@ shutdown() { //////////////////////////////////////////////////////////////////// bool MilesAudioManager:: is_valid() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return do_is_valid(); } @@ -136,7 +136,7 @@ is_valid() { //////////////////////////////////////////////////////////////////// PT(AudioSound) MilesAudioManager:: get_sound(const string &file_name, bool, int) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); audio_debug("MilesAudioManager::get_sound(file_name=\""<get_name()<<"\"), this = " << (void *)this); - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); AudioSet::iterator ai = _sounds_on_loan.find(audioSound); nassertv(ai != _sounds_on_loan.end()); _sounds_on_loan.erase(ai); @@ -501,7 +501,7 @@ void MilesAudioManager:: cleanup() { audio_debug("MilesAudioManager::cleanup(), this = " << (void *)this << ", _cleanup_required = " << _cleanup_required); - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (!_cleanup_required) { return; } @@ -541,7 +541,7 @@ cleanup() { //////////////////////////////////////////////////////////////////// void MilesAudioManager:: output(ostream &out) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); out << get_type() << ": " << _sounds_playing.size() << " / " << _sounds_on_loan.size() << " sounds playing / total"; } @@ -553,7 +553,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void MilesAudioManager:: write(ostream &out) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); out << (*this) << "\n"; AudioSet::const_iterator ai; @@ -733,7 +733,7 @@ uncache_a_sound() { //////////////////////////////////////////////////////////////////// void MilesAudioManager:: starting_sound(MilesAudioSound *audio) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_concurrent_sound_limit) { do_reduce_sounds_playing_to(_concurrent_sound_limit); } @@ -749,7 +749,7 @@ starting_sound(MilesAudioSound *audio) { //////////////////////////////////////////////////////////////////// void MilesAudioManager:: stopping_sound(MilesAudioSound *audio) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _sounds_playing.erase(audio); if (_hasMidiSounds && _sounds_playing.size() == 0) { GlobalMilesManager::get_global_ptr()->force_midi_reset(); diff --git a/panda/src/audiotraits/milesAudioManager.h b/panda/src/audiotraits/milesAudioManager.h index 981a020c7a..1601a21158 100644 --- a/panda/src/audiotraits/milesAudioManager.h +++ b/panda/src/audiotraits/milesAudioManager.h @@ -27,7 +27,7 @@ #include "pvector.h" #include "thread.h" #include "pmutex.h" -#include "reMutex.h" +#include "lightReMutex.h" #include "conditionVar.h" class MilesAudioSound; @@ -143,7 +143,7 @@ private: bool _hasMidiSounds; // This mutex protects everything above. - ReMutex _lock; + LightReMutex _lock; bool _sounds_finished; typedef pvector Streams; diff --git a/panda/src/char/jointVertexTransform.cxx b/panda/src/char/jointVertexTransform.cxx index 1f455cce37..f494e5d93c 100644 --- a/panda/src/char/jointVertexTransform.cxx +++ b/panda/src/char/jointVertexTransform.cxx @@ -17,7 +17,7 @@ #include "datagramIterator.h" #include "bamReader.h" #include "bamWriter.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" TypeHandle JointVertexTransform::_type_handle; @@ -137,7 +137,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void JointVertexTransform:: compute_matrix() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_matrix_stale) { _matrix = _joint->_initial_net_transform_inverse * _joint->_net_transform; _matrix_stale = false; diff --git a/panda/src/char/jointVertexTransform.h b/panda/src/char/jointVertexTransform.h index 673d8c798d..7add735a21 100644 --- a/panda/src/char/jointVertexTransform.h +++ b/panda/src/char/jointVertexTransform.h @@ -19,7 +19,7 @@ #include "characterJoint.h" #include "vertexTransform.h" #include "pointerTo.h" -#include "pmutex.h" +#include "lightMutex.h" //////////////////////////////////////////////////////////////////// // Class : JointVertexTransform @@ -59,7 +59,7 @@ private: LMatrix4f _matrix; bool _matrix_stale; - Mutex _lock; + LightMutex _lock; public: static void register_with_read_factory(); diff --git a/panda/src/collide/collisionSolid.I b/panda/src/collide/collisionSolid.I index f16d5f4b61..dd25056d14 100644 --- a/panda/src/collide/collisionSolid.I +++ b/panda/src/collide/collisionSolid.I @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: set_tangible(bool tangible) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (tangible) { _flags |= F_tangible; } else { @@ -45,7 +45,7 @@ set_tangible(bool tangible) { //////////////////////////////////////////////////////////////////// INLINE bool CollisionSolid:: is_tangible() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_is_tangible(); } @@ -63,7 +63,7 @@ is_tangible() const { //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: set_effective_normal(const LVector3f &effective_normal) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _effective_normal = effective_normal; _flags |= F_effective_normal; } @@ -76,7 +76,7 @@ set_effective_normal(const LVector3f &effective_normal) { //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: clear_effective_normal() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _flags &= ~F_effective_normal; } @@ -88,7 +88,7 @@ clear_effective_normal() { //////////////////////////////////////////////////////////////////// INLINE bool CollisionSolid:: has_effective_normal() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_has_effective_normal(); } @@ -101,7 +101,7 @@ has_effective_normal() const { //////////////////////////////////////////////////////////////////// INLINE const LVector3f &CollisionSolid:: get_effective_normal() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(do_has_effective_normal(), LVector3f::zero()); return _effective_normal; } @@ -118,7 +118,7 @@ get_effective_normal() const { //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: set_respect_effective_normal(bool respect_effective_normal) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // For historical reasons, the bit we store is the opposite of the // bool flag we present. if (respect_effective_normal) { @@ -135,7 +135,7 @@ set_respect_effective_normal(bool respect_effective_normal) { //////////////////////////////////////////////////////////////////// INLINE bool CollisionSolid:: get_respect_effective_normal() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return (_flags & F_ignore_effective_normal) == 0; } @@ -172,7 +172,7 @@ do_has_effective_normal() const { //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: mark_internal_bounds_stale() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _flags |= F_internal_bounds_stale; } @@ -186,6 +186,6 @@ mark_internal_bounds_stale() { //////////////////////////////////////////////////////////////////// INLINE void CollisionSolid:: mark_viz_stale() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _flags |= F_viz_geom_stale; } diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index fcc30cde73..b3aa064ae6 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -90,7 +90,7 @@ make_cow_copy() { //////////////////////////////////////////////////////////////////// CPT(BoundingVolume) CollisionSolid:: get_bounds() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_flags & F_internal_bounds_stale) { ((CollisionSolid *)this)->_internal_bounds = compute_internal_bounds(); ((CollisionSolid *)this)->_flags &= ~F_internal_bounds_stale; @@ -105,7 +105,7 @@ get_bounds() const { //////////////////////////////////////////////////////////////////// void CollisionSolid:: set_bounds(const BoundingVolume &bounding_volume) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); ((CollisionSolid *)this)->_internal_bounds = bounding_volume.make_copy(); ((CollisionSolid *)this)->_flags &= ~F_internal_bounds_stale; } @@ -132,7 +132,7 @@ test_intersection(const CollisionEntry &) const { //////////////////////////////////////////////////////////////////// void CollisionSolid:: xform(const LMatrix4f &mat) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_effective_normal) != 0) { _effective_normal = _effective_normal * mat; _effective_normal.normalize(); @@ -151,7 +151,7 @@ xform(const LMatrix4f &mat) { //////////////////////////////////////////////////////////////////// PT(PandaNode) CollisionSolid:: get_viz(const CullTraverser *, const CullTraverserData &, bool bounds_only) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_viz_geom_stale) != 0) { if (_viz_geom == (GeomNode *)NULL) { ((CollisionSolid *)this)->_viz_geom = new GeomNode("viz"); @@ -390,7 +390,7 @@ void CollisionSolid:: write_datagram(BamWriter *, Datagram &me) { // For now, we need only 8 bits of flags. If we need to expand this // later, we will have to increase the bam version. - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); me.add_uint8(_flags); if ((_flags & F_effective_normal) != 0) { _effective_normal.write_datagram(me); diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index de361f86c7..ee4b173a08 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -23,8 +23,8 @@ #include "pointerTo.h" #include "renderState.h" #include "geomNode.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" #include "pStatCollector.h" class CollisionHandler; @@ -143,7 +143,7 @@ private: }; int _flags; - Mutex _lock; + LightMutex _lock; static PStatCollector _volume_pcollector; static PStatCollector _test_pcollector; diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index e3f286769a..aa404ccfb5 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -27,7 +27,7 @@ #include "pStatClient.h" #include "pStatCollector.h" #include "mutexHolder.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include "cullFaceAttrib.h" #include "string_utils.h" #include "geomCacheManager.h" @@ -196,7 +196,7 @@ set_threading_model(const GraphicsThreadingModel &threading_model) { << "Danger! Creating requested render threads anyway!\n"; } #endif // THREADED_PIPELINE - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _threading_model = threading_model; } @@ -210,7 +210,7 @@ GraphicsThreadingModel GraphicsEngine:: get_threading_model() const { GraphicsThreadingModel result; { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); result = _threading_model; } return result; @@ -454,7 +454,7 @@ remove_window(GraphicsOutput *window) { PT(GraphicsOutput) ptwin = window; size_t count; { - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); if (!_windows_sorted) { do_resort_windows(); } @@ -613,7 +613,7 @@ render_frame() { } { - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); if (!_windows_sorted) { do_resort_windows(); @@ -833,7 +833,7 @@ void GraphicsEngine:: open_windows() { Thread *current_thread = Thread::get_current_thread(); - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); if (!_windows_sorted) { do_resort_windows(); @@ -876,7 +876,7 @@ open_windows() { void GraphicsEngine:: sync_frame() { Thread *current_thread = Thread::get_current_thread(); - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); if (_flip_state == FS_draw) { do_sync_frame(current_thread); @@ -895,7 +895,7 @@ sync_frame() { void GraphicsEngine:: flip_frame() { Thread *current_thread = Thread::get_current_thread(); - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); if (_flip_state != FS_flip) { do_flip_frame(current_thread); @@ -933,7 +933,7 @@ flip_frame() { //////////////////////////////////////////////////////////////////// bool GraphicsEngine:: extract_texture_data(Texture *tex, GraphicsStateGuardian *gsg) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); string draw_name = gsg->get_threading_model().get_draw_name(); if (draw_name.empty()) { @@ -994,7 +994,7 @@ bool GraphicsEngine:: add_callback(const string &thread_name, GraphicsEngine::CallbackTime callback_time, GraphicsEngine::CallbackFunction *func, void *data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); WindowRenderer *wr = get_window_renderer(thread_name, 0); return wr->add_callback(callback_time, Callback(func, data)); } @@ -1015,7 +1015,7 @@ bool GraphicsEngine:: remove_callback(const string &thread_name, GraphicsEngine::CallbackTime callback_time, GraphicsEngine::CallbackFunction *func, void *data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); WindowRenderer *wr = get_window_renderer(thread_name, 0); return wr->remove_callback(callback_time, Callback(func, data)); } @@ -1092,7 +1092,7 @@ is_scene_root(const PandaNode *node) { //////////////////////////////////////////////////////////////////// void GraphicsEngine:: set_window_sort(GraphicsOutput *window, int sort) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); window->_sort = sort; _windows_sorted = false; } @@ -1776,7 +1776,7 @@ do_draw(CullResult *cull_result, SceneSetup *scene_setup, void GraphicsEngine:: do_add_window(GraphicsOutput *window, const GraphicsThreadingModel &threading_model) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); // We have a special counter that is unique per window that allows // us to assure that recently-added windows end up on the end of the @@ -1841,7 +1841,7 @@ do_add_window(GraphicsOutput *window, void GraphicsEngine:: do_add_gsg(GraphicsStateGuardian *gsg, GraphicsPipe *pipe, const GraphicsThreadingModel &threading_model) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); gsg->_threading_model = threading_model; gsg->_pipe = pipe; @@ -2072,7 +2072,7 @@ auto_adjust_capabilities(GraphicsStateGuardian *gsg) { //////////////////////////////////////////////////////////////////// void GraphicsEngine:: terminate_threads(Thread *current_thread) { - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); // We spend almost our entire time in this method just waiting for // threads. Time it appropriately. @@ -2221,7 +2221,7 @@ WindowRenderer(const string &name) : //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: add_gsg(GraphicsStateGuardian *gsg) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); _gsgs.insert(gsg); } @@ -2233,7 +2233,7 @@ add_gsg(GraphicsStateGuardian *gsg) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: add_window(Windows &wlist, GraphicsOutput *window) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); wlist.insert(window); } @@ -2247,7 +2247,7 @@ add_window(Windows &wlist, GraphicsOutput *window) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: remove_window(GraphicsOutput *window) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); PT(GraphicsOutput) ptwin = window; _cull.erase(ptwin); @@ -2284,7 +2284,7 @@ remove_window(GraphicsOutput *window) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: resort_windows() { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); _cull.sort(); _cdraw.sort(); @@ -2324,7 +2324,7 @@ resort_windows() { void GraphicsEngine::WindowRenderer:: do_frame(GraphicsEngine *engine, Thread *current_thread) { PStatTimer timer(engine->_do_frame_pcollector, current_thread); - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); do_callbacks(CB_pre_frame); @@ -2367,7 +2367,7 @@ do_frame(GraphicsEngine *engine, Thread *current_thread) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: do_windows(GraphicsEngine *engine, Thread *current_thread) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); engine->process_events(_window, current_thread); @@ -2383,7 +2383,7 @@ do_windows(GraphicsEngine *engine, Thread *current_thread) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: do_flip(GraphicsEngine *engine, Thread *current_thread) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); engine->flip_windows(_cdraw, current_thread); engine->flip_windows(_draw, current_thread); } @@ -2395,7 +2395,7 @@ do_flip(GraphicsEngine *engine, Thread *current_thread) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: do_close(GraphicsEngine *engine, Thread *current_thread) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); Windows::iterator wi; for (wi = _window.begin(); wi != _window.end(); ++wi) { GraphicsOutput *win = (*wi); @@ -2428,7 +2428,7 @@ do_close(GraphicsEngine *engine, Thread *current_thread) { //////////////////////////////////////////////////////////////////// void GraphicsEngine::WindowRenderer:: do_pending(GraphicsEngine *engine, Thread *current_thread) { - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); if (!_pending_close.empty()) { if (display_cat.is_debug()) { @@ -2477,7 +2477,7 @@ bool GraphicsEngine::WindowRenderer:: add_callback(GraphicsEngine::CallbackTime callback_time, const GraphicsEngine::Callback &callback) { nassertr(callback_time >= 0 && callback_time < CB_len, false); - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); return _callbacks[callback_time].insert(callback).second; } @@ -2493,7 +2493,7 @@ bool GraphicsEngine::WindowRenderer:: remove_callback(GraphicsEngine::CallbackTime callback_time, const GraphicsEngine::Callback &callback) { nassertr(callback_time >= 0 && callback_time < CB_len, false); - ReMutexHolder holder(_wl_lock); + LightReMutexHolder holder(_wl_lock); Callbacks::iterator cbi = _callbacks[callback_time].find(callback); if (cbi != _callbacks[callback_time].end()) { _callbacks[callback_time].erase(cbi); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index db3ec16155..1e77f055cf 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -24,7 +24,7 @@ #include "pointerTo.h" #include "thread.h" #include "pmutex.h" -#include "reMutex.h" +#include "lightReMutex.h" #include "conditionVar.h" #include "pStatCollector.h" #include "pset.h" @@ -302,7 +302,7 @@ private: GSGs _gsgs; // draw stage Callbacks _callbacks[CB_len]; - ReMutex _wl_lock; + LightReMutex _wl_lock; }; class RenderThread : public Thread, public WindowRenderer { @@ -343,7 +343,7 @@ private: bool _singular_warning_last_frame; bool _singular_warning_this_frame; - ReMutex _lock; + LightReMutex _lock; static PT(GraphicsEngine) _global_ptr; diff --git a/panda/src/display/graphicsOutput.cxx b/panda/src/display/graphicsOutput.cxx index b613d8beab..be8afe05c9 100644 --- a/panda/src/display/graphicsOutput.cxx +++ b/panda/src/display/graphicsOutput.cxx @@ -17,7 +17,7 @@ #include "graphicsEngine.h" #include "graphicsWindow.h" #include "config_display.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "renderBuffer.h" #include "indirectLess.h" #include "pStatTimer.h" @@ -217,7 +217,7 @@ GraphicsOutput:: //////////////////////////////////////////////////////////////////// void GraphicsOutput:: clear_render_textures() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); throw_event("render-texture-targets-changed"); _textures.clear(); } @@ -268,7 +268,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode, if (mode == RTM_none) { return; } - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); throw_event("render-texture-targets-changed"); @@ -442,7 +442,7 @@ set_sort(int sort) { //////////////////////////////////////////////////////////////////// bool GraphicsOutput:: remove_display_region(DisplayRegion *display_region) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(display_region != _default_display_region, false); @@ -472,7 +472,7 @@ remove_display_region(DisplayRegion *display_region) { //////////////////////////////////////////////////////////////////// void GraphicsOutput:: remove_all_display_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); TotalDisplayRegions::iterator dri; for (dri = _total_display_regions.begin(); @@ -501,7 +501,7 @@ get_num_display_regions() const { determine_display_regions(); int result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); result = _total_display_regions.size(); } return result; @@ -521,7 +521,7 @@ get_display_region(int n) const { determine_display_regions(); PT(DisplayRegion) result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (n >= 0 && n < (int)_total_display_regions.size()) { result = _total_display_regions[n]; } else { @@ -542,7 +542,7 @@ get_num_active_display_regions() const { determine_display_regions(); int result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); result = _active_display_regions.size(); } return result; @@ -562,7 +562,7 @@ get_active_display_region(int n) const { determine_display_regions(); PT(DisplayRegion) result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (n >= 0 && n < (int)_active_display_regions.size()) { result = _active_display_regions[n]; } else { @@ -1200,7 +1200,7 @@ process_events() { //////////////////////////////////////////////////////////////////// DisplayRegion *GraphicsOutput:: add_display_region(DisplayRegion *display_region) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _total_display_regions.push_back(display_region); _display_regions_stale = true; @@ -1215,7 +1215,7 @@ add_display_region(DisplayRegion *display_region) { //////////////////////////////////////////////////////////////////// void GraphicsOutput:: do_determine_display_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _display_regions_stale = false; _active_display_regions.clear(); diff --git a/panda/src/display/graphicsOutput.h b/panda/src/display/graphicsOutput.h index a9b7f02f5d..5001eb135c 100644 --- a/panda/src/display/graphicsOutput.h +++ b/panda/src/display/graphicsOutput.h @@ -27,7 +27,7 @@ #include "pandaNode.h" #include "pStatCollector.h" #include "pnotify.h" -#include "pmutex.h" +#include "lightMutex.h" #include "filename.h" #include "drawMask.h" #include "pvector.h" @@ -273,7 +273,7 @@ protected: pvector _hold_textures; protected: - Mutex _lock; + LightMutex _lock; // protects _display_regions. PT(DisplayRegion) _default_display_region; typedef pvector< PT(DisplayRegion) > TotalDisplayRegions; diff --git a/panda/src/display/graphicsPipe.h b/panda/src/display/graphicsPipe.h index 5242c20d6b..735b043103 100644 --- a/panda/src/display/graphicsPipe.h +++ b/panda/src/display/graphicsPipe.h @@ -20,7 +20,7 @@ #include "graphicsDevice.h" #include "typedReferenceCount.h" #include "pointerTo.h" -#include "pmutex.h" +#include "lightMutex.h" #include "displayInformation.h" class GraphicsOutput; @@ -121,7 +121,7 @@ protected: int retry, bool &precertify); - Mutex _lock; + LightMutex _lock; bool _is_valid; int _supported_types; diff --git a/panda/src/display/graphicsPipeSelection.cxx b/panda/src/display/graphicsPipeSelection.cxx index 6c4c343e7e..22a722b933 100644 --- a/panda/src/display/graphicsPipeSelection.cxx +++ b/panda/src/display/graphicsPipeSelection.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "graphicsPipeSelection.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "string_utils.h" #include "filename.h" #include "load_dso.h" @@ -95,7 +95,7 @@ get_num_pipe_types() const { int result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); result = _pipe_types.size(); } return result; @@ -113,7 +113,7 @@ get_pipe_type(int n) const { TypeHandle result; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (n >= 0 && n < (int)_pipe_types.size()) { result = _pipe_types[n]._type; } @@ -131,7 +131,7 @@ void GraphicsPipeSelection:: print_pipe_types() const { load_default_module(); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nout << "Known pipe types:" << endl; PipeTypes::const_iterator pi; for (pi = _pipe_types.begin(); pi != _pipe_types.end(); ++pi) { @@ -202,7 +202,7 @@ make_pipe(const string &type_name, const string &module_name) { //////////////////////////////////////////////////////////////////// PT(GraphicsPipe) GraphicsPipeSelection:: make_pipe(TypeHandle type) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PipeTypes::const_iterator ti; // First, look for an exact match of the requested type. @@ -257,7 +257,7 @@ PT(GraphicsPipe) GraphicsPipeSelection:: make_default_pipe() { load_default_module(); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PipeTypes::const_iterator ti; if (!_default_pipe_name.empty()) { @@ -340,7 +340,7 @@ add_pipe_type(TypeHandle type, PipeConstructorFunc *func) { // First, make sure we don't already have a GraphicsPipe of this // type. - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PipeTypes::const_iterator ti; for (ti = _pipe_types.begin(); ti != _pipe_types.end(); ++ti) { const PipeType &ptype = (*ti); diff --git a/panda/src/display/graphicsPipeSelection.h b/panda/src/display/graphicsPipeSelection.h index 5f35b7ad1f..fae6c89d43 100644 --- a/panda/src/display/graphicsPipeSelection.h +++ b/panda/src/display/graphicsPipeSelection.h @@ -20,7 +20,7 @@ #include "graphicsPipe.h" #include "pointerTo.h" #include "typeHandle.h" -#include "pmutex.h" +#include "lightMutex.h" #include "vector_string.h" class HardwareChannel; @@ -70,7 +70,7 @@ private: }; typedef pvector PipeTypes; PipeTypes _pipe_types; - Mutex _lock; + LightMutex _lock; typedef vector_string DisplayModules; DisplayModules _display_modules; diff --git a/panda/src/display/graphicsWindow.cxx b/panda/src/display/graphicsWindow.cxx index ce73693902..b8744e44cb 100644 --- a/panda/src/display/graphicsWindow.cxx +++ b/panda/src/display/graphicsWindow.cxx @@ -17,8 +17,8 @@ #include "config_display.h" #include "mouseButton.h" #include "keyboardButton.h" -#include "mutexHolder.h" -#include "reMutexHolder.h" +#include "lightMutexHolder.h" +#include "lightReMutexHolder.h" #include "throw_event.h" #include "string_utils.h" @@ -88,7 +88,7 @@ const WindowProperties GraphicsWindow:: get_properties() const { WindowProperties result; { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); result = _properties; } return result; @@ -106,7 +106,7 @@ const WindowProperties GraphicsWindow:: get_requested_properties() const { WindowProperties result; { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); result = _requested_properties; } return result; @@ -120,7 +120,7 @@ get_requested_properties() const { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: clear_rejected_properties() { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); _rejected_properties.clear(); } @@ -137,7 +137,7 @@ WindowProperties GraphicsWindow:: get_rejected_properties() const { WindowProperties result; { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); result = _rejected_properties; } return result; @@ -156,7 +156,7 @@ get_rejected_properties() const { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: request_properties(const WindowProperties &requested_properties) { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); _requested_properties.add_properties(requested_properties); if (!_has_size && _requested_properties.has_size()) { @@ -197,7 +197,7 @@ is_active() const { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: set_window_event(const string &window_event) { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); _window_event = window_event; } @@ -211,7 +211,7 @@ set_window_event(const string &window_event) { string GraphicsWindow:: get_window_event() const { string result; - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); result = _window_event; return result; } @@ -242,7 +242,7 @@ get_window_event() const { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: set_close_request_event(const string &close_request_event) { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); _close_request_event = close_request_event; } @@ -258,7 +258,7 @@ set_close_request_event(const string &close_request_event) { string GraphicsWindow:: get_close_request_event() const { string result; - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); result = _close_request_event; return result; } @@ -277,7 +277,7 @@ int GraphicsWindow:: get_num_input_devices() const { int result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); result = _input_devices.size(); } return result; @@ -292,7 +292,7 @@ string GraphicsWindow:: get_input_device_name(int device) const { string result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), ""); result = _input_devices[device].get_name(); } @@ -310,7 +310,7 @@ bool GraphicsWindow:: has_pointer(int device) const { bool result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), false); result = _input_devices[device].has_pointer(); } @@ -327,7 +327,7 @@ bool GraphicsWindow:: has_keyboard(int device) const { bool result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), false); result = _input_devices[device].has_keyboard(); } @@ -341,7 +341,7 @@ has_keyboard(int device) const { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: enable_pointer_events(int device) { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertv(device >= 0 && device < (int)_input_devices.size()); _input_devices[device].enable_pointer_events(); } @@ -353,7 +353,7 @@ enable_pointer_events(int device) { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: disable_pointer_events(int device) { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertv(device >= 0 && device < (int)_input_devices.size()); _input_devices[device].disable_pointer_events(); } @@ -365,7 +365,7 @@ disable_pointer_events(int device) { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: enable_pointer_mode(int device, double speed) { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertv(device >= 0 && device < (int)_input_devices.size()); _input_devices[device].enable_pointer_mode(speed); } @@ -377,7 +377,7 @@ enable_pointer_mode(int device, double speed) { //////////////////////////////////////////////////////////////////// void GraphicsWindow:: disable_pointer_mode(int device) { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertv(device >= 0 && device < (int)_input_devices.size()); _input_devices[device].disable_pointer_mode(); } @@ -392,7 +392,7 @@ MouseData GraphicsWindow:: get_pointer(int device) const { MouseData result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), MouseData()); result = _input_devices[device].get_pointer(); } @@ -438,7 +438,7 @@ bool GraphicsWindow:: has_button_event(int device) const { bool result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), false); result = _input_devices[device].has_button_event(); } @@ -455,7 +455,7 @@ ButtonEvent GraphicsWindow:: get_button_event(int device) { ButtonEvent result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), ButtonEvent()); nassertr(_input_devices[device].has_button_event(), ButtonEvent()); result = _input_devices[device].get_button_event(); @@ -475,7 +475,7 @@ bool GraphicsWindow:: has_pointer_event(int device) const { bool result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), false); result = _input_devices[device].has_pointer_event(); } @@ -492,7 +492,7 @@ PT(PointerEventList) GraphicsWindow:: get_pointer_events(int device) { PT(PointerEventList) result; { - MutexHolder holder(_input_lock); + LightMutexHolder holder(_input_lock); nassertr(device >= 0 && device < (int)_input_devices.size(), NULL); nassertr(_input_devices[device].has_pointer_event(), NULL); result = _input_devices[device].get_pointer_events(); @@ -591,7 +591,7 @@ process_events() { // bitmask after all. WindowProperties properties; { - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); properties = _requested_properties; _requested_properties.clear(); @@ -806,7 +806,7 @@ system_changed_properties(const WindowProperties &properties) { << "system_changed_properties(" << properties << ")\n"; } - ReMutexHolder holder(_properties_lock); + LightReMutexHolder holder(_properties_lock); if (properties.has_size()) { system_changed_size(properties.get_x_size(), properties.get_y_size()); diff --git a/panda/src/display/graphicsWindow.h b/panda/src/display/graphicsWindow.h index 6453dfb446..a880088170 100644 --- a/panda/src/display/graphicsWindow.h +++ b/panda/src/display/graphicsWindow.h @@ -24,8 +24,8 @@ #include "modifierButtons.h" #include "buttonEvent.h" #include "pnotify.h" -#include "pmutex.h" -#include "reMutex.h" +#include "lightMutex.h" +#include "lightReMutex.h" #include "pvector.h" //////////////////////////////////////////////////////////////////// @@ -121,13 +121,13 @@ protected: INLINE void add_input_device(const GraphicsWindowInputDevice &device); typedef vector_GraphicsWindowInputDevice InputDevices; InputDevices _input_devices; - Mutex _input_lock; + LightMutex _input_lock; protected: WindowProperties _properties; private: - ReMutex _properties_lock; + LightReMutex _properties_lock; // protects _requested_properties, _rejected_properties, and // _window_event. diff --git a/panda/src/display/graphicsWindowInputDevice.I b/panda/src/display/graphicsWindowInputDevice.I index f5b36f2616..f4000f9df7 100644 --- a/panda/src/display/graphicsWindowInputDevice.I +++ b/panda/src/display/graphicsWindowInputDevice.I @@ -19,7 +19,7 @@ //////////////////////////////////////////////////////////////////// INLINE GraphicsWindowInputDevice:: GraphicsWindowInputDevice() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _flags = 0; } @@ -30,7 +30,7 @@ GraphicsWindowInputDevice() { //////////////////////////////////////////////////////////////////// INLINE string GraphicsWindowInputDevice:: get_name() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _name; } @@ -41,7 +41,7 @@ get_name() const { //////////////////////////////////////////////////////////////////// INLINE bool GraphicsWindowInputDevice:: has_pointer() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return ((_flags & IDF_has_pointer) != 0); } @@ -52,7 +52,7 @@ has_pointer() const { //////////////////////////////////////////////////////////////////// INLINE bool GraphicsWindowInputDevice:: has_keyboard() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return ((_flags & IDF_has_keyboard) != 0); } @@ -64,7 +64,7 @@ has_keyboard() const { //////////////////////////////////////////////////////////////////// INLINE MouseData GraphicsWindowInputDevice:: get_pointer() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _mouse_data; } @@ -77,7 +77,7 @@ get_pointer() const { //////////////////////////////////////////////////////////////////// INLINE MouseData GraphicsWindowInputDevice:: get_raw_pointer() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _true_mouse_data; } @@ -90,7 +90,7 @@ get_raw_pointer() const { //////////////////////////////////////////////////////////////////// INLINE void GraphicsWindowInputDevice:: set_device_index(int index) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _device_index = index; } @@ -101,7 +101,7 @@ set_device_index(int index) { //////////////////////////////////////////////////////////////////// INLINE void GraphicsWindowInputDevice:: enable_pointer_events() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _enable_pointer_events = true; } @@ -112,7 +112,7 @@ enable_pointer_events() { //////////////////////////////////////////////////////////////////// INLINE void GraphicsWindowInputDevice:: disable_pointer_events() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _enable_pointer_events = false; _pointer_events.clear(); } diff --git a/panda/src/display/graphicsWindowInputDevice.cxx b/panda/src/display/graphicsWindowInputDevice.cxx index 3879215281..eb7e38aa90 100644 --- a/panda/src/display/graphicsWindowInputDevice.cxx +++ b/panda/src/display/graphicsWindowInputDevice.cxx @@ -108,8 +108,8 @@ GraphicsWindowInputDevice(const GraphicsWindowInputDevice ©) void GraphicsWindowInputDevice:: operator = (const GraphicsWindowInputDevice ©) { - MutexHolder holder(_lock); - MutexHolder holder1(copy._lock); + LightMutexHolder holder(_lock); + LightMutexHolder holder1(copy._lock); _host = copy._host; _name = copy._name; _flags = copy._flags; @@ -146,7 +146,7 @@ GraphicsWindowInputDevice:: //////////////////////////////////////////////////////////////////// bool GraphicsWindowInputDevice:: has_button_event() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return !_button_events.empty(); } @@ -158,7 +158,7 @@ has_button_event() const { //////////////////////////////////////////////////////////////////// ButtonEvent GraphicsWindowInputDevice:: get_button_event() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); ButtonEvent be = _button_events.front(); _button_events.pop_front(); return be; @@ -174,7 +174,7 @@ get_button_event() { //////////////////////////////////////////////////////////////////// bool GraphicsWindowInputDevice:: has_pointer_event() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return (_pointer_events != 0); } @@ -186,7 +186,7 @@ has_pointer_event() const { //////////////////////////////////////////////////////////////////// PT(PointerEventList) GraphicsWindowInputDevice:: get_pointer_events() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PT(PointerEventList) result = _pointer_events; _pointer_events = 0; return result; @@ -212,7 +212,7 @@ get_pointer_events() { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: enable_pointer_mode(double speed) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertv(_device_index != 0); _pointer_mode_enable = true; _pointer_speed = speed; @@ -230,7 +230,7 @@ enable_pointer_mode(double speed) { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: disable_pointer_mode() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertv(_device_index != 0); _pointer_mode_enable = false; _pointer_speed = 1.0; @@ -246,7 +246,7 @@ disable_pointer_mode() { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: set_pointer(bool inwin, int x, int y, double time) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int delta_x = x - _true_mouse_data._xpos; int delta_y = y - _true_mouse_data._ypos; @@ -289,7 +289,7 @@ set_pointer(bool inwin, int x, int y, double time) { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: button_down(ButtonHandle button, double time) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(button, ButtonEvent::T_down, time)); } @@ -303,7 +303,7 @@ button_down(ButtonHandle button, double time) { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: button_resume_down(ButtonHandle button, double time) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(button, ButtonEvent::T_resume_down, time)); } @@ -314,7 +314,7 @@ button_resume_down(ButtonHandle button, double time) { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: button_up(ButtonHandle button, double time) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(button, ButtonEvent::T_up, time)); } @@ -326,7 +326,7 @@ button_up(ButtonHandle button, double time) { //////////////////////////////////////////////////////////////////// void GraphicsWindowInputDevice:: keystroke(int keycode, double time) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(keycode, time)); } @@ -339,7 +339,7 @@ keystroke(int keycode, double time) { void GraphicsWindowInputDevice:: candidate(const wstring &candidate_string, size_t highlight_start, size_t highlight_end, size_t cursor_pos) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _button_events.push_back(ButtonEvent(candidate_string, highlight_start, highlight_end, cursor_pos)); diff --git a/panda/src/display/graphicsWindowInputDevice.h b/panda/src/display/graphicsWindowInputDevice.h index 42bd18da18..f67b6276c3 100644 --- a/panda/src/display/graphicsWindowInputDevice.h +++ b/panda/src/display/graphicsWindowInputDevice.h @@ -25,8 +25,8 @@ #include "pdeque.h" #include "pvector.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" //////////////////////////////////////////////////////////////////// @@ -100,7 +100,7 @@ private: }; typedef pdeque ButtonEvents; - Mutex _lock; + LightMutex _lock; GraphicsWindow *_host; diff --git a/panda/src/display/lru.h b/panda/src/display/lru.h index 96ed91b4b8..e08aeff0aa 100644 --- a/panda/src/display/lru.h +++ b/panda/src/display/lru.h @@ -18,8 +18,8 @@ #define ENABLE_MUTEX 1 #if ENABLE_MUTEX -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" #define LruMutexHolder(mutex) MutexHolder(mutex) #else #define LruMutexHolder(mutex) diff --git a/panda/src/egg/eggData.cxx b/panda/src/egg/eggData.cxx index 4751e12566..f079c5cb41 100644 --- a/panda/src/egg/eggData.cxx +++ b/panda/src/egg/eggData.cxx @@ -24,7 +24,7 @@ #include "string_utils.h" #include "dSearchPath.h" #include "virtualFileSystem.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "zStream.h" extern int eggyyparse(); @@ -122,7 +122,7 @@ read(istream &in) { int error_count; { - MutexHolder holder(egg_lock); + LightMutexHolder holder(egg_lock); egg_init_parser(in, get_egg_filename(), data, data); eggyyparse(); egg_cleanup_parser(); diff --git a/panda/src/egg/eggNode.cxx b/panda/src/egg/eggNode.cxx index c0fd5b0a2c..2fa933320e 100644 --- a/panda/src/egg/eggNode.cxx +++ b/panda/src/egg/eggNode.cxx @@ -254,7 +254,7 @@ parse_egg(const string &egg_syntax) { istringstream in(egg_syntax); - MutexHolder holder(egg_lock); + LightMutexHolder holder(egg_lock); egg_init_parser(in, "", this, group); diff --git a/panda/src/egg/lexer.cxx.prebuilt b/panda/src/egg/lexer.cxx.prebuilt index 7154a3c10b..fbb6f9948d 100644 --- a/panda/src/egg/lexer.cxx.prebuilt +++ b/panda/src/egg/lexer.cxx.prebuilt @@ -745,7 +745,7 @@ char *yytext; #include "parser.h" #include "indent.h" #include "pnotify.h" -#include "pmutex.h" +#include "lightMutex.h" #include "thread.h" #include @@ -760,7 +760,7 @@ static int yyinput(void); // declared by flex. //////////////////////////////////////////////////////////////////// // This mutex protects all of these global variables. -Mutex egg_lock; +LightMutex egg_lock; // We'll increment line_number and col_number as we parse the file, so // that we can report the position of an error. diff --git a/panda/src/egg/lexer.lxx b/panda/src/egg/lexer.lxx index 5f40ac590a..85ab939a94 100644 --- a/panda/src/egg/lexer.lxx +++ b/panda/src/egg/lexer.lxx @@ -13,7 +13,7 @@ #include "parser.h" #include "indent.h" #include "pnotify.h" -#include "pmutex.h" +#include "lightMutex.h" #include "thread.h" #include @@ -28,7 +28,7 @@ static int yyinput(void); // declared by flex. //////////////////////////////////////////////////////////////////// // This mutex protects all of these global variables. -Mutex egg_lock; +LightMutex egg_lock; // We'll increment line_number and col_number as we parse the file, so // that we can report the position of an error. diff --git a/panda/src/egg/parserDefs.h b/panda/src/egg/parserDefs.h index 950c0ce078..3ea01ad75a 100644 --- a/panda/src/egg/parserDefs.h +++ b/panda/src/egg/parserDefs.h @@ -26,9 +26,9 @@ #include class EggGroupNode; -class Mutex; +class LightMutex; -extern Mutex egg_lock; +extern LightMutex egg_lock; void egg_init_parser(istream &in, const string &filename, EggObject *tos, EggGroupNode *egg_top_node); diff --git a/panda/src/event/asyncTaskChain.h b/panda/src/event/asyncTaskChain.h index 110f87945d..74c38420aa 100644 --- a/panda/src/event/asyncTaskChain.h +++ b/panda/src/event/asyncTaskChain.h @@ -21,7 +21,6 @@ #include "asyncTaskCollection.h" #include "typedReferenceCount.h" #include "thread.h" -#include "pmutex.h" #include "conditionVarFull.h" #include "pvector.h" #include "pdeque.h" diff --git a/panda/src/event/asyncTaskManager.h b/panda/src/event/asyncTaskManager.h index 445b05cefd..2f5cb7ed39 100644 --- a/panda/src/event/asyncTaskManager.h +++ b/panda/src/event/asyncTaskManager.h @@ -23,6 +23,7 @@ #include "typedReferenceCount.h" #include "thread.h" #include "pmutex.h" +#include "mutexHolder.h" #include "conditionVarFull.h" #include "pvector.h" #include "pdeque.h" diff --git a/panda/src/event/eventQueue.cxx b/panda/src/event/eventQueue.cxx index c83dbaa8ee..4752abd6e0 100644 --- a/panda/src/event/eventQueue.cxx +++ b/panda/src/event/eventQueue.cxx @@ -14,7 +14,7 @@ #include "eventQueue.h" #include "config_event.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" EventQueue *EventQueue::_global_event_queue = NULL; @@ -50,7 +50,7 @@ queue_event(CPT_Event event) { return; } - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _queue.push_back(event); if (event_cat.is_spam() || event_cat.is_debug()) { @@ -73,7 +73,7 @@ queue_event(CPT_Event event) { //////////////////////////////////////////////////////////////////// void EventQueue:: clear() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _queue.clear(); } @@ -86,7 +86,7 @@ clear() { //////////////////////////////////////////////////////////////////// bool EventQueue:: is_queue_empty() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _queue.empty(); } @@ -109,7 +109,7 @@ is_queue_full() const { //////////////////////////////////////////////////////////////////// CPT_Event EventQueue:: dequeue_event() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); CPT_Event result = _queue.front(); _queue.pop_front(); diff --git a/panda/src/event/eventQueue.h b/panda/src/event/eventQueue.h index bba370ef89..0aef01d6f6 100644 --- a/panda/src/event/eventQueue.h +++ b/panda/src/event/eventQueue.h @@ -19,7 +19,7 @@ #include "event.h" #include "pt_Event.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pdeque.h" //////////////////////////////////////////////////////////////////// @@ -50,7 +50,7 @@ private: typedef pdeque Events; Events _queue; - Mutex _lock; + LightMutex _lock; }; #include "eventQueue.I" diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 3e769105a1..f10b69bab3 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -42,7 +42,7 @@ #include "string_utils.h" #include "pnmImage.h" #include "config_gobj.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "indirectLess.h" #include "pStatTimer.h" #include "load_prc_file.h" @@ -1670,7 +1670,7 @@ end_frame(Thread *current_thread) { // Now is a good time to delete any pending display lists. { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!_deleted_display_lists.empty()) { DeletedDisplayLists::iterator ddli; for (ddli = _deleted_display_lists.begin(); @@ -2795,7 +2795,7 @@ release_shader(ShaderContext *sc) { //////////////////////////////////////////////////////////////////// void CLP(GraphicsStateGuardian):: record_deleted_display_list(GLuint index) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _deleted_display_lists.push_back(index); } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index 7ec0b183ae..241a484443 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -33,7 +33,7 @@ #include "pset.h" #include "pmap.h" #include "geomVertexArrayData.h" -#include "pmutex.h" +#include "lightMutex.h" class PlaneNode; class Light; @@ -503,7 +503,7 @@ public: GLenum _mirror_edge_clamp; GLenum _mirror_border_clamp; - Mutex _lock; + LightMutex _lock; typedef pvector DeletedDisplayLists; DeletedDisplayLists _deleted_display_lists; DeletedDisplayLists _deleted_queries; diff --git a/panda/src/glstuff/glOcclusionQueryContext_src.cxx b/panda/src/glstuff/glOcclusionQueryContext_src.cxx index ec0e3f2731..793fc0fdbf 100644 --- a/panda/src/glstuff/glOcclusionQueryContext_src.cxx +++ b/panda/src/glstuff/glOcclusionQueryContext_src.cxx @@ -14,7 +14,7 @@ #include "pnotify.h" #include "dcast.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "pStatTimer.h" TypeHandle CLP(OcclusionQueryContext)::_type_handle; @@ -30,7 +30,7 @@ CLP(OcclusionQueryContext):: // Tell the GSG to recycle this index when it gets around to it. CLP(GraphicsStateGuardian) *glgsg; DCAST_INTO_V(glgsg, _gsg); - MutexHolder holder(glgsg->_lock); + LightMutexHolder holder(glgsg->_lock); glgsg->_deleted_queries.push_back(_index); _index = 0; diff --git a/panda/src/glxdisplay/glxGraphicsPipe.h b/panda/src/glxdisplay/glxGraphicsPipe.h index 3b2ef435bf..ffba429592 100644 --- a/panda/src/glxdisplay/glxGraphicsPipe.h +++ b/panda/src/glxdisplay/glxGraphicsPipe.h @@ -19,8 +19,8 @@ #include "graphicsWindow.h" #include "graphicsPipe.h" #include "glgsg.h" -#include "pmutex.h" -#include "reMutex.h" +#include "lightMutex.h" +#include "lightReMutex.h" class FrameBufferProperties; @@ -151,7 +151,7 @@ private: public: // This Mutex protects any X library calls, which all have to be // single-threaded. In particular, it protects glXMakeCurrent(). - static ReMutex _x_mutex; + static LightReMutex _x_mutex; public: static TypeHandle get_class_type() { diff --git a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx index ea4e21e586..903a47f1a1 100644 --- a/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx +++ b/panda/src/glxdisplay/glxGraphicsStateGuardian.cxx @@ -15,7 +15,7 @@ #include "glxGraphicsStateGuardian.h" #include "config_glxdisplay.h" #include "config_glgsg.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include @@ -388,7 +388,7 @@ glx_is_at_least_version(int major_version, int minor_version) const { void glxGraphicsStateGuardian:: gl_flush() const { // This call requires synchronization with X. - ReMutexHolder holder(glxGraphicsPipe::_x_mutex); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); GLGraphicsStateGuardian::gl_flush(); } @@ -400,7 +400,7 @@ gl_flush() const { GLenum glxGraphicsStateGuardian:: gl_get_error() const { // This call requires synchronization with X. - ReMutexHolder holder(glxGraphicsPipe::_x_mutex); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); return GLGraphicsStateGuardian::gl_get_error(); } diff --git a/panda/src/glxdisplay/glxGraphicsWindow.cxx b/panda/src/glxdisplay/glxGraphicsWindow.cxx index eea8f18f10..5dce6241b6 100644 --- a/panda/src/glxdisplay/glxGraphicsWindow.cxx +++ b/panda/src/glxdisplay/glxGraphicsWindow.cxx @@ -25,7 +25,7 @@ #include "pStatTimer.h" #include "textEncoder.h" #include "throw_event.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include #include @@ -151,7 +151,7 @@ begin_frame(FrameMode mode, Thread *current_thread) { glxGraphicsStateGuardian *glxgsg; DCAST_INTO_R(glxgsg, _gsg, false); { - ReMutexHolder holder(glxGraphicsPipe::_x_mutex); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); if (glXGetCurrentDisplay() == _display && glXGetCurrentDrawable() == _xwindow && @@ -231,7 +231,7 @@ begin_flip() { //make_current(); - ReMutexHolder holder(glxGraphicsPipe::_x_mutex); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); glXSwapBuffers(_display, _xwindow); } } @@ -248,7 +248,7 @@ begin_flip() { //////////////////////////////////////////////////////////////////// void glxGraphicsWindow:: process_events() { - ReMutexHolder holder(glxGraphicsPipe::_x_mutex); + LightReMutexHolder holder(glxGraphicsPipe::_x_mutex); GraphicsWindow::process_events(); diff --git a/panda/src/gobj/adaptiveLru.I b/panda/src/gobj/adaptiveLru.I index b707a520d6..8c30c7f2bc 100644 --- a/panda/src/gobj/adaptiveLru.I +++ b/panda/src/gobj/adaptiveLru.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE size_t AdaptiveLru:: get_total_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _total_size; } @@ -33,7 +33,7 @@ get_total_size() const { //////////////////////////////////////////////////////////////////// INLINE size_t AdaptiveLru:: get_max_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _max_size; } @@ -47,7 +47,7 @@ get_max_size() const { //////////////////////////////////////////////////////////////////// INLINE void AdaptiveLru:: set_max_size(size_t max_size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _max_size = max_size; if (_total_size > _max_size) { do_evict_to(_max_size, false); @@ -61,7 +61,7 @@ set_max_size(size_t max_size) { //////////////////////////////////////////////////////////////////// INLINE void AdaptiveLru:: consider_evict() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_total_size > _max_size) { do_evict_to(_max_size, false); } @@ -76,7 +76,7 @@ consider_evict() { //////////////////////////////////////////////////////////////////// INLINE void AdaptiveLru:: evict_to(size_t target_size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_total_size > target_size) { do_evict_to(target_size, true); } @@ -91,7 +91,7 @@ evict_to(size_t target_size) { //////////////////////////////////////////////////////////////////// INLINE bool AdaptiveLru:: validate() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_validate(); } @@ -219,7 +219,7 @@ get_lru_size() const { INLINE void AdaptiveLruPage:: set_lru_size(size_t lru_size) { if (_lru != (AdaptiveLru *)NULL) { - MutexHolder holder(_lru->_lock); + LightMutexHolder holder(_lru->_lock); _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; _lru_size = lru_size; diff --git a/panda/src/gobj/adaptiveLru.cxx b/panda/src/gobj/adaptiveLru.cxx index 10846a0e39..36ef45e175 100644 --- a/panda/src/gobj/adaptiveLru.cxx +++ b/panda/src/gobj/adaptiveLru.cxx @@ -234,7 +234,7 @@ count_active_size() const { //////////////////////////////////////////////////////////////////// void AdaptiveLru:: begin_epoch() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_partial_lru_update(_max_updates_per_frame); if (_total_size > _max_size) { do_evict_to(_max_size, false); @@ -250,7 +250,7 @@ begin_epoch() { //////////////////////////////////////////////////////////////////// void AdaptiveLru:: output(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << "AdaptiveLru " << get_name() << ", " << _total_size << " of " << _max_size; } @@ -268,7 +268,7 @@ write(ostream &out, int indent_level) const { // the freshest in the LRU. Things at the end of the list will be // the next to be evicted. - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int index; for (index = 0; index < LPP_TotalPriorities; ++index) { @@ -302,7 +302,7 @@ write(ostream &out, int indent_level) const { void AdaptiveLru:: do_add_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _total_size += page->_lru_size; ((AdaptiveLruPageDynamicList *)page)->insert_before(&_page_array[page->_priority]); @@ -317,7 +317,7 @@ do_add_page(AdaptiveLruPage *page) { void AdaptiveLru:: do_remove_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _total_size -= page->_lru_size; ((AdaptiveLruPageDynamicList *)page)->remove_from_list(); @@ -332,7 +332,7 @@ do_remove_page(AdaptiveLruPage *page) { void AdaptiveLru:: do_access_page(AdaptiveLruPage *page) { nassertv(page != (AdaptiveLruPage *)NULL && page->_lru == this); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (page->_current_frame_identifier == _current_frame_identifier) { // This is the second or more time this page is accessed this diff --git a/panda/src/gobj/adaptiveLru.h b/panda/src/gobj/adaptiveLru.h index e1e4f4c0e6..2d38758918 100644 --- a/panda/src/gobj/adaptiveLru.h +++ b/panda/src/gobj/adaptiveLru.h @@ -18,8 +18,8 @@ #include "pandabase.h" #include "linkedListNode.h" #include "namable.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" class AdaptiveLruPage; @@ -99,7 +99,7 @@ private: void do_evict_to(size_t target_size, bool hard_evict); bool do_validate(); - Mutex _lock; + LightMutex _lock; size_t _total_size; size_t _max_size; diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 79fc44e3a3..924a1dba8c 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -23,7 +23,7 @@ #include "bamWriter.h" #include "boundingSphere.h" #include "boundingBox.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "config_mathutil.h" UpdateSeq Geom::_next_modified; @@ -1005,7 +1005,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// void Geom:: clear_cache() { - MutexHolder holder(_cache_lock); + LightMutexHolder holder(_cache_lock); for (Cache::iterator ci = _cache.begin(); ci != _cache.end(); ++ci) { @@ -1028,7 +1028,7 @@ clear_cache() { //////////////////////////////////////////////////////////////////// void Geom:: clear_cache_stage(Thread *current_thread) { - MutexHolder holder(_cache_lock); + LightMutexHolder holder(_cache_lock); for (Cache::iterator ci = _cache.begin(); ci != _cache.end(); ++ci) { @@ -1558,7 +1558,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void Geom::CacheEntry:: evict_callback() { - MutexHolder holder(_source->_cache_lock); + LightMutexHolder holder(_source->_cache_lock); Cache::iterator ci = _source->_cache.find(&_key); nassertv(ci != _source->_cache.end()); nassertv((*ci).second == this); diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index db46be2b98..6729755fa6 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -39,7 +39,7 @@ #include "boundingVolume.h" #include "pStatCollector.h" #include "deletedChain.h" -#include "pmutex.h" +#include "lightMutex.h" class GeomContext; class PreparedGraphicsObjects; @@ -321,7 +321,7 @@ private: typedef CycleDataStageWriter CDStageWriter; Cache _cache; - Mutex _cache_lock; + LightMutex _cache_lock; // This works just like the Texture contexts: each Geom keeps a // record of all the PGO objects that hold the Geom, and vice-versa. diff --git a/panda/src/gobj/geomCacheEntry.cxx b/panda/src/gobj/geomCacheEntry.cxx index e49e7cb1f6..1560880806 100644 --- a/panda/src/gobj/geomCacheEntry.cxx +++ b/panda/src/gobj/geomCacheEntry.cxx @@ -14,7 +14,7 @@ #include "geomCacheEntry.h" #include "geomCacheManager.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "config_gobj.h" #include "clockObject.h" @@ -39,7 +39,7 @@ record(Thread *current_thread) { PT(GeomCacheEntry) keepme = this; GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); - MutexHolder holder(cache_mgr->_lock); + LightMutexHolder holder(cache_mgr->_lock); if (gobj_cat.is_debug()) { gobj_cat.debug() @@ -79,7 +79,7 @@ record(Thread *current_thread) { void GeomCacheEntry:: refresh(Thread *current_thread) { GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); - MutexHolder holder(cache_mgr->_lock); + LightMutexHolder holder(cache_mgr->_lock); nassertv(_next != (GeomCacheEntry *)NULL && _prev != (GeomCacheEntry *)NULL); remove_from_list(); @@ -114,7 +114,7 @@ erase() { } GeomCacheManager *cache_mgr = GeomCacheManager::get_global_ptr(); - MutexHolder holder(cache_mgr->_lock); + LightMutexHolder holder(cache_mgr->_lock); remove_from_list(); --cache_mgr->_total_size; diff --git a/panda/src/gobj/geomCacheManager.cxx b/panda/src/gobj/geomCacheManager.cxx index 969865d92d..61dc8b4a64 100644 --- a/panda/src/gobj/geomCacheManager.cxx +++ b/panda/src/gobj/geomCacheManager.cxx @@ -14,7 +14,7 @@ #include "geomCacheManager.h" #include "geomCacheEntry.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" GeomCacheManager *GeomCacheManager::_global_ptr = NULL; @@ -59,7 +59,7 @@ GeomCacheManager:: //////////////////////////////////////////////////////////////////// void GeomCacheManager:: flush() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); evict_old_entries(0, false); } diff --git a/panda/src/gobj/geomCacheManager.h b/panda/src/gobj/geomCacheManager.h index 7a5c8b4a76..34979b356c 100644 --- a/panda/src/gobj/geomCacheManager.h +++ b/panda/src/gobj/geomCacheManager.h @@ -17,7 +17,7 @@ #include "pandabase.h" #include "config_gobj.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pStatCollector.h" class GeomCacheEntry; @@ -63,7 +63,7 @@ public: private: // This mutex protects all operations on this object, especially the // linked-list operations. - Mutex _lock; + LightMutex _lock; int _total_size; diff --git a/panda/src/gobj/geomMunger.cxx b/panda/src/gobj/geomMunger.cxx index a97c6ef850..1300617883 100644 --- a/panda/src/gobj/geomMunger.cxx +++ b/panda/src/gobj/geomMunger.cxx @@ -15,8 +15,8 @@ #include "geomMunger.h" #include "geom.h" #include "geomCacheManager.h" -#include "mutexHolder.h" -#include "reMutexHolder.h" +#include "lightMutexHolder.h" +#include "lightReMutexHolder.h" #include "pStatTimer.h" GeomMunger::Registry *GeomMunger::_registry = NULL; @@ -36,7 +36,7 @@ GeomMunger(GraphicsStateGuardianBase *gsg) : { #ifndef NDEBUG Registry *registry = get_registry(); - ReMutexHolder holder(registry->_registry_lock); + LightReMutexHolder holder(registry->_registry_lock); _registered_key = registry->_mungers.end(); #endif } @@ -52,7 +52,7 @@ GeomMunger(const GeomMunger ©) : { #ifndef NDEBUG Registry *registry = get_registry(); - ReMutexHolder holder(registry->_registry_lock); + LightReMutexHolder holder(registry->_registry_lock); _registered_key = registry->_mungers.end(); #endif } @@ -168,7 +168,7 @@ munge_geom(CPT(Geom) &geom, CPT(GeomVertexData) &data, // Create a new entry for the result. entry = new Geom::CacheEntry(orig_geom, source_data, this); { - MutexHolder holder(orig_geom->_cache_lock); + LightMutexHolder holder(orig_geom->_cache_lock); bool inserted = orig_geom->_cache.insert(Geom::Cache::value_type(&entry->_key, entry)).second; if (!inserted) { // Some other thread must have beat us to the punch. Never @@ -203,7 +203,7 @@ do_munge_format(const GeomVertexFormat *format, nassertr(_is_registered, NULL); nassertr(format->is_registered(), NULL); - MutexHolder holder(_formats_lock); + LightMutexHolder holder(_formats_lock); Formats &formats = _formats_by_animation[animation]; @@ -281,7 +281,7 @@ do_premunge_format(const GeomVertexFormat *format) { nassertr(_is_registered, NULL); nassertr(format->is_registered(), NULL); - MutexHolder holder(_formats_lock); + LightMutexHolder holder(_formats_lock); Formats::iterator fi; fi = _premunge_formats.find(format); @@ -472,7 +472,7 @@ register_munger(GeomMunger *munger, Thread *current_thread) { // will be automatically deleted when this function returns. PT(GeomMunger) pt_munger = munger; - ReMutexHolder holder(_registry_lock); + LightReMutexHolder holder(_registry_lock); Mungers::iterator mi = _mungers.insert(munger).first; GeomMunger *new_munger = (*mi); @@ -493,7 +493,7 @@ register_munger(GeomMunger *munger, Thread *current_thread) { //////////////////////////////////////////////////////////////////// void GeomMunger::Registry:: unregister_munger(GeomMunger *munger) { - ReMutexHolder holder(_registry_lock); + LightReMutexHolder holder(_registry_lock); nassertv(munger->is_registered()); nassertv(munger->_registered_key != _mungers.end()); @@ -510,7 +510,7 @@ unregister_munger(GeomMunger *munger) { //////////////////////////////////////////////////////////////////// void GeomMunger::Registry:: unregister_mungers_for_gsg(GraphicsStateGuardianBase *gsg) { - ReMutexHolder holder(_registry_lock); + LightReMutexHolder holder(_registry_lock); Mungers::iterator mi = _mungers.begin(); while (mi != _mungers.end()) { diff --git a/panda/src/gobj/geomMunger.h b/panda/src/gobj/geomMunger.h index d981729859..c1e9b45b12 100644 --- a/panda/src/gobj/geomMunger.h +++ b/panda/src/gobj/geomMunger.h @@ -23,8 +23,8 @@ #include "geomCacheEntry.h" #include "indirectCompareTo.h" #include "pStatCollector.h" -#include "pmutex.h" -#include "reMutex.h" +#include "lightMutex.h" +#include "lightReMutex.h" #include "pointerTo.h" #include "pmap.h" #include "pset.h" @@ -127,7 +127,7 @@ private: Formats _premunge_formats; // This mutex protects the above. - Mutex _formats_lock; + LightMutex _formats_lock; GraphicsStateGuardianBase *_gsg; @@ -141,7 +141,7 @@ private: void unregister_mungers_for_gsg(GraphicsStateGuardianBase *gsg); Mungers _mungers; - ReMutex _registry_lock; + LightReMutex _registry_lock; }; // We store the iterator into the above registry, while we are diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 52ff617f34..2ca951d382 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -28,7 +28,7 @@ #include "cycleDataStageWriter.h" #include "pipelineCycler.h" #include "pmap.h" -#include "reMutex.h" +#include "lightReMutex.h" #include "simpleLru.h" #include "vertexDataBuffer.h" #include "config_gobj.h" @@ -166,7 +166,7 @@ private: // This implements read-write locking. Anyone who gets the data for // reading or writing will hold this mutex during the lock. - ReMutex _rw_lock; + LightReMutex _rw_lock; public: static TypeHandle get_class_type() { diff --git a/panda/src/gobj/geomVertexArrayFormat.cxx b/panda/src/gobj/geomVertexArrayFormat.cxx index f8b43178c8..54ee96477a 100644 --- a/panda/src/gobj/geomVertexArrayFormat.cxx +++ b/panda/src/gobj/geomVertexArrayFormat.cxx @@ -20,7 +20,7 @@ #include "bamReader.h" #include "bamWriter.h" #include "indirectLess.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" GeomVertexArrayFormat::Registry *GeomVertexArrayFormat::_registry = NULL; TypeHandle GeomVertexArrayFormat::_type_handle; @@ -202,7 +202,7 @@ GeomVertexArrayFormat:: bool GeomVertexArrayFormat:: unref() const { Registry *registry = get_registry(); - MutexHolder holder(registry->_lock); + LightMutexHolder holder(registry->_lock); if (ReferenceCount::unref()) { return true; @@ -782,7 +782,7 @@ register_format(GeomVertexArrayFormat *format) { GeomVertexArrayFormat *new_format; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); ArrayFormats::iterator fi = _formats.insert(format).first; new_format = (*fi); if (!new_format->is_registered()) { diff --git a/panda/src/gobj/geomVertexArrayFormat.h b/panda/src/gobj/geomVertexArrayFormat.h index c2bc3b647c..8199c1696d 100644 --- a/panda/src/gobj/geomVertexArrayFormat.h +++ b/panda/src/gobj/geomVertexArrayFormat.h @@ -22,7 +22,7 @@ #include "indirectCompareTo.h" #include "pvector.h" #include "pmap.h" -#include "pmutex.h" +#include "lightMutex.h" class GeomVertexFormat; class GeomVertexData; @@ -146,7 +146,7 @@ private: void unregister_format(GeomVertexArrayFormat *format); ArrayFormats _formats; - Mutex _lock; + LightMutex _lock; }; static Registry *_registry; diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 5478fdff2e..9ddce956de 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -800,7 +800,7 @@ convert_to(const GeomVertexFormat *new_format) const { // Create a new entry for the result. entry = new CacheEntry((GeomVertexData *)this, new_format); { - MutexHolder holder(_cache_lock); + LightMutexHolder holder(_cache_lock); bool inserted = ((GeomVertexData *)this)->_cache.insert(Cache::value_type(&entry->_key, entry)).second; if (!inserted) { // Some other thread must have beat us to the punch. Never @@ -1230,7 +1230,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// void GeomVertexData:: clear_cache() { - MutexHolder holder(_cache_lock); + LightMutexHolder holder(_cache_lock); for (Cache::iterator ci = _cache.begin(); ci != _cache.end(); ++ci) { @@ -1253,7 +1253,7 @@ clear_cache() { //////////////////////////////////////////////////////////////////// void GeomVertexData:: clear_cache_stage() { - MutexHolder holder(_cache_lock); + LightMutexHolder holder(_cache_lock); for (Cache::iterator ci = _cache.begin(); ci != _cache.end(); ++ci) { @@ -1793,7 +1793,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void GeomVertexData::CacheEntry:: evict_callback() { - MutexHolder holder(_source->_cache_lock); + LightMutexHolder holder(_source->_cache_lock); Cache::iterator ci = _source->_cache.find(&_key); nassertv(ci != _source->_cache.end()); nassertv((*ci).second == this); diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index 2108176bb4..6a0441e0ab 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -305,7 +305,7 @@ private: typedef CycleDataStageWriter CDStageWriter; Cache _cache; - Mutex _cache_lock; + LightMutex _cache_lock; private: void update_animated_vertices(CData *cdata, Thread *current_thread); diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index f8ea05ab24..a1bb49208d 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -15,7 +15,7 @@ #include "geomVertexFormat.h" #include "geomVertexData.h" #include "geomMunger.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include "indent.h" #include "bamReader.h" #include "bamWriter.h" @@ -96,7 +96,7 @@ GeomVertexFormat:: bool GeomVertexFormat:: unref() const { Registry *registry = get_registry(); - ReMutexHolder holder(registry->_lock); + LightReMutexHolder holder(registry->_lock); if (ReferenceCount::unref()) { return true; @@ -1058,7 +1058,7 @@ register_format(GeomVertexFormat *format) { GeomVertexFormat *new_format; { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); Formats::iterator fi = _formats.insert(format).first; new_format = (*fi); if (!new_format->is_registered()) { diff --git a/panda/src/gobj/geomVertexFormat.h b/panda/src/gobj/geomVertexFormat.h index fc03bdbb52..2e4796e65a 100644 --- a/panda/src/gobj/geomVertexFormat.h +++ b/panda/src/gobj/geomVertexFormat.h @@ -27,7 +27,7 @@ #include "pset.h" #include "pvector.h" #include "indirectCompareTo.h" -#include "reMutex.h" +#include "lightReMutex.h" class FactoryParams; class GeomVertexData; @@ -218,7 +218,7 @@ private: void unregister_format(GeomVertexFormat *format); Formats _formats; - ReMutex _lock; + LightReMutex _lock; CPT(GeomVertexFormat) _v3; CPT(GeomVertexFormat) _v3n3; diff --git a/panda/src/gobj/internalName.cxx b/panda/src/gobj/internalName.cxx index 72c6d1d5cd..217da70f57 100644 --- a/panda/src/gobj/internalName.cxx +++ b/panda/src/gobj/internalName.cxx @@ -65,7 +65,7 @@ InternalName:: #ifndef NDEBUG if (_parent != (const InternalName *)NULL) { // unref() should have removed us from our parent's table already. - MutexHolder holder(_parent->_name_table_lock); + LightMutexHolder holder(_parent->_name_table_lock); NameTable::iterator ni = _parent->_name_table.find(_basename); nassertv(ni == _parent->_name_table.end()); } @@ -88,7 +88,7 @@ unref() const { return TypedWritableReferenceCount::unref(); } - MutexHolder holder(_parent->_name_table_lock); + LightMutexHolder holder(_parent->_name_table_lock); if (ReferenceCount::unref()) { return true; @@ -123,7 +123,7 @@ append(const string &name) { return append(name.substr(0, dot))->append(name.substr(dot + 1)); } - MutexHolder holder(_name_table_lock); + LightMutexHolder holder(_name_table_lock); NameTable::iterator ni = _name_table.find(name); if (ni != _name_table.end()) { diff --git a/panda/src/gobj/internalName.h b/panda/src/gobj/internalName.h index f2891ac4e8..717e7ea77a 100644 --- a/panda/src/gobj/internalName.h +++ b/panda/src/gobj/internalName.h @@ -20,7 +20,7 @@ #include "typedWritableReferenceCount.h" #include "pointerTo.h" #include "pmap.h" -#include "pmutex.h" +#include "lightMutex.h" class FactoryParams; @@ -93,7 +93,7 @@ private: typedef phash_map NameTable; NameTable _name_table; - Mutex _name_table_lock; + LightMutex _name_table_lock; static PT(InternalName) _root; static PT(InternalName) _error; diff --git a/panda/src/gobj/materialPool.cxx b/panda/src/gobj/materialPool.cxx index 6fa0226432..193892a90e 100644 --- a/panda/src/gobj/materialPool.cxx +++ b/panda/src/gobj/materialPool.cxx @@ -14,7 +14,7 @@ #include "materialPool.h" #include "config_gobj.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" MaterialPool *MaterialPool::_global_ptr = (MaterialPool *)NULL; @@ -37,7 +37,7 @@ write(ostream &out) { //////////////////////////////////////////////////////////////////// Material *MaterialPool:: ns_get_material(Material *temp) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); CPT(Material) cpttemp = temp; Materials::iterator mi = _materials.find(cpttemp); @@ -60,7 +60,7 @@ ns_get_material(Material *temp) { //////////////////////////////////////////////////////////////////// int MaterialPool:: ns_garbage_collect() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int num_released = 0; Materials new_set; @@ -91,7 +91,7 @@ ns_garbage_collect() { //////////////////////////////////////////////////////////////////// void MaterialPool:: ns_list_contents(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << _materials.size() << " materials:\n"; Materials::const_iterator mi; diff --git a/panda/src/gobj/materialPool.h b/panda/src/gobj/materialPool.h index 432833ae10..354e0be876 100644 --- a/panda/src/gobj/materialPool.h +++ b/panda/src/gobj/materialPool.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "material.h" #include "pointerTo.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pset.h" //////////////////////////////////////////////////////////////////// @@ -57,7 +57,7 @@ private: static MaterialPool *_global_ptr; - Mutex _lock; + LightMutex _lock; // We store a map of CPT(Material) to PT(Material). These are two // equivalent structures, but different pointers. The first pointer diff --git a/panda/src/gobj/simpleAllocator.I b/panda/src/gobj/simpleAllocator.I index e42694f14a..f51ee911a7 100644 --- a/panda/src/gobj/simpleAllocator.I +++ b/panda/src/gobj/simpleAllocator.I @@ -19,7 +19,7 @@ // Description: //////////////////////////////////////////////////////////////////// INLINE SimpleAllocator:: -SimpleAllocator(size_t max_size, Mutex &lock) : +SimpleAllocator(size_t max_size, LightMutex &lock) : LinkedListNode(true), _total_size(0), _max_size(max_size), @@ -39,7 +39,7 @@ SimpleAllocator(size_t max_size, Mutex &lock) : //////////////////////////////////////////////////////////////////// SimpleAllocatorBlock *SimpleAllocator:: alloc(size_t size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_alloc(size); } @@ -51,7 +51,7 @@ alloc(size_t size) { //////////////////////////////////////////////////////////////////// INLINE bool SimpleAllocator:: is_empty() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_is_empty(); } @@ -62,7 +62,7 @@ is_empty() const { //////////////////////////////////////////////////////////////////// INLINE size_t SimpleAllocator:: get_total_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _total_size; } @@ -73,7 +73,7 @@ get_total_size() const { //////////////////////////////////////////////////////////////////// INLINE size_t SimpleAllocator:: get_max_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _max_size; } @@ -86,7 +86,7 @@ get_max_size() const { //////////////////////////////////////////////////////////////////// INLINE void SimpleAllocator:: set_max_size(size_t max_size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _max_size = max_size; } @@ -102,7 +102,7 @@ set_max_size(size_t max_size) { //////////////////////////////////////////////////////////////////// INLINE size_t SimpleAllocator:: get_contiguous() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _contiguous; } @@ -114,7 +114,7 @@ get_contiguous() const { //////////////////////////////////////////////////////////////////// INLINE SimpleAllocatorBlock *SimpleAllocator:: get_first_block() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return (_next == this) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; } @@ -194,7 +194,7 @@ INLINE SimpleAllocatorBlock:: INLINE void SimpleAllocatorBlock:: free() { if (_allocator != (SimpleAllocator *)NULL) { - MutexHolder holder(_allocator->_lock); + LightMutexHolder holder(_allocator->_lock); do_free(); } } @@ -254,7 +254,7 @@ is_free() const { INLINE size_t SimpleAllocatorBlock:: get_max_size() const { nassertr(_allocator != (SimpleAllocator *)NULL, 0); - MutexHolder holder(_allocator->_lock); + LightMutexHolder holder(_allocator->_lock); return do_get_max_size(); } @@ -268,7 +268,7 @@ get_max_size() const { INLINE bool SimpleAllocatorBlock:: realloc(size_t size) { nassertr(_allocator != (SimpleAllocator *)NULL, false); - MutexHolder holder(_allocator->_lock); + LightMutexHolder holder(_allocator->_lock); return do_realloc(size); } @@ -281,7 +281,7 @@ realloc(size_t size) { INLINE SimpleAllocatorBlock *SimpleAllocatorBlock:: get_next_block() const { nassertr(_allocator != (SimpleAllocator *)NULL, NULL); - MutexHolder holder(_allocator->_lock); + LightMutexHolder holder(_allocator->_lock); return (_next == _allocator) ? (SimpleAllocatorBlock *)NULL : (SimpleAllocatorBlock *)_next; } diff --git a/panda/src/gobj/simpleAllocator.cxx b/panda/src/gobj/simpleAllocator.cxx index 8b0bd2a1de..b129090ffa 100644 --- a/panda/src/gobj/simpleAllocator.cxx +++ b/panda/src/gobj/simpleAllocator.cxx @@ -23,7 +23,7 @@ SimpleAllocator:: ~SimpleAllocator() { // We're shutting down. Force-free everything remaining. if (_next != (LinkedListNode *)this) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); while (_next != (LinkedListNode *)this) { nassertv(_next != (LinkedListNode *)NULL); ((SimpleAllocatorBlock *)_next)->do_free(); @@ -38,7 +38,7 @@ SimpleAllocator:: //////////////////////////////////////////////////////////////////// void SimpleAllocator:: output(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; } @@ -50,7 +50,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void SimpleAllocator:: write(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << "SimpleAllocator, " << _total_size << " of " << _max_size << " allocated"; @@ -187,7 +187,7 @@ output(ostream &out) const { if (_allocator == (SimpleAllocator *)NULL) { out << "free block\n"; } else { - MutexHolder holder(_allocator->_lock); + LightMutexHolder holder(_allocator->_lock); out << "block of size " << _size << " at " << _start; } } diff --git a/panda/src/gobj/simpleAllocator.h b/panda/src/gobj/simpleAllocator.h index f494697bec..7a36373f0f 100644 --- a/panda/src/gobj/simpleAllocator.h +++ b/panda/src/gobj/simpleAllocator.h @@ -17,8 +17,8 @@ #include "pandabase.h" #include "linkedListNode.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" class SimpleAllocatorBlock; @@ -32,7 +32,7 @@ class SimpleAllocatorBlock; //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_GOBJ SimpleAllocator : public LinkedListNode { PUBLISHED: - INLINE SimpleAllocator(size_t max_size, Mutex &lock); + INLINE SimpleAllocator(size_t max_size, LightMutex &lock); virtual ~SimpleAllocator(); INLINE SimpleAllocatorBlock *alloc(size_t size); @@ -82,7 +82,7 @@ protected: // A derived class may also use it to protect itself as well, but // take care to call do_alloc() instead of alloc() etc. as // necessary. - Mutex &_lock; + LightMutex &_lock; friend class SimpleAllocatorBlock; }; diff --git a/panda/src/gobj/simpleLru.I b/panda/src/gobj/simpleLru.I index 6c53024a08..09fb9618ac 100644 --- a/panda/src/gobj/simpleLru.I +++ b/panda/src/gobj/simpleLru.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE size_t SimpleLru:: get_total_size() const { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); return _total_size; } @@ -33,7 +33,7 @@ get_total_size() const { //////////////////////////////////////////////////////////////////// INLINE size_t SimpleLru:: get_max_size() const { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); return _max_size; } @@ -47,7 +47,7 @@ get_max_size() const { //////////////////////////////////////////////////////////////////// INLINE void SimpleLru:: set_max_size(size_t max_size) { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); _max_size = max_size; if (_total_size > _max_size) { do_evict_to(_max_size, false); @@ -61,7 +61,7 @@ set_max_size(size_t max_size) { //////////////////////////////////////////////////////////////////// INLINE void SimpleLru:: consider_evict() { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); if (_total_size > _max_size) { do_evict_to(_max_size, false); } @@ -76,7 +76,7 @@ consider_evict() { //////////////////////////////////////////////////////////////////// INLINE void SimpleLru:: evict_to(size_t target_size) { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); if (_total_size > target_size) { do_evict_to(target_size, true); } @@ -105,7 +105,7 @@ begin_epoch() { //////////////////////////////////////////////////////////////////// INLINE bool SimpleLru:: validate() { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); return do_validate(); } @@ -151,7 +151,7 @@ operator = (const SimpleLruPage ©) { //////////////////////////////////////////////////////////////////// INLINE SimpleLru *SimpleLruPage:: get_lru() const { - MutexHolder holder(SimpleLru::_global_lock); + LightMutexHolder holder(SimpleLru::_global_lock); return _lru; } @@ -162,7 +162,7 @@ get_lru() const { //////////////////////////////////////////////////////////////////// INLINE void SimpleLruPage:: dequeue_lru() { - MutexHolder holder(SimpleLru::_global_lock); + LightMutexHolder holder(SimpleLru::_global_lock); if (_lru != (SimpleLru *)NULL) { remove_from_list(); @@ -217,7 +217,7 @@ get_lru_size() const { //////////////////////////////////////////////////////////////////// INLINE void SimpleLruPage:: set_lru_size(size_t lru_size) { - MutexHolder holder(SimpleLru::_global_lock); + LightMutexHolder holder(SimpleLru::_global_lock); if (_lru != (SimpleLru *)NULL) { _lru->_total_size -= _lru_size; _lru->_total_size += lru_size; diff --git a/panda/src/gobj/simpleLru.cxx b/panda/src/gobj/simpleLru.cxx index 4c911406ca..fcd94d0647 100644 --- a/panda/src/gobj/simpleLru.cxx +++ b/panda/src/gobj/simpleLru.cxx @@ -19,7 +19,7 @@ // a concrete object, so that it won't get destructed when the program // exits. (If it did, there would be an ordering issue between it and // the various concrete SimpleLru objects which reference it.) -Mutex &SimpleLru::_global_lock = *new Mutex; +LightMutex &SimpleLru::_global_lock = *new LightMutex; //////////////////////////////////////////////////////////////////// // Function: SimpleLru::Constructor @@ -68,7 +68,7 @@ SimpleLru:: //////////////////////////////////////////////////////////////////// void SimpleLruPage:: enqueue_lru(SimpleLru *lru) { - MutexHolder holder(SimpleLru::_global_lock); + LightMutexHolder holder(SimpleLru::_global_lock); if (_lru == lru) { if (_lru != (SimpleLru *)NULL) { @@ -104,7 +104,7 @@ enqueue_lru(SimpleLru *lru) { //////////////////////////////////////////////////////////////////// size_t SimpleLru:: count_active_size() const { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); size_t total = 0; LinkedListNode *node = _prev; @@ -123,7 +123,7 @@ count_active_size() const { //////////////////////////////////////////////////////////////////// void SimpleLru:: output(ostream &out) const { - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); out << "SimpleLru " << get_name() << ", " << _total_size << " of " << _max_size; } @@ -141,7 +141,7 @@ write(ostream &out, int indent_level) const { // the freshest in the LRU. Things at the end of the list will be // the next to be evicted. - MutexHolder holder(_global_lock); + LightMutexHolder holder(_global_lock); LinkedListNode *node = _prev; while (node != _active_marker && node != this) { SimpleLruPage *page = (SimpleLruPage *)node; diff --git a/panda/src/gobj/simpleLru.h b/panda/src/gobj/simpleLru.h index db3a749672..da7ad94b08 100644 --- a/panda/src/gobj/simpleLru.h +++ b/panda/src/gobj/simpleLru.h @@ -18,8 +18,8 @@ #include "pandabase.h" #include "linkedListNode.h" #include "namable.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" class SimpleLruPage; @@ -48,7 +48,7 @@ PUBLISHED: void write(ostream &out, int indent_level) const; public: - static Mutex &_global_lock; + static LightMutex &_global_lock; private: void do_evict_to(size_t target_size, bool hard_evict); diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index 1fbac95c22..dbf55582ee 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -24,7 +24,7 @@ #include "texturePoolFilter.h" #include "configVariableList.h" #include "load_dso.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" TexturePool *TexturePool::_global_ptr; @@ -51,7 +51,7 @@ write(ostream &out) { //////////////////////////////////////////////////////////////////// void TexturePool:: register_texture_type(MakeTextureFunc *func, const string &extensions) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); vector_string words; extract_words(downcase(extensions), words); @@ -70,7 +70,7 @@ register_texture_type(MakeTextureFunc *func, const string &extensions) { //////////////////////////////////////////////////////////////////// void TexturePool:: register_filter(TexturePoolFilter *filter) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); gobj_cat.info() << "Registering Texture filter " << *filter << "\n"; @@ -87,7 +87,7 @@ register_filter(TexturePoolFilter *filter) { //////////////////////////////////////////////////////////////////// TexturePool::MakeTextureFunc *TexturePool:: get_texture_type(const string &extension) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); string c = downcase(extension); TypeRegistry::const_iterator ti; @@ -139,7 +139,7 @@ make_texture(const string &extension) const { //////////////////////////////////////////////////////////////////// void TexturePool:: write_texture_types(ostream &out, int indent_level) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PNMFileTypeRegistry *pnm_reg = PNMFileTypeRegistry::get_global_ptr(); pnm_reg->write(out, indent_level); @@ -206,7 +206,7 @@ TexturePool() { //////////////////////////////////////////////////////////////////// bool TexturePool:: ns_has_texture(const Filename &orig_filename) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Filename filename(orig_filename); @@ -247,7 +247,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, vfs->resolve_filename(filename, get_model_path()); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Textures::const_iterator ti; ti = _textures.find(filename); if (ti != _textures.end()) { @@ -312,7 +312,7 @@ ns_load_texture(const Filename &orig_filename, int primary_file_num_channels, tex->_texture_pool_key = filename; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Now look again--someone may have just loaded this texture in // another thread. @@ -375,7 +375,7 @@ ns_load_texture(const Filename &orig_filename, vfs->resolve_filename(alpha_filename, get_model_path()); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Textures::const_iterator ti; ti = _textures.find(filename); @@ -444,7 +444,7 @@ ns_load_texture(const Filename &orig_filename, tex->_texture_pool_key = filename; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; @@ -494,7 +494,7 @@ ns_load_3d_texture(const Filename &filename_pattern, vfs->resolve_filename(filename, get_model_path()); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Textures::const_iterator ti; ti = _textures.find(filename); @@ -549,7 +549,7 @@ ns_load_3d_texture(const Filename &filename_pattern, tex->_texture_pool_key = filename; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; @@ -588,7 +588,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, vfs->resolve_filename(filename, get_model_path()); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Textures::const_iterator ti; ti = _textures.find(filename); @@ -643,7 +643,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, tex->_texture_pool_key = filename; { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Now look again. Textures::const_iterator ti; @@ -673,7 +673,7 @@ ns_load_cube_map(const Filename &filename_pattern, bool read_mipmaps, //////////////////////////////////////////////////////////////////// Texture *TexturePool:: ns_get_normalization_cube_map(int size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_normalization_cube_map == (Texture *)NULL) { _normalization_cube_map = new Texture("normalization_cube_map"); @@ -693,7 +693,7 @@ ns_get_normalization_cube_map(int size) { //////////////////////////////////////////////////////////////////// Texture *TexturePool:: ns_get_alpha_scale_map() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_alpha_scale_map == (Texture *)NULL) { _alpha_scale_map = new Texture("alpha_scale_map"); @@ -711,7 +711,7 @@ ns_get_alpha_scale_map() { void TexturePool:: ns_add_texture(Texture *tex) { PT(Texture) keep = tex; - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!tex->_texture_pool_key.empty()) { ns_release_texture(tex); @@ -734,7 +734,7 @@ ns_add_texture(Texture *tex) { //////////////////////////////////////////////////////////////////// void TexturePool:: ns_release_texture(Texture *tex) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!tex->_texture_pool_key.empty()) { Textures::iterator ti; @@ -753,7 +753,7 @@ ns_release_texture(Texture *tex) { //////////////////////////////////////////////////////////////////// void TexturePool:: ns_release_all_textures() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Textures::iterator ti; for (ti = _textures.begin(); ti != _textures.end(); ++ti) { @@ -772,7 +772,7 @@ ns_release_all_textures() { //////////////////////////////////////////////////////////////////// int TexturePool:: ns_garbage_collect() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int num_released = 0; Textures new_set; @@ -814,7 +814,7 @@ ns_garbage_collect() { //////////////////////////////////////////////////////////////////// void TexturePool:: ns_list_contents(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int total_size; int total_ram_size; @@ -985,7 +985,7 @@ pre_load(const Filename &orig_filename, const Filename &orig_alpha_filename, bool read_mipmaps, const LoaderOptions &options) { PT(Texture) tex; - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); FilterRegistry::iterator fi; for (fi = _filter_registry.begin(); @@ -1011,7 +1011,7 @@ PT(Texture) TexturePool:: post_load(Texture *tex) { PT(Texture) result = tex; - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); FilterRegistry::iterator fi; for (fi = _filter_registry.begin(); diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index fbb79b34f2..0a8015df13 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -20,7 +20,7 @@ #include "filename.h" #include "config_gobj.h" #include "loaderOptions.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pmap.h" class TexturePoolFilter; @@ -136,7 +136,7 @@ private: static TexturePool *_global_ptr; - Mutex _lock; + LightMutex _lock; typedef phash_map Textures; Textures _textures; string _fake_texture_image; diff --git a/panda/src/gobj/vertexDataBook.I b/panda/src/gobj/vertexDataBook.I index 30e6f01ef4..edcc6bf820 100644 --- a/panda/src/gobj/vertexDataBook.I +++ b/panda/src/gobj/vertexDataBook.I @@ -21,7 +21,7 @@ //////////////////////////////////////////////////////////////////// INLINE VertexDataBlock *VertexDataBook:: alloc(size_t size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_alloc(size); } diff --git a/panda/src/gobj/vertexDataBook.cxx b/panda/src/gobj/vertexDataBook.cxx index 2a7d11883e..6465d4e684 100644 --- a/panda/src/gobj/vertexDataBook.cxx +++ b/panda/src/gobj/vertexDataBook.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "vertexDataBook.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" //////////////////////////////////////////////////////////////////// // Function: VertexDataBook::Constructor @@ -44,7 +44,7 @@ VertexDataBook:: //////////////////////////////////////////////////////////////////// size_t VertexDataBook:: count_total_page_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); size_t total = 0; Pages::const_iterator pi; @@ -63,7 +63,7 @@ count_total_page_size() const { //////////////////////////////////////////////////////////////////// size_t VertexDataBook:: count_total_page_size(VertexDataPage::RamClass ram_class) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); size_t total = 0; Pages::const_iterator pi; @@ -83,7 +83,7 @@ count_total_page_size(VertexDataPage::RamClass ram_class) const { //////////////////////////////////////////////////////////////////// size_t VertexDataBook:: count_allocated_size() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); size_t total = 0; Pages::const_iterator pi; @@ -102,7 +102,7 @@ count_allocated_size() const { //////////////////////////////////////////////////////////////////// size_t VertexDataBook:: count_allocated_size(VertexDataPage::RamClass ram_class) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); size_t total = 0; Pages::const_iterator pi; @@ -124,7 +124,7 @@ count_allocated_size(VertexDataPage::RamClass ram_class) const { //////////////////////////////////////////////////////////////////// void VertexDataBook:: save_to_disk() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Pages::iterator pi; for (pi = _pages.begin(); pi != _pages.end(); ++pi) { diff --git a/panda/src/gobj/vertexDataBook.h b/panda/src/gobj/vertexDataBook.h index 4f5754138b..c1617857ac 100644 --- a/panda/src/gobj/vertexDataBook.h +++ b/panda/src/gobj/vertexDataBook.h @@ -16,8 +16,8 @@ #define VERTEXDATABOOK_H #include "pandabase.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" #include "vertexDataPage.h" #include "indirectLess.h" #include "plist.h" @@ -58,7 +58,7 @@ private: typedef pset > Pages; Pages _pages; - Mutex _lock; + LightMutex _lock; friend class VertexDataPage; }; diff --git a/panda/src/gobj/vertexDataBuffer.I b/panda/src/gobj/vertexDataBuffer.I index 6a92708e9b..0ceb50b434 100644 --- a/panda/src/gobj/vertexDataBuffer.I +++ b/panda/src/gobj/vertexDataBuffer.I @@ -74,7 +74,7 @@ INLINE VertexDataBuffer:: //////////////////////////////////////////////////////////////////// INLINE const unsigned char *VertexDataBuffer:: get_read_pointer(bool force) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_resident_data != (unsigned char *)NULL || _size == 0) { return _resident_data; @@ -95,7 +95,7 @@ get_read_pointer(bool force) const { //////////////////////////////////////////////////////////////////// INLINE unsigned char *VertexDataBuffer:: get_write_pointer() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_resident_data == (unsigned char *)NULL && _size != 0) { do_page_in(); @@ -123,7 +123,7 @@ get_size() const { //////////////////////////////////////////////////////////////////// INLINE void VertexDataBuffer:: clean_realloc(size_t size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_clean_realloc(size); } @@ -136,7 +136,7 @@ clean_realloc(size_t size) { //////////////////////////////////////////////////////////////////// INLINE void VertexDataBuffer:: unclean_realloc(size_t size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_unclean_realloc(size); } @@ -162,7 +162,7 @@ clear() { //////////////////////////////////////////////////////////////////// INLINE void VertexDataBuffer:: page_out(VertexDataBook &book) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_page_out(book); } @@ -174,8 +174,8 @@ page_out(VertexDataBook &book) { //////////////////////////////////////////////////////////////////// INLINE void VertexDataBuffer:: swap(VertexDataBuffer &other) { - MutexHolder holder(_lock); - MutexHolder holder2(other._lock); + LightMutexHolder holder(_lock); + LightMutexHolder holder2(other._lock); unsigned char *resident_data = _resident_data; size_t size = _size; diff --git a/panda/src/gobj/vertexDataBuffer.cxx b/panda/src/gobj/vertexDataBuffer.cxx index 384c7287a2..aed159d4ce 100644 --- a/panda/src/gobj/vertexDataBuffer.cxx +++ b/panda/src/gobj/vertexDataBuffer.cxx @@ -24,8 +24,8 @@ TypeHandle VertexDataBuffer::_type_handle; //////////////////////////////////////////////////////////////////// void VertexDataBuffer:: operator = (const VertexDataBuffer ©) { - MutexHolder holder(_lock); - MutexHolder holder2(copy._lock); + LightMutexHolder holder(_lock); + LightMutexHolder holder2(copy._lock); if (_resident_data != (unsigned char *)NULL) { nassertv(_size != 0); diff --git a/panda/src/gobj/vertexDataBuffer.h b/panda/src/gobj/vertexDataBuffer.h index c89c3dc504..e90e7ff702 100644 --- a/panda/src/gobj/vertexDataBuffer.h +++ b/panda/src/gobj/vertexDataBuffer.h @@ -21,8 +21,8 @@ #include "pointerTo.h" #include "virtualFile.h" #include "pStatCollector.h" -#include "pmutex.h" -#include "mutexHolder.h" +#include "lightMutex.h" +#include "lightMutexHolder.h" //////////////////////////////////////////////////////////////////// // Class : VertexDataBuffer @@ -86,7 +86,7 @@ private: unsigned char *_resident_data; size_t _size; PT(VertexDataBlock) _block; - Mutex _lock; + LightMutex _lock; public: static TypeHandle get_class_type() { diff --git a/panda/src/gobj/vertexDataPage.I b/panda/src/gobj/vertexDataPage.I index 947efbd278..aa103376eb 100644 --- a/panda/src/gobj/vertexDataPage.I +++ b/panda/src/gobj/vertexDataPage.I @@ -22,7 +22,7 @@ //////////////////////////////////////////////////////////////////// INLINE VertexDataPage::RamClass VertexDataPage:: get_ram_class() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _ram_class; } @@ -36,7 +36,7 @@ get_ram_class() const { //////////////////////////////////////////////////////////////////// INLINE VertexDataPage::RamClass VertexDataPage:: get_pending_ram_class() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _pending_ram_class; } @@ -49,7 +49,7 @@ get_pending_ram_class() const { //////////////////////////////////////////////////////////////////// INLINE void VertexDataPage:: request_resident() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_ram_class != RC_resident) { request_ram_class(RC_resident); } @@ -66,7 +66,7 @@ request_resident() { //////////////////////////////////////////////////////////////////// INLINE VertexDataBlock *VertexDataPage:: alloc(size_t size) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_alloc(size); } @@ -78,7 +78,7 @@ alloc(size_t size) { //////////////////////////////////////////////////////////////////// INLINE VertexDataBlock *VertexDataPage:: get_first_block() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return (VertexDataBlock *)SimpleAllocator::get_first_block(); } @@ -142,7 +142,7 @@ get_save_file() { //////////////////////////////////////////////////////////////////// INLINE bool VertexDataPage:: save_to_disk() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_save_to_disk(); } @@ -208,7 +208,7 @@ get_num_pending_writes() { //////////////////////////////////////////////////////////////////// INLINE unsigned char *VertexDataPage:: get_page_data(bool force) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (_ram_class != RC_resident || _pending_ram_class != RC_resident) { if (force) { make_resident_now(); diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index b10e43ac07..73db5df16e 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -17,7 +17,7 @@ #include "vertexDataSaveFile.h" #include "vertexDataBook.h" #include "pStatTimer.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "memoryHook.h" #ifdef HAVE_ZLIB @@ -68,9 +68,9 @@ SimpleLru *VertexDataPage::_global_lru[RC_end_of_list] = { VertexDataSaveFile *VertexDataPage::_save_file; -// This mutex is (mostly) unused. We just need a Mutex to pass to the -// Book Constructor, below. -Mutex VertexDataPage::_unused_mutex; +// This mutex is (mostly) unused. We just need a LightMutex to pass +// to the Book Constructor, below. +LightMutex VertexDataPage::_unused_mutex; PStatCollector VertexDataPage::_vdata_compress_pcollector("*:Vertex Data:Compress"); PStatCollector VertexDataPage::_vdata_decompress_pcollector("*:Vertex Data:Decompress"); @@ -149,7 +149,7 @@ VertexDataPage:: // Since the only way to delete a page is via the // changed_contiguous() method, the lock will already be held. - // MutexHolder holder(_lock); + // LightMutexHolder holder(_lock); { MutexHolder holder2(_tlock); @@ -287,7 +287,7 @@ changed_contiguous() { //////////////////////////////////////////////////////////////////// void VertexDataPage:: evict_lru() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); switch (_ram_class) { case RC_resident: @@ -1037,7 +1037,7 @@ thread_main() { _tlock.release(); { - MutexHolder holder(_working_page->_lock); + LightMutexHolder holder(_working_page->_lock); switch (ram_class) { case RC_resident: _working_page->make_resident(); diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 71c7670ce1..683a852d07 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -21,10 +21,12 @@ #include "pStatCollector.h" #include "vertexDataSaveFile.h" #include "pmutex.h" +#include "lightMutex.h" #include "conditionVar.h" #include "conditionVarFull.h" #include "thread.h" #include "mutexHolder.h" +#include "lightMutexHolder.h" #include "pdeque.h" class VertexDataBook; @@ -167,7 +169,7 @@ private: size_t _book_size; size_t _block_size; - //Mutex _lock; // Inherited from SimpleAllocator. Protects above members. + //LightMutex _lock; // Inherited from SimpleAllocator. Protects above members. RamClass _pending_ram_class; // Protected by _tlock. VertexDataBook *_book; // never changes. @@ -208,7 +210,7 @@ private: static VertexDataSaveFile *_save_file; - static Mutex _unused_mutex; + static LightMutex _unused_mutex; static PStatCollector _vdata_compress_pcollector; static PStatCollector _vdata_decompress_pcollector; diff --git a/panda/src/gobj/vertexDataSaveFile.cxx b/panda/src/gobj/vertexDataSaveFile.cxx index 8c31510338..815341f012 100644 --- a/panda/src/gobj/vertexDataSaveFile.cxx +++ b/panda/src/gobj/vertexDataSaveFile.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "vertexDataSaveFile.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "clockObject.h" #ifndef _WIN32 @@ -189,7 +189,7 @@ VertexDataSaveFile:: //////////////////////////////////////////////////////////////////// PT(VertexDataSaveBlock) VertexDataSaveFile:: write_data(const unsigned char *data, size_t size, bool compressed) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!_is_valid) { return NULL; @@ -269,7 +269,7 @@ write_data(const unsigned char *data, size_t size, bool compressed) { //////////////////////////////////////////////////////////////////// bool VertexDataSaveFile:: read_data(unsigned char *data, size_t size, VertexDataSaveBlock *block) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!_is_valid) { return false; diff --git a/panda/src/gobj/vertexDataSaveFile.h b/panda/src/gobj/vertexDataSaveFile.h index 948d8a7ba8..0daa681eb3 100644 --- a/panda/src/gobj/vertexDataSaveFile.h +++ b/panda/src/gobj/vertexDataSaveFile.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "simpleAllocator.h" #include "filename.h" -#include "pmutex.h" +#include "lightMutex.h" #if defined(_WIN32) #define WIN32_LEAN_AND_MEAN @@ -59,7 +59,7 @@ private: Filename _filename; bool _is_valid; size_t _total_file_size; - Mutex _lock; + LightMutex _lock; #ifdef _WIN32 HANDLE _handle; diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.cxx b/panda/src/gsgbase/graphicsStateGuardianBase.cxx index 519db344d4..ef2be5cfd8 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.cxx +++ b/panda/src/gsgbase/graphicsStateGuardianBase.cxx @@ -13,12 +13,12 @@ //////////////////////////////////////////////////////////////////// #include "graphicsStateGuardianBase.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include GraphicsStateGuardianBase::GSGs GraphicsStateGuardianBase::_gsgs; GraphicsStateGuardianBase *GraphicsStateGuardianBase::_default_gsg; -Mutex GraphicsStateGuardianBase::_lock; +LightMutex GraphicsStateGuardianBase::_lock; TypeHandle GraphicsStateGuardianBase::_type_handle; //////////////////////////////////////////////////////////////////// @@ -35,7 +35,7 @@ TypeHandle GraphicsStateGuardianBase::_type_handle; //////////////////////////////////////////////////////////////////// GraphicsStateGuardianBase *GraphicsStateGuardianBase:: get_default_gsg() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _default_gsg; } @@ -47,7 +47,7 @@ get_default_gsg() { //////////////////////////////////////////////////////////////////// void GraphicsStateGuardianBase:: set_default_gsg(GraphicsStateGuardianBase *default_gsg) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (find(_gsgs.begin(), _gsgs.end(), default_gsg) == _gsgs.end()) { // The specified GSG doesn't exist or it has already destructed. nassertv(false); @@ -65,7 +65,7 @@ set_default_gsg(GraphicsStateGuardianBase *default_gsg) { //////////////////////////////////////////////////////////////////// void GraphicsStateGuardianBase:: add_gsg(GraphicsStateGuardianBase *gsg) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (find(_gsgs.begin(), _gsgs.end(), gsg) != _gsgs.end()) { // Already on the list. @@ -87,7 +87,7 @@ add_gsg(GraphicsStateGuardianBase *gsg) { //////////////////////////////////////////////////////////////////// void GraphicsStateGuardianBase:: remove_gsg(GraphicsStateGuardianBase *gsg) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); GSGs::iterator gi = find(_gsgs.begin(), _gsgs.end(), gsg); if (gi == _gsgs.end()) { diff --git a/panda/src/gsgbase/graphicsStateGuardianBase.h b/panda/src/gsgbase/graphicsStateGuardianBase.h index 58b97a11d3..ed253dc733 100644 --- a/panda/src/gsgbase/graphicsStateGuardianBase.h +++ b/panda/src/gsgbase/graphicsStateGuardianBase.h @@ -19,7 +19,7 @@ #include "typedWritableReferenceCount.h" #include "luse.h" -#include "pmutex.h" +#include "lightMutex.h" // A handful of forward references. @@ -222,7 +222,7 @@ private: typedef pvector GSGs; static GSGs _gsgs; static GraphicsStateGuardianBase *_default_gsg; - static Mutex _lock; + static LightMutex _lock; public: static TypeHandle get_class_type() { diff --git a/panda/src/net/connection.cxx b/panda/src/net/connection.cxx index 43bfc5a13b..1a49881003 100644 --- a/panda/src/net/connection.cxx +++ b/panda/src/net/connection.cxx @@ -21,7 +21,7 @@ #include "config_express.h" // for collect_tcp #include "trueClock.h" #include "pnotify.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include "socket_ip.h" #include "socket_tcp.h" #include "socket_udp.h" @@ -179,7 +179,7 @@ get_collect_tcp_interval() const { //////////////////////////////////////////////////////////////////// bool Connection:: consider_flush() { - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); if (!_collect_tcp) { return do_flush(); @@ -206,7 +206,7 @@ consider_flush() { //////////////////////////////////////////////////////////////////// bool Connection:: flush() { - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); return do_flush(); } @@ -361,7 +361,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { Socket_UDP *udp; DCAST_INTO_R(udp, _socket, false); - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); DatagramUDPHeader header(datagram); string data; data += header.get_header(); @@ -403,7 +403,7 @@ send_datagram(const NetDatagram &datagram, int tcp_header_size) { DatagramTCPHeader header(datagram, tcp_header_size); - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); _queued_data += header.get_header(); _queued_data += datagram.get_message(); _queued_count++; @@ -438,7 +438,7 @@ send_raw_datagram(const NetDatagram &datagram) { string data = datagram.get_message(); - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); Socket_Address addr = datagram.get_address().get_addr(); bool okflag = udp->SendTo(data, addr); #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS) @@ -459,7 +459,7 @@ send_raw_datagram(const NetDatagram &datagram) { } // We might queue up TCP packets for later sending. - ReMutexHolder holder(_write_mutex); + LightReMutexHolder holder(_write_mutex); _queued_data += datagram.get_message(); _queued_count++; diff --git a/panda/src/net/connection.h b/panda/src/net/connection.h index f97b2c169f..618efa6664 100644 --- a/panda/src/net/connection.h +++ b/panda/src/net/connection.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "referenceCount.h" #include "netAddress.h" -#include "reMutex.h" +#include "lightReMutex.h" class Socket_IP; class ConnectionManager; @@ -67,7 +67,7 @@ private: ConnectionManager *_manager; Socket_IP *_socket; - ReMutex _write_mutex; + LightReMutex _write_mutex; bool _collect_tcp; double _collect_tcp_interval; diff --git a/panda/src/net/connectionManager.cxx b/panda/src/net/connectionManager.cxx index 8df1e5f4b3..5559514928 100644 --- a/panda/src/net/connectionManager.cxx +++ b/panda/src/net/connectionManager.cxx @@ -18,7 +18,7 @@ #include "connectionWriter.h" #include "netAddress.h" #include "config_net.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "trueClock.h" #ifdef WIN32_VC @@ -238,7 +238,7 @@ close_connection(const PT(Connection) &connection) { } { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); Connections::iterator ci = _connections.find(connection); if (ci == _connections.end()) { // Already closed, or not part of this ConnectionManager. @@ -295,7 +295,7 @@ get_host_name() { //////////////////////////////////////////////////////////////////// void ConnectionManager:: new_connection(const PT(Connection) &connection) { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); _connections.insert(connection); } @@ -338,7 +338,7 @@ connection_reset(const PT(Connection) &connection, bool okflag) { //////////////////////////////////////////////////////////////////// void ConnectionManager:: add_reader(ConnectionReader *reader) { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); _readers.insert(reader); } @@ -350,7 +350,7 @@ add_reader(ConnectionReader *reader) { //////////////////////////////////////////////////////////////////// void ConnectionManager:: remove_reader(ConnectionReader *reader) { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); _readers.erase(reader); } @@ -362,7 +362,7 @@ remove_reader(ConnectionReader *reader) { //////////////////////////////////////////////////////////////////// void ConnectionManager:: add_writer(ConnectionWriter *writer) { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); _writers.insert(writer); } @@ -374,6 +374,6 @@ add_writer(ConnectionWriter *writer) { //////////////////////////////////////////////////////////////////// void ConnectionManager:: remove_writer(ConnectionWriter *writer) { - MutexHolder holder(_set_mutex); + LightMutexHolder holder(_set_mutex); _writers.erase(writer); } diff --git a/panda/src/net/connectionManager.h b/panda/src/net/connectionManager.h index aff9fbff9a..02fa040d8a 100644 --- a/panda/src/net/connectionManager.h +++ b/panda/src/net/connectionManager.h @@ -21,7 +21,7 @@ #include "connection.h" #include "pointerTo.h" #include "pset.h" -#include "pmutex.h" +#include "lightMutex.h" class NetAddress; class ConnectionReader; @@ -76,7 +76,7 @@ protected: Connections _connections; Readers _readers; Writers _writers; - Mutex _set_mutex; + LightMutex _set_mutex; private: friend class ConnectionReader; diff --git a/panda/src/net/connectionReader.cxx b/panda/src/net/connectionReader.cxx index cf074e6c01..4766d22525 100644 --- a/panda/src/net/connectionReader.cxx +++ b/panda/src/net/connectionReader.cxx @@ -21,7 +21,7 @@ #include "trueClock.h" #include "socket_udp.h" #include "socket_tcp.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "pnotify.h" #include "atomicAdjust.h" @@ -187,7 +187,7 @@ bool ConnectionReader:: add_connection(Connection *connection) { nassertr(connection != (Connection *)NULL, false); - MutexHolder holder(_sockets_mutex); + LightMutexHolder holder(_sockets_mutex); // Make sure it's not already on the _sockets list. Sockets::const_iterator si; @@ -216,7 +216,7 @@ add_connection(Connection *connection) { //////////////////////////////////////////////////////////////////// bool ConnectionReader:: remove_connection(Connection *connection) { - MutexHolder holder(_sockets_mutex); + LightMutexHolder holder(_sockets_mutex); // Walk through the list of sockets to find the one we're removing. Sockets::iterator si; @@ -247,7 +247,7 @@ remove_connection(Connection *connection) { //////////////////////////////////////////////////////////////////// bool ConnectionReader:: is_connection_ok(Connection *connection) { - MutexHolder holder(_sockets_mutex); + LightMutexHolder holder(_sockets_mutex); // Walk through the list of sockets to find the one we're asking // about. @@ -784,7 +784,7 @@ ConnectionReader::SocketInfo *ConnectionReader:: get_next_available_socket(bool allow_block, int current_thread_index) { // Go to sleep on the select() mutex. This guarantees that only one // thread is in this function at a time. - MutexHolder holder(_select_mutex); + LightMutexHolder holder(_select_mutex); do { // First, check the result from the previous select call. If @@ -865,7 +865,7 @@ rebuild_select_list() { _fdset.clear(); _selecting_sockets.clear(); - MutexHolder holder(_sockets_mutex); + LightMutexHolder holder(_sockets_mutex); Sockets::const_iterator si; for (si = _sockets.begin(); si != _sockets.end(); ++si) { SocketInfo *sinfo = (*si); diff --git a/panda/src/net/connectionReader.h b/panda/src/net/connectionReader.h index 9394dca769..d3730c3337 100644 --- a/panda/src/net/connectionReader.h +++ b/panda/src/net/connectionReader.h @@ -20,7 +20,7 @@ #include "connection.h" #include "pointerTo.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pvector.h" #include "pset.h" #include "socket_fdset.h" @@ -147,7 +147,7 @@ private: int _num_results; // Threads go to sleep on this mutex waiting for their chance to // read a socket. - Mutex _select_mutex; + LightMutex _select_mutex; // This is atomically updated with the index (in _threads) of the // thread that is currently waiting on the PR_Poll() call. It @@ -161,7 +161,7 @@ private: // delete them until they're no longer _busy. Sockets _removed_sockets; // Any operations on _sockets are protected by this mutex. - Mutex _sockets_mutex; + LightMutex _sockets_mutex; friend class ConnectionManager; diff --git a/panda/src/net/queuedConnectionReader.cxx b/panda/src/net/queuedConnectionReader.cxx index e947465ad7..99b18721ac 100644 --- a/panda/src/net/queuedConnectionReader.cxx +++ b/panda/src/net/queuedConnectionReader.cxx @@ -15,7 +15,7 @@ #include "queuedConnectionReader.h" #include "config_net.h" #include "trueClock.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" //////////////////////////////////////////////////////////////////// // Function: QueuedConnectionReader::Constructor @@ -141,7 +141,7 @@ receive_datagram(const NetDatagram &datagram) { //////////////////////////////////////////////////////////////////// void QueuedConnectionReader:: start_delay(double min_delay, double max_delay) { - MutexHolder holder(_dd_mutex); + LightMutexHolder holder(_dd_mutex); _min_delay = min_delay; _delay_variance = max(max_delay - min_delay, 0.0); _delay_active = true; @@ -156,7 +156,7 @@ start_delay(double min_delay, double max_delay) { //////////////////////////////////////////////////////////////////// void QueuedConnectionReader:: stop_delay() { - MutexHolder holder(_dd_mutex); + LightMutexHolder holder(_dd_mutex); _delay_active = false; // Copy the entire contents of the delay queue to the normal queue. @@ -180,7 +180,7 @@ stop_delay() { void QueuedConnectionReader:: get_delayed() { if (_delay_active) { - MutexHolder holder(_dd_mutex); + LightMutexHolder holder(_dd_mutex); double now = TrueClock::get_global_ptr()->get_short_time(); while (!_delayed.empty()) { const DelayedDatagram &dd = _delayed.front(); @@ -211,7 +211,7 @@ delay_datagram(const NetDatagram &datagram) { << "QueuedConnectionReader queue full!\n"; } } else { - MutexHolder holder(_dd_mutex); + LightMutexHolder holder(_dd_mutex); // Check the delay_active flag again, now that we have grabbed the // mutex. if (!_delay_active) { diff --git a/panda/src/net/queuedConnectionReader.h b/panda/src/net/queuedConnectionReader.h index 9987b2835e..7f5340342a 100644 --- a/panda/src/net/queuedConnectionReader.h +++ b/panda/src/net/queuedConnectionReader.h @@ -20,7 +20,7 @@ #include "connectionReader.h" #include "netDatagram.h" #include "queuedReturn.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pdeque.h" EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_NET, EXPTP_PANDA_NET, QueuedReturn); @@ -62,7 +62,7 @@ private: NetDatagram _datagram; }; - Mutex _dd_mutex; + LightMutex _dd_mutex; typedef pdeque Delayed; Delayed _delayed; bool _delay_active; diff --git a/panda/src/net/queuedReturn.I b/panda/src/net/queuedReturn.I index 25a6b50a08..dd03916edd 100644 --- a/panda/src/net/queuedReturn.I +++ b/panda/src/net/queuedReturn.I @@ -28,7 +28,7 @@ template void QueuedReturn:: set_max_queue_size(int max_size) { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); _max_queue_size = max_size; } @@ -52,7 +52,7 @@ get_max_queue_size() const { template int QueuedReturn:: get_current_queue_size() const { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); int size = _things.size(); return size; } @@ -134,7 +134,7 @@ thing_available() const { template bool QueuedReturn:: get_thing(Thing &result) { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); if (_things.empty()) { // Huh. Nothing after all. _available = false; @@ -157,7 +157,7 @@ get_thing(Thing &result) { template bool QueuedReturn:: enqueue_thing(const Thing &thing) { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); bool enqueue_ok = ((int)_things.size() < _max_queue_size); if (enqueue_ok) { _things.push_back(thing); @@ -181,7 +181,7 @@ enqueue_thing(const Thing &thing) { template bool QueuedReturn:: enqueue_unique_thing(const Thing &thing) { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); bool enqueue_ok = ((int)_things.size() < _max_queue_size); if (enqueue_ok) { if (find(_things.begin(), _things.end(), thing) == _things.end()) { diff --git a/panda/src/net/queuedReturn.h b/panda/src/net/queuedReturn.h index c4da4dad93..e50cc7b0cb 100644 --- a/panda/src/net/queuedReturn.h +++ b/panda/src/net/queuedReturn.h @@ -20,10 +20,10 @@ #include "connectionListener.h" #include "connection.h" #include "netAddress.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pdeque.h" #include "config_net.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include @@ -55,7 +55,7 @@ protected: bool enqueue_unique_thing(const Thing &thing); private: - Mutex _mutex; + LightMutex _mutex; pdeque _things; bool _available; int _max_queue_size; diff --git a/panda/src/net/recentConnectionReader.cxx b/panda/src/net/recentConnectionReader.cxx index b0247187f6..b544d258f2 100644 --- a/panda/src/net/recentConnectionReader.cxx +++ b/panda/src/net/recentConnectionReader.cxx @@ -14,7 +14,7 @@ #include "recentConnectionReader.h" #include "config_net.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" //////////////////////////////////////////////////////////////////// // Function: RecentConnectionReader::Constructor @@ -70,7 +70,7 @@ data_available() { //////////////////////////////////////////////////////////////////// bool RecentConnectionReader:: get_data(NetDatagram &result) { - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); if (!_available) { // Huh. Nothing after all. return false; @@ -117,7 +117,7 @@ receive_datagram(const NetDatagram &datagram) { << " bytes\n"; } - MutexHolder holder(_mutex); + LightMutexHolder holder(_mutex); _datagram = datagram; _available = true; } diff --git a/panda/src/net/recentConnectionReader.h b/panda/src/net/recentConnectionReader.h index fc9f272577..99c35ea337 100644 --- a/panda/src/net/recentConnectionReader.h +++ b/panda/src/net/recentConnectionReader.h @@ -19,7 +19,7 @@ #include "connectionReader.h" #include "netDatagram.h" -#include "pmutex.h" +#include "lightMutex.h" //////////////////////////////////////////////////////////////////// // Class : RecentConnectionReader @@ -48,7 +48,7 @@ protected: private: bool _available; Datagram _datagram; - Mutex _mutex; + LightMutex _mutex; }; #endif diff --git a/panda/src/pgraph/attribNodeRegistry.cxx b/panda/src/pgraph/attribNodeRegistry.cxx index fb732984ad..e8636ba7d3 100644 --- a/panda/src/pgraph/attribNodeRegistry.cxx +++ b/panda/src/pgraph/attribNodeRegistry.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "attribNodeRegistry.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" AttribNodeRegistry * TVOLATILE AttribNodeRegistry::_global_ptr; @@ -46,7 +46,7 @@ AttribNodeRegistry() { void AttribNodeRegistry:: add_node(const NodePath &attrib_node) { nassertv(!attrib_node.is_empty()); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); pair result = _entries.insert(Entry(attrib_node)); if (!result.second) { @@ -70,7 +70,7 @@ add_node(const NodePath &attrib_node) { bool AttribNodeRegistry:: remove_node(const NodePath &attrib_node) { nassertr(!attrib_node.is_empty(), false); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Entries::iterator ei = _entries.find(Entry(attrib_node)); if (ei != _entries.end()) { _entries.erase(ei); @@ -91,7 +91,7 @@ NodePath AttribNodeRegistry:: lookup_node(const NodePath &orig_node) const { nassertr(!orig_node.is_empty(), orig_node); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Entries::const_iterator ei = _entries.find(Entry(orig_node)); if (ei != _entries.end()) { return (*ei)._node; @@ -106,7 +106,7 @@ lookup_node(const NodePath &orig_node) const { //////////////////////////////////////////////////////////////////// int AttribNodeRegistry:: get_num_nodes() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _entries.size(); } @@ -117,7 +117,7 @@ get_num_nodes() const { //////////////////////////////////////////////////////////////////// NodePath AttribNodeRegistry:: get_node(int n) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(n >= 0 && n < (int)_entries.size(), NodePath()); return _entries[n]._node; } @@ -130,7 +130,7 @@ get_node(int n) const { //////////////////////////////////////////////////////////////////// TypeHandle AttribNodeRegistry:: get_node_type(int n) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(n >= 0 && n < (int)_entries.size(), TypeHandle::none()); return _entries[n]._type; } @@ -146,7 +146,7 @@ get_node_type(int n) const { //////////////////////////////////////////////////////////////////// string AttribNodeRegistry:: get_node_name(int n) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(n >= 0 && n < (int)_entries.size(), string()); return _entries[n]._name; } @@ -163,7 +163,7 @@ get_node_name(int n) const { int AttribNodeRegistry:: find_node(const NodePath &attrib_node) const { nassertr(!attrib_node.is_empty(), -1); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Entries::const_iterator ei = _entries.find(Entry(attrib_node)); if (ei != _entries.end()) { return ei - _entries.begin(); @@ -180,7 +180,7 @@ find_node(const NodePath &attrib_node) const { //////////////////////////////////////////////////////////////////// int AttribNodeRegistry:: find_node(TypeHandle type, const string &name) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Entries::const_iterator ei = _entries.find(Entry(type, name)); if (ei != _entries.end()) { return ei - _entries.begin(); @@ -195,7 +195,7 @@ find_node(TypeHandle type, const string &name) const { //////////////////////////////////////////////////////////////////// void AttribNodeRegistry:: remove_node(int n) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertv(n >= 0 && n < (int)_entries.size()); _entries.erase(_entries.begin() + n); } @@ -207,7 +207,7 @@ remove_node(int n) { //////////////////////////////////////////////////////////////////// void AttribNodeRegistry:: clear() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _entries.clear(); } @@ -218,7 +218,7 @@ clear() { //////////////////////////////////////////////////////////////////// void AttribNodeRegistry:: output(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); typedef pmap Counts; Counts counts; @@ -251,7 +251,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void AttribNodeRegistry:: write(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Entries::const_iterator ei; for (ei = _entries.begin(); ei != _entries.end(); ++ei) { diff --git a/panda/src/pgraph/attribNodeRegistry.h b/panda/src/pgraph/attribNodeRegistry.h index de155f4497..42b0f78678 100644 --- a/panda/src/pgraph/attribNodeRegistry.h +++ b/panda/src/pgraph/attribNodeRegistry.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "nodePath.h" #include "ordered_vector.h" -#include "pmutex.h" +#include "lightMutex.h" //////////////////////////////////////////////////////////////////// // Class : AttribNodeRegistry @@ -76,7 +76,7 @@ private: typedef ov_set Entries; Entries _entries; - Mutex _lock; + LightMutex _lock; static AttribNodeRegistry * TVOLATILE _global_ptr; }; diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index 0a1b9091b3..62df8f3ad1 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -15,7 +15,7 @@ #include "modelPool.h" #include "loader.h" #include "config_pgraph.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" ModelPool *ModelPool::_global_ptr = (ModelPool *)NULL; @@ -39,7 +39,7 @@ write(ostream &out) { //////////////////////////////////////////////////////////////////// bool ModelPool:: ns_has_model(const string &filename) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Models::const_iterator ti; ti = _models.find(filename); if (ti != _models.end() && (*ti).second != (ModelRoot *)NULL) { @@ -58,7 +58,7 @@ ns_has_model(const string &filename) { ModelRoot *ModelPool:: ns_load_model(const string &filename, const LoaderOptions &options) { { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Models::const_iterator ti; ti = _models.find(filename); if (ti != _models.end()) { @@ -91,7 +91,7 @@ ns_load_model(const string &filename, const LoaderOptions &options) { } { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Look again, in case someone has just loaded the model in // another thread. @@ -115,7 +115,7 @@ ns_load_model(const string &filename, const LoaderOptions &options) { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_add_model(const string &filename, ModelRoot *model) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // We blow away whatever model was there previously, if any. _models[filename] = model; } @@ -127,7 +127,7 @@ ns_add_model(const string &filename, ModelRoot *model) { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_release_model(const string &filename) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Models::iterator ti; ti = _models.find(filename); if (ti != _models.end()) { @@ -142,7 +142,7 @@ ns_release_model(const string &filename) { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_add_model(ModelRoot *model) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // We blow away whatever model was there previously, if any. _models[model->get_fullpath()] = model; } @@ -154,7 +154,7 @@ ns_add_model(ModelRoot *model) { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_release_model(ModelRoot *model) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Models::iterator ti; ti = _models.find(model->get_fullpath()); if (ti != _models.end()) { @@ -169,7 +169,7 @@ ns_release_model(ModelRoot *model) { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_release_all_models() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _models.clear(); } @@ -180,7 +180,7 @@ ns_release_all_models() { //////////////////////////////////////////////////////////////////// int ModelPool:: ns_garbage_collect() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int num_released = 0; Models new_set; @@ -211,7 +211,7 @@ ns_garbage_collect() { //////////////////////////////////////////////////////////////////// void ModelPool:: ns_list_contents(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << "model pool contents:\n"; diff --git a/panda/src/pgraph/modelPool.h b/panda/src/pgraph/modelPool.h index 2768913258..0c12479484 100644 --- a/panda/src/pgraph/modelPool.h +++ b/panda/src/pgraph/modelPool.h @@ -20,7 +20,7 @@ #include "filename.h" #include "modelRoot.h" #include "pointerTo.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pmap.h" #include "loaderOptions.h" @@ -86,7 +86,7 @@ private: static ModelPool *_global_ptr; - Mutex _lock; + LightMutex _lock; typedef pmap Models; Models _models; }; diff --git a/panda/src/pgraph/nodePathComponent.cxx b/panda/src/pgraph/nodePathComponent.cxx index 4d80a309b1..4bbe9b1180 100644 --- a/panda/src/pgraph/nodePathComponent.cxx +++ b/panda/src/pgraph/nodePathComponent.cxx @@ -13,12 +13,12 @@ //////////////////////////////////////////////////////////////////// #include "nodePathComponent.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" // We start the key counters off at 1, since 0 is reserved for an // empty NodePath (and also for an unassigned key). int NodePathComponent::_next_key = 1; -Mutex NodePathComponent::_key_lock("NodePathComponent::_key_lock"); +LightMutex NodePathComponent::_key_lock("NodePathComponent::_key_lock"); TypeHandle NodePathComponent::_type_handle; TypeHandle NodePathComponent::CData::_type_handle; @@ -72,7 +72,7 @@ NodePathComponent(PandaNode *node, NodePathComponent *next, //////////////////////////////////////////////////////////////////// int NodePathComponent:: get_key() const { - MutexHolder holder(_key_lock); + LightMutexHolder holder(_key_lock); if (_key == 0) { // The first time someone asks for a particular component's key, // we make it up on the spot. This helps keep us from wasting diff --git a/panda/src/pgraph/nodePathComponent.h b/panda/src/pgraph/nodePathComponent.h index 7e11a47ed5..0002d9464d 100644 --- a/panda/src/pgraph/nodePathComponent.h +++ b/panda/src/pgraph/nodePathComponent.h @@ -26,7 +26,7 @@ #include "cycleDataLockedStageReader.h" #include "cycleDataStageReader.h" #include "cycleDataStageWriter.h" -#include "pmutex.h" +#include "lightMutex.h" #include "deletedChain.h" //////////////////////////////////////////////////////////////////// @@ -113,7 +113,7 @@ private: typedef CycleDataStageWriter CDStageWriter; static int _next_key; - static Mutex _key_lock; + static LightMutex _key_lock; public: static TypeHandle get_class_type() { diff --git a/panda/src/pgraph/pandaNode.I b/panda/src/pgraph/pandaNode.I index 2e848fe6ca..67628a4e9d 100644 --- a/panda/src/pgraph/pandaNode.I +++ b/panda/src/pgraph/pandaNode.I @@ -818,7 +818,7 @@ verify_child_no_cycles(PandaNode *child_node) { INLINE void PandaNode:: set_dirty_prev_transform() { if (!_dirty_prev_transform) { - MutexHolder holder(_dirty_prev_transforms._lock); + LightMutexHolder holder(_dirty_prev_transforms._lock); if (!_dirty_prev_transform) { LinkedListNode::insert_before(&_dirty_prev_transforms); _dirty_prev_transform = true; @@ -835,7 +835,7 @@ set_dirty_prev_transform() { INLINE void PandaNode:: clear_dirty_prev_transform() { if (_dirty_prev_transform) { - MutexHolder holder(_dirty_prev_transforms._lock); + LightMutexHolder holder(_dirty_prev_transforms._lock); if (_dirty_prev_transform) { LinkedListNode::remove_from_list(); _dirty_prev_transform = false; diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 14e3d58358..e3e3c38647 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -26,7 +26,7 @@ #include "boundingBox.h" #include "pStatTimer.h" #include "config_mathutil.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include "graphicsStateGuardianBase.h" // This category is just temporary for debugging convenience. @@ -1298,7 +1298,7 @@ reset_all_prev_transform(Thread *current_thread) { nassertv(current_thread->get_pipeline_stage() == 0); PStatTimer timer(_reset_prev_pcollector, current_thread); - MutexHolder holder(_dirty_prev_transforms._lock); + LightMutexHolder holder(_dirty_prev_transforms._lock); LinkedListNode *list_node = _dirty_prev_transforms._next; while (list_node != &_dirty_prev_transforms) { @@ -1792,8 +1792,8 @@ replace_node(PandaNode *other) { // Fix up the NodePaths. { - ReMutexHolder holder1(other->_paths_lock); - ReMutexHolder holder2(_paths_lock); + LightReMutexHolder holder1(other->_paths_lock); + LightReMutexHolder holder2(_paths_lock); Paths::iterator pi; for (pi = other->_paths.begin(); pi != other->_paths.end(); ++pi) { (*pi)->_node = this; @@ -3031,7 +3031,7 @@ attach(NodePathComponent *parent, PandaNode *child_node, int sort, PT(NodePathComponent) child = new NodePathComponent(child_node, (NodePathComponent *)NULL, pipeline_stage, current_thread); - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); child_node->_paths.insert(child); return child; } @@ -3236,7 +3236,7 @@ reparent_one_stage(NodePathComponent *new_parent, NodePathComponent *child, #ifndef NDEBUG // The NodePathComponent should already be in the set. { - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); nassertr(child_node->_paths.find(child) != child_node->_paths.end(), false); } #endif // NDEBUG @@ -3262,7 +3262,7 @@ get_component(NodePathComponent *parent, PandaNode *child_node, nassertr(parent != (NodePathComponent *)NULL, (NodePathComponent *)NULL); PandaNode *parent_node = parent->get_node(); - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); // First, walk through the list of NodePathComponents we already // have on the child, looking for one that already exists, @@ -3309,7 +3309,7 @@ get_component(NodePathComponent *parent, PandaNode *child_node, PT(NodePathComponent) PandaNode:: get_top_component(PandaNode *child_node, bool force, int pipeline_stage, Thread *current_thread) { - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); // Walk through the list of NodePathComponents we already have on // the child, looking for one that already exists as a top node. @@ -3421,7 +3421,7 @@ r_get_generic_component(bool accept_ambiguity, bool &ambiguity_detected, //////////////////////////////////////////////////////////////////// void PandaNode:: delete_component(NodePathComponent *component) { - ReMutexHolder holder(_paths_lock); + LightReMutexHolder holder(_paths_lock); int num_erased = _paths.erase(component); nassertv(num_erased == 1); } @@ -3448,7 +3448,7 @@ void PandaNode:: sever_connection(PandaNode *parent_node, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { { - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); Paths::iterator pi; for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { if (!(*pi)->is_top_node(pipeline_stage, current_thread) && @@ -3481,7 +3481,7 @@ void PandaNode:: new_connection(PandaNode *parent_node, PandaNode *child_node, int pipeline_stage, Thread *current_thread) { { - ReMutexHolder holder(child_node->_paths_lock); + LightReMutexHolder holder(child_node->_paths_lock); Paths::iterator pi; for (pi = child_node->_paths.begin(); pi != child_node->_paths.end(); ++pi) { if ((*pi)->is_top_node(pipeline_stage, current_thread)) { @@ -3506,7 +3506,7 @@ new_connection(PandaNode *parent_node, PandaNode *child_node, //////////////////////////////////////////////////////////////////// void PandaNode:: fix_path_lengths(int pipeline_stage, Thread *current_thread) { - ReMutexHolder holder(_paths_lock); + LightReMutexHolder holder(_paths_lock); bool any_wrong = false; diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 7423d51b83..be12d43dbb 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -44,7 +44,7 @@ #include "pStatCollector.h" #include "copyOnWriteObject.h" #include "copyOnWritePointer.h" -#include "reMutex.h" +#include "lightReMutex.h" #ifdef HAVE_PYTHON @@ -444,7 +444,7 @@ private: // threads. A NodePathComponent, once created, is always associated // with the same node. We do, however, protect the Paths under a mutex. Paths _paths; - ReMutex _paths_lock; + LightReMutex _paths_lock; bool _dirty_prev_transform; static PandaNodeChain _dirty_prev_transforms; diff --git a/panda/src/pgraph/pandaNodeChain.h b/panda/src/pgraph/pandaNodeChain.h index 0755edc29a..de554b6bcf 100644 --- a/panda/src/pgraph/pandaNodeChain.h +++ b/panda/src/pgraph/pandaNodeChain.h @@ -17,7 +17,7 @@ #include "pandabase.h" #include "linkedListNode.h" -#include "pmutex.h" +#include "lightMutex.h" class PandaNode; @@ -33,7 +33,7 @@ public: INLINE PandaNodeChain(); INLINE ~PandaNodeChain(); - Mutex _lock; + LightMutex _lock; friend class PandaNode; }; diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 7227957df8..fcfc639511 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -17,9 +17,9 @@ #include "bamReader.h" #include "indent.h" #include "config_pgraph.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" -ReMutex *RenderAttrib::_attribs_lock = NULL; +LightReMutex *RenderAttrib::_attribs_lock = NULL; RenderAttrib::Attribs *RenderAttrib::_attribs = NULL; TypeHandle RenderAttrib::_type_handle; @@ -66,7 +66,7 @@ operator = (const RenderAttrib &) { //////////////////////////////////////////////////////////////////// RenderAttrib:: ~RenderAttrib() { - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); // unref() should have cleared this. nassertv(_saved_entry == _attribs->end()); @@ -147,7 +147,7 @@ bool RenderAttrib:: unref() const { // We always have to grab the lock, since we will definitely need to // be holding it if we happen to drop the reference count to 0. - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); if (ReferenceCount::unref()) { // The reference count is still nonzero. @@ -191,7 +191,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// int RenderAttrib:: get_num_attribs() { - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); if (_attribs == (Attribs *)NULL) { return 0; @@ -208,7 +208,7 @@ get_num_attribs() { //////////////////////////////////////////////////////////////////// void RenderAttrib:: list_attribs(ostream &out) { - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); out << _attribs->size() << " attribs:\n"; Attribs::const_iterator si; @@ -228,7 +228,7 @@ list_attribs(ostream &out) { //////////////////////////////////////////////////////////////////// bool RenderAttrib:: validate_attribs() { - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); if (_attribs->empty()) { return true; @@ -274,7 +274,7 @@ return_new(RenderAttrib *attrib) { return attrib; } - ReMutexHolder holder(*_attribs_lock); + LightReMutexHolder holder(*_attribs_lock); // This should be a newly allocated pointer, not one that was used // for anything else. @@ -496,7 +496,7 @@ init_attribs() { // meantime, this is OK because we guarantee that this method is // called at static init time, presumably when there is still only // one thread in the world. - _attribs_lock = new ReMutex("RenderAttrib::_attribs_lock"); + _attribs_lock = new LightReMutex("RenderAttrib::_attribs_lock"); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index 917466db6a..0f84a3ce02 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -20,7 +20,7 @@ #include "typedWritableReferenceCount.h" #include "pointerTo.h" #include "pset.h" -#include "reMutex.h" +#include "lightReMutex.h" class AttribSlots; class GraphicsStateGuardianBase; @@ -190,7 +190,7 @@ public: private: // This mutex protects _attribs. - static ReMutex *_attribs_lock; + static LightReMutex *_attribs_lock; typedef pset > Attribs; static Attribs *_attribs; diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index ec658352e3..60f50f396e 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -24,11 +24,11 @@ #include "datagramIterator.h" #include "indent.h" #include "compareTo.h" -#include "reMutexHolder.h" -#include "mutexHolder.h" +#include "lightReMutexHolder.h" +#include "lightMutexHolder.h" #include "thread.h" -ReMutex *RenderEffects::_states_lock = NULL; +LightReMutex *RenderEffects::_states_lock = NULL; RenderEffects::States *RenderEffects::_states = NULL; CPT(RenderEffects) RenderEffects::_empty_state; TypeHandle RenderEffects::_type_handle; @@ -78,7 +78,7 @@ operator = (const RenderEffects &) { RenderEffects:: ~RenderEffects() { // Remove the deleted RenderEffects object from the global pool. - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // unref() should have cleared this. nassertv(_saved_entry == _states->end()); @@ -399,7 +399,7 @@ get_effect(TypeHandle type) const { //////////////////////////////////////////////////////////////////// bool RenderEffects:: unref() const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (ReferenceCount::unref()) { // The reference count is still nonzero. @@ -464,7 +464,7 @@ get_num_states() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _states->size(); } @@ -498,7 +498,7 @@ validate_states() { if (_states->empty()) { return true; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); States::const_iterator si = _states->begin(); States::const_iterator snext = si; @@ -587,7 +587,7 @@ init_states() { // meantime, this is OK because we guarantee that this method is // called at static init time, presumably when there is still only // one thread in the world. - _states_lock = new ReMutex("RenderEffects::_states_lock"); + _states_lock = new LightReMutex("RenderEffects::_states_lock"); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } @@ -620,7 +620,7 @@ return_new(RenderEffects *state) { } #endif - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // This should be a newly allocated pointer, not one that was used // for anything else. @@ -671,7 +671,7 @@ release_new() { //////////////////////////////////////////////////////////////////// void RenderEffects:: determine_decal() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_decal) != 0) { // Someone else checked it first. return; @@ -691,7 +691,7 @@ determine_decal() { //////////////////////////////////////////////////////////////////// void RenderEffects:: determine_show_bounds() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_show_bounds) != 0) { // Someone else checked it first. return; @@ -715,7 +715,7 @@ determine_show_bounds() { //////////////////////////////////////////////////////////////////// void RenderEffects:: determine_cull_callback() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_cull_callback) != 0) { // Someone else checked it first. return; @@ -739,7 +739,7 @@ determine_cull_callback() { //////////////////////////////////////////////////////////////////// void RenderEffects:: determine_adjust_transform() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_adjust_transform) != 0) { // Someone else checked it first. return; diff --git a/panda/src/pgraph/renderEffects.h b/panda/src/pgraph/renderEffects.h index ce2fe1442f..ebd906db90 100644 --- a/panda/src/pgraph/renderEffects.h +++ b/panda/src/pgraph/renderEffects.h @@ -24,8 +24,8 @@ #include "typedWritableReferenceCount.h" #include "pointerTo.h" #include "ordered_vector.h" -#include "reMutex.h" -#include "pmutex.h" +#include "lightReMutex.h" +#include "lightMutex.h" class CullTraverser; class CullTraverserData; @@ -124,7 +124,7 @@ private: // This mutex protects _states. It also protects any modification // to the cache, which is encoded in _composition_cache and // _invert_composition_cache. - static ReMutex *_states_lock; + static LightReMutex *_states_lock; typedef pset > States; static States *_states; static CPT(RenderEffects) _empty_state; @@ -167,7 +167,7 @@ private: int _flags; // This mutex protects _flags, and all of the above computed values. - Mutex _lock; + LightMutex _lock; public: diff --git a/panda/src/pgraph/renderState.I b/panda/src/pgraph/renderState.I index b100855f2b..ff89310c16 100644 --- a/panda/src/pgraph/renderState.I +++ b/panda/src/pgraph/renderState.I @@ -430,7 +430,7 @@ get_audio_volume() const { //////////////////////////////////////////////////////////////////// INLINE void RenderState:: determine_bin() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_determine_bin(); } @@ -441,7 +441,7 @@ determine_bin() { //////////////////////////////////////////////////////////////////// INLINE void RenderState:: determine_transparency() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_determine_transparency(); } diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 39a06949c3..424cd755af 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -32,13 +32,13 @@ #include "datagramIterator.h" #include "indent.h" #include "compareTo.h" -#include "reMutexHolder.h" -#include "mutexHolder.h" +#include "lightReMutexHolder.h" +#include "lightMutexHolder.h" #include "thread.h" #include "attribSlots.h" #include "shaderGenerator.h" -ReMutex *RenderState::_states_lock = NULL; +LightReMutex *RenderState::_states_lock = NULL; RenderState::States *RenderState::_states = NULL; CPT(RenderState) RenderState::_empty_state; UpdateSeq RenderState::_last_cycle_detect; @@ -104,7 +104,7 @@ RenderState:: nassertv(!is_destructing()); set_destructing(); - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // unref() should have cleared these. nassertv(_saved_entry == _states->end()); @@ -345,7 +345,7 @@ compose(const RenderState *other) const { } #endif // NDEBUG - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // Is this composition already cached? int index = _composition_cache.find(other); @@ -442,7 +442,7 @@ invert_compose(const RenderState *other) const { } #endif // NDEBUG - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // Is this composition already cached? int index = _invert_composition_cache.find(other); @@ -766,7 +766,7 @@ bool RenderState:: unref() const { // We always have to grab the lock, since we will definitely need to // be holding it if we happen to drop the reference count to 0. - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (auto_break_cycles) { if (get_cache_ref_count() > 0 && @@ -871,7 +871,7 @@ get_num_states() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _states->size(); } @@ -898,7 +898,7 @@ get_num_unused_states() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // First, we need to count the number of times each RenderState // object is recorded in the cache. @@ -993,7 +993,7 @@ clear_cache() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); PStatTimer timer(_cache_update_pcollector); int orig_size = _states->size(); @@ -1063,7 +1063,7 @@ clear_cache() { //////////////////////////////////////////////////////////////////// void RenderState:: clear_munger_cache() { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // First, we need to count the number of times each RenderState // object is recorded in the cache. @@ -1101,7 +1101,7 @@ list_cycles(ostream &out) { if (_states == (States *)NULL) { return; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); typedef pset VisitedStates; VisitedStates visited; @@ -1157,7 +1157,7 @@ list_states(ostream &out) { out << "0 states:\n"; return; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); out << _states->size() << " states:\n"; States::const_iterator si; @@ -1183,7 +1183,7 @@ validate_states() { return true; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (_states->empty()) { return true; } @@ -1324,7 +1324,7 @@ return_new(RenderState *state) { } #endif - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // This should be a newly allocated pointer, not one that was used // for anything else. @@ -1709,7 +1709,7 @@ remove_cache_pointers() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_bin_index() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_bin_index) != 0) { // Someone else checked it first. return; @@ -1768,7 +1768,7 @@ determine_bin_index() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_fog() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_fog) != 0) { // Someone else checked it first. return; @@ -1833,7 +1833,7 @@ do_determine_transparency() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_color() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_color) != 0) { // Someone else checked it first. return; @@ -1854,7 +1854,7 @@ determine_color() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_color_scale() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_color_scale) != 0) { // Someone else checked it first. return; @@ -1875,7 +1875,7 @@ determine_color_scale() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_texture() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_texture) != 0) { // Someone else checked it first. return; @@ -1896,7 +1896,7 @@ determine_texture() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_tex_gen() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_tex_gen) != 0) { // Someone else checked it first. return; @@ -1917,7 +1917,7 @@ determine_tex_gen() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_tex_matrix() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_tex_matrix) != 0) { // Someone else checked it first. return; @@ -1938,7 +1938,7 @@ determine_tex_matrix() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_render_mode() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_render_mode) != 0) { // Someone else checked it first. return; @@ -1959,7 +1959,7 @@ determine_render_mode() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_clip_plane() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_clip_plane) != 0) { // Someone else checked it first. return; @@ -1980,7 +1980,7 @@ determine_clip_plane() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_scissor() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_scissor) != 0) { // Someone else checked it first. return; @@ -2001,7 +2001,7 @@ determine_scissor() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_shader() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_shader) != 0) { // Someone else checked it first. return; @@ -2022,7 +2022,7 @@ determine_shader() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_cull_callback() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_cull_callback) != 0) { // Someone else checked it first. return; @@ -2047,7 +2047,7 @@ determine_cull_callback() { //////////////////////////////////////////////////////////////////// void RenderState:: determine_audio_volume() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_checked_audio_volume) != 0) { // Someone else checked it first. return; @@ -2104,7 +2104,7 @@ init_states() { // meantime, this is OK because we guarantee that this method is // called at static init time, presumably when there is still only // one thread in the world. - _states_lock = new ReMutex("RenderState::_states_lock"); + _states_lock = new LightReMutex("RenderState::_states_lock"); _cache_stats.init(); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } diff --git a/panda/src/pgraph/renderState.h b/panda/src/pgraph/renderState.h index 37fbd26156..8e9b364881 100644 --- a/panda/src/pgraph/renderState.h +++ b/panda/src/pgraph/renderState.h @@ -27,8 +27,8 @@ #include "texMatrixAttrib.h" #include "geomMunger.h" #include "weakPointerTo.h" -#include "reMutex.h" -#include "pmutex.h" +#include "lightReMutex.h" +#include "lightMutex.h" #include "deletedChain.h" #include "simpleHashMap.h" #include "cacheStats.h" @@ -221,7 +221,7 @@ private: // This mutex protects _states. It also protects any modification // to the cache, which is encoded in _composition_cache and // _invert_composition_cache. - static ReMutex *_states_lock; + static LightReMutex *_states_lock; typedef phash_set > States; static States *_states; static CPT(RenderState) _empty_state; @@ -344,7 +344,7 @@ private: unsigned int _flags; // This mutex protects _flags, and all of the above computed values. - Mutex _lock; + LightMutex _lock; static CacheStats _cache_stats; diff --git a/panda/src/pgraph/shaderPool.cxx b/panda/src/pgraph/shaderPool.cxx index daa1cfaa6f..d8acc737eb 100644 --- a/panda/src/pgraph/shaderPool.cxx +++ b/panda/src/pgraph/shaderPool.cxx @@ -39,7 +39,7 @@ write(ostream &out) { //////////////////////////////////////////////////////////////////// bool ShaderPool:: ns_has_shader(const string &str) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); string index_str; Filename filename; @@ -69,7 +69,7 @@ ns_load_shader(const string &str) { lookup_filename(str, index_str, filename, face_index); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Shaders::const_iterator ti; ti = _shaders.find(index_str); @@ -105,7 +105,7 @@ ns_load_shader(const string &str) { } { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Now try again. Someone may have loaded the shader in another // thread. @@ -129,7 +129,7 @@ ns_load_shader(const string &str) { //////////////////////////////////////////////////////////////////// void ShaderPool:: ns_add_shader(const string &str, Shader *shader) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); string index_str; Filename filename; @@ -147,7 +147,7 @@ ns_add_shader(const string &str, Shader *shader) { //////////////////////////////////////////////////////////////////// void ShaderPool:: ns_release_shader(const string &filename) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Shaders::iterator ti; ti = _shaders.find(filename); @@ -163,7 +163,7 @@ ns_release_shader(const string &filename) { //////////////////////////////////////////////////////////////////// void ShaderPool:: ns_release_all_shaders() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _shaders.clear(); } @@ -175,7 +175,7 @@ ns_release_all_shaders() { //////////////////////////////////////////////////////////////////// int ShaderPool:: ns_garbage_collect() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int num_released = 0; Shaders new_set; @@ -207,7 +207,7 @@ ns_garbage_collect() { //////////////////////////////////////////////////////////////////// void ShaderPool:: ns_list_contents(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << _shaders.size() << " shaders:\n"; Shaders::const_iterator ti; diff --git a/panda/src/pgraph/shaderPool.h b/panda/src/pgraph/shaderPool.h index 2e506e7972..fe0fa1ff1c 100644 --- a/panda/src/pgraph/shaderPool.h +++ b/panda/src/pgraph/shaderPool.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "shader.h" #include "filename.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pmap.h" //////////////////////////////////////////////////////////////////// @@ -62,7 +62,7 @@ private: static ShaderPool *get_ptr(); static ShaderPool *_global_ptr; - Mutex _lock; + LightMutex _lock; typedef pmap Shaders; Shaders _shaders; }; diff --git a/panda/src/pgraph/transformState.I b/panda/src/pgraph/transformState.I index bc359c27a7..f08ddd8a44 100644 --- a/panda/src/pgraph/transformState.I +++ b/panda/src/pgraph/transformState.I @@ -781,7 +781,7 @@ node_unref() const { //////////////////////////////////////////////////////////////////// INLINE int TransformState:: get_composition_cache_num_entries() const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _composition_cache.get_num_entries(); } @@ -796,7 +796,7 @@ get_composition_cache_num_entries() const { //////////////////////////////////////////////////////////////////// INLINE int TransformState:: get_invert_composition_cache_num_entries() const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_num_entries(); } @@ -814,7 +814,7 @@ get_invert_composition_cache_num_entries() const { //////////////////////////////////////////////////////////////////// INLINE int TransformState:: get_composition_cache_size() const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _composition_cache.get_size(); } @@ -831,7 +831,7 @@ get_composition_cache_size() const { //////////////////////////////////////////////////////////////////// INLINE const TransformState *TransformState:: get_composition_cache_source(int n) const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (!_composition_cache.has_element(n)) { return NULL; } @@ -854,7 +854,7 @@ get_composition_cache_source(int n) const { //////////////////////////////////////////////////////////////////// INLINE const TransformState *TransformState:: get_composition_cache_result(int n) const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (!_composition_cache.has_element(n)) { return NULL; } @@ -875,7 +875,7 @@ get_composition_cache_result(int n) const { //////////////////////////////////////////////////////////////////// INLINE int TransformState:: get_invert_composition_cache_size() const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _invert_composition_cache.get_size(); } @@ -892,7 +892,7 @@ get_invert_composition_cache_size() const { //////////////////////////////////////////////////////////////////// INLINE const TransformState *TransformState:: get_invert_composition_cache_source(int n) const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (!_invert_composition_cache.has_element(n)) { return NULL; } @@ -915,7 +915,7 @@ get_invert_composition_cache_source(int n) const { //////////////////////////////////////////////////////////////////// INLINE const TransformState *TransformState:: get_invert_composition_cache_result(int n) const { - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (!_invert_composition_cache.has_element(n)) { return NULL; } @@ -1067,7 +1067,7 @@ check_mat() const { //////////////////////////////////////////////////////////////////// INLINE void TransformState:: calc_hash() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_calc_hash(); } @@ -1078,7 +1078,7 @@ calc_hash() { //////////////////////////////////////////////////////////////////// INLINE void TransformState:: calc_components() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_calc_components(); } @@ -1090,7 +1090,7 @@ calc_components() { //////////////////////////////////////////////////////////////////// INLINE void TransformState:: calc_hpr() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_calc_hpr(); } @@ -1101,7 +1101,7 @@ calc_hpr() { //////////////////////////////////////////////////////////////////// INLINE void TransformState:: calc_mat() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_calc_mat(); } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index cdf6c9c9bc..e0607f02e8 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -21,11 +21,11 @@ #include "compareTo.h" #include "pStatTimer.h" #include "config_pgraph.h" -#include "reMutexHolder.h" -#include "mutexHolder.h" +#include "lightReMutexHolder.h" +#include "lightMutexHolder.h" #include "thread.h" -ReMutex *TransformState::_states_lock = NULL; +LightReMutex *TransformState::_states_lock = NULL; TransformState::States *TransformState::_states = NULL; CPT(TransformState) TransformState::_identity_state; UpdateSeq TransformState::_last_cycle_detect; @@ -100,7 +100,7 @@ TransformState:: _inv_mat = (LMatrix4f *)NULL; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // unref() should have cleared these. nassertv(_saved_entry == _states->end()); @@ -599,7 +599,7 @@ compose(const TransformState *other) const { } #endif // NDEBUG - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // Is this composition already cached? int index = _composition_cache.find(other); @@ -704,7 +704,7 @@ invert_compose(const TransformState *other) const { } #endif // NDEBUG - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // Is this composition already cached? int index = _invert_composition_cache.find(other); @@ -784,7 +784,7 @@ bool TransformState:: unref() const { // We always have to grab the lock, since we will definitely need to // be holding it if we happen to drop the reference count to 0. - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (auto_break_cycles) { if (get_cache_ref_count() > 0 && @@ -941,7 +941,7 @@ get_num_states() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); return _states->size(); } @@ -968,7 +968,7 @@ get_num_unused_states() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // First, we need to count the number of times each TransformState // object is recorded in the cache. We could just trust @@ -1064,7 +1064,7 @@ clear_cache() { if (_states == (States *)NULL) { return 0; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); PStatTimer timer(_cache_update_pcollector); int orig_size = _states->size(); @@ -1148,7 +1148,7 @@ list_cycles(ostream &out) { if (_states == (States *)NULL) { return; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); typedef pset VisitedStates; VisitedStates visited; @@ -1204,7 +1204,7 @@ list_states(ostream &out) { out << "0 states:\n"; return; } - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); out << _states->size() << " states:\n"; States::const_iterator si; @@ -1232,7 +1232,7 @@ validate_states() { PStatTimer timer(_transform_validate_pcollector); - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); if (_states->empty()) { return true; } @@ -1287,7 +1287,7 @@ init_states() { // meantime, this is OK because we guarantee that this method is // called at static init time, presumably when there is still only // one thread in the world. - _states_lock = new ReMutex("TransformState::_states_lock"); + _states_lock = new LightReMutex("TransformState::_states_lock"); _cache_stats.init(); nassertv(Thread::get_current_thread() == Thread::get_main_thread()); } @@ -1326,7 +1326,7 @@ return_new(TransformState *state) { PStatTimer timer(_transform_new_pcollector); - ReMutexHolder holder(*_states_lock); + LightReMutexHolder holder(*_states_lock); // This should be a newly allocated pointer, not one that was used // for anything else. @@ -1836,7 +1836,7 @@ do_calc_hash() { //////////////////////////////////////////////////////////////////// void TransformState:: calc_singular() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_singular_known) != 0) { // Someone else computed it first. return; @@ -1953,7 +1953,7 @@ do_calc_hpr() { //////////////////////////////////////////////////////////////////// void TransformState:: calc_quat() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if ((_flags & F_quat_known) != 0) { // Someone else computed it first. return; @@ -1984,7 +1984,7 @@ calc_norm_quat() { PStatTimer timer(_transform_calc_pcollector); LQuaternionf quat = get_quat(); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _norm_quat = quat; _norm_quat.normalize(); _flags |= F_norm_quat_known; diff --git a/panda/src/pgraph/transformState.h b/panda/src/pgraph/transformState.h index c268ebc458..5e36b96191 100644 --- a/panda/src/pgraph/transformState.h +++ b/panda/src/pgraph/transformState.h @@ -25,8 +25,8 @@ #include "updateSeq.h" #include "pStatCollector.h" #include "geomEnums.h" -#include "reMutex.h" -#include "pmutex.h" +#include "lightReMutex.h" +#include "lightMutex.h" #include "config_pgraph.h" #include "deletedChain.h" #include "simpleHashMap.h" @@ -233,7 +233,7 @@ private: // This mutex protects _states. It also protects any modification // to the cache, which is encoded in _composition_cache and // _invert_composition_cache. - static ReMutex *_states_lock; + static LightReMutex *_states_lock; typedef phash_set > States; static States *_states; static CPT(TransformState) _identity_state; @@ -344,7 +344,7 @@ private: unsigned int _flags; // This mutex protects _flags, and all of the above computed values. - Mutex _lock; + LightMutex _lock; static CacheStats _cache_stats; diff --git a/panda/src/pgui/pgButton.I b/panda/src/pgui/pgButton.I index 37316a8e51..fd423d4c3d 100644 --- a/panda/src/pgui/pgButton.I +++ b/panda/src/pgui/pgButton.I @@ -93,7 +93,7 @@ get_click_prefix() { //////////////////////////////////////////////////////////////////// INLINE string PGButton:: get_click_event(const ButtonHandle &button) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_click_prefix() + button.get_name() + "-" + get_id(); } @@ -105,6 +105,6 @@ get_click_event(const ButtonHandle &button) const { //////////////////////////////////////////////////////////////////// INLINE bool PGButton:: is_button_down() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _button_down; } diff --git a/panda/src/pgui/pgButton.cxx b/panda/src/pgui/pgButton.cxx index 05f4153023..a25ad30e7f 100644 --- a/panda/src/pgui/pgButton.cxx +++ b/panda/src/pgui/pgButton.cxx @@ -69,7 +69,7 @@ PGButton(const PGButton ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGButton:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGButton(*this); } @@ -81,7 +81,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void PGButton:: enter_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (get_active()) { set_state(_button_down ? S_depressed : S_rollover); } @@ -96,7 +96,7 @@ enter_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGButton:: exit_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (get_active()) { set_state(S_ready); } @@ -112,7 +112,7 @@ exit_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGButton:: press(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (has_click_button(param.get_button())) { if (get_active()) { _button_down = true; @@ -131,7 +131,7 @@ press(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGButton:: release(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (has_click_button(param.get_button())) { _button_down = false; if (get_active()) { @@ -154,7 +154,7 @@ release(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGButton:: click(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_click_event(param.get_button()); play_sound(event); @@ -176,7 +176,7 @@ click(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGButton:: setup(const string &label, float bevel) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); clear_state_def(S_ready); clear_state_def(S_depressed); clear_state_def(S_rollover); @@ -233,7 +233,7 @@ setup(const string &label, float bevel) { void PGButton:: setup(const NodePath &ready, const NodePath &depressed, const NodePath &rollover, const NodePath &inactive) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); clear_state_def(S_ready); clear_state_def(S_depressed); clear_state_def(S_rollover); @@ -254,7 +254,7 @@ setup(const NodePath &ready, const NodePath &depressed, //////////////////////////////////////////////////////////////////// void PGButton:: set_active(bool active) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (active != get_active()) { PGItem::set_active(active); set_state(active ? S_ready : S_inactive); @@ -271,7 +271,7 @@ set_active(bool active) { //////////////////////////////////////////////////////////////////// bool PGButton:: add_click_button(const ButtonHandle &button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _click_buttons.insert(button).second; } @@ -286,7 +286,7 @@ add_click_button(const ButtonHandle &button) { //////////////////////////////////////////////////////////////////// bool PGButton:: remove_click_button(const ButtonHandle &button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_click_buttons.erase(button) != 0); } @@ -299,6 +299,6 @@ remove_click_button(const ButtonHandle &button) { //////////////////////////////////////////////////////////////////// bool PGButton:: has_click_button(const ButtonHandle &button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_click_buttons.count(button) != 0); } diff --git a/panda/src/pgui/pgEntry.I b/panda/src/pgui/pgEntry.I index ce3b1240f7..a64ea8ba20 100644 --- a/panda/src/pgui/pgEntry.I +++ b/panda/src/pgui/pgEntry.I @@ -27,7 +27,7 @@ //////////////////////////////////////////////////////////////////// INLINE bool PGEntry:: set_text(const string &text) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); nassertr(text_node != (TextNode *)NULL, false); return set_wtext(text_node->decode_text(text)); @@ -45,7 +45,7 @@ set_text(const string &text) { //////////////////////////////////////////////////////////////////// INLINE string PGEntry:: get_plain_text() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); nassertr(text_node != (TextNode *)NULL, string()); return text_node->encode_wtext(get_plain_wtext()); @@ -61,7 +61,7 @@ get_plain_text() const { //////////////////////////////////////////////////////////////////// INLINE string PGEntry:: get_text() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); TextNode *text_node = get_text_def(S_focus); nassertr(text_node != (TextNode *)NULL, string()); return text_node->encode_wtext(get_wtext()); @@ -82,7 +82,7 @@ get_text() const { //////////////////////////////////////////////////////////////////// INLINE int PGEntry:: get_num_characters() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_num_characters(); } @@ -95,7 +95,7 @@ get_num_characters() const { //////////////////////////////////////////////////////////////////// INLINE wchar_t PGEntry:: get_character(int n) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_character(n); } @@ -109,7 +109,7 @@ get_character(int n) const { //////////////////////////////////////////////////////////////////// INLINE const TextGraphic *PGEntry:: get_graphic(int n) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_graphic(n); } @@ -122,7 +122,7 @@ get_graphic(int n) const { //////////////////////////////////////////////////////////////////// INLINE const TextProperties &PGEntry:: get_properties(int n) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_properties(n); } @@ -136,7 +136,7 @@ get_properties(int n) const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_cursor_position(int position) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_cursor_position != position) { _cursor_position = position; _cursor_stale = true; @@ -151,7 +151,7 @@ set_cursor_position(int position) { //////////////////////////////////////////////////////////////////// INLINE int PGEntry:: get_cursor_position() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _cursor_position; } @@ -167,7 +167,7 @@ get_cursor_position() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_max_chars(int max_chars) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _max_chars = max_chars; } @@ -180,7 +180,7 @@ set_max_chars(int max_chars) { //////////////////////////////////////////////////////////////////// INLINE int PGEntry:: get_max_chars() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _max_chars; } @@ -201,7 +201,7 @@ get_max_chars() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_max_width(float max_width) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _max_width = max_width; _text_geom_stale = true; } @@ -215,7 +215,7 @@ set_max_width(float max_width) { //////////////////////////////////////////////////////////////////// INLINE float PGEntry:: get_max_width() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _max_width; } @@ -228,7 +228,7 @@ get_max_width() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_num_lines(int num_lines) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertv(num_lines >= 1); _num_lines = num_lines; _text_geom_stale = true; @@ -242,7 +242,7 @@ set_num_lines(int num_lines) { //////////////////////////////////////////////////////////////////// INLINE int PGEntry:: get_num_lines() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _num_lines; } @@ -257,7 +257,7 @@ get_num_lines() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_blink_rate(float blink_rate) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _blink_rate = blink_rate; } @@ -269,7 +269,7 @@ set_blink_rate(float blink_rate) { //////////////////////////////////////////////////////////////////// INLINE float PGEntry:: get_blink_rate() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _blink_rate; } @@ -282,7 +282,7 @@ get_blink_rate() const { //////////////////////////////////////////////////////////////////// INLINE const NodePath &PGEntry:: get_cursor_def() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _cursor_def; } @@ -294,7 +294,7 @@ get_cursor_def() { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: clear_cursor_def() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _cursor_def.remove_node(); _cursor_def = _cursor_scale.attach_new_node("cursor"); } @@ -308,7 +308,7 @@ clear_cursor_def() { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_cursor_keys_active(bool flag) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _cursor_keys_active = flag; } @@ -321,7 +321,7 @@ set_cursor_keys_active(bool flag) { //////////////////////////////////////////////////////////////////// INLINE bool PGEntry:: get_cursor_keys_active() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _cursor_keys_active; } @@ -341,7 +341,7 @@ get_cursor_keys_active() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_obscure_mode(bool flag) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_obscure_mode != flag) { _obscure_mode = flag; _text_geom_stale = true; @@ -356,7 +356,7 @@ set_obscure_mode(bool flag) { //////////////////////////////////////////////////////////////////// INLINE bool PGEntry:: get_obscure_mode() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _obscure_mode; } @@ -379,7 +379,7 @@ get_obscure_mode() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_candidate_active(const string &candidate_active) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _candidate_active = candidate_active; } @@ -390,7 +390,7 @@ set_candidate_active(const string &candidate_active) { //////////////////////////////////////////////////////////////////// INLINE const string &PGEntry:: get_candidate_active() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _candidate_active; } @@ -413,7 +413,7 @@ get_candidate_active() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_candidate_inactive(const string &candidate_inactive) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _candidate_inactive = candidate_inactive; } @@ -424,7 +424,7 @@ set_candidate_inactive(const string &candidate_inactive) { //////////////////////////////////////////////////////////////////// INLINE const string &PGEntry:: get_candidate_inactive() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _candidate_inactive; } @@ -557,7 +557,7 @@ get_erase_event() const { //////////////////////////////////////////////////////////////////// INLINE bool PGEntry:: set_wtext(const wstring &wtext) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); bool ret = _text.set_wtext(wtext); if (_obscure_mode) { ret = _obscure_text.set_wtext(wstring(_text.get_num_characters(), '*')); @@ -575,7 +575,7 @@ set_wtext(const wstring &wtext) { //////////////////////////////////////////////////////////////////// INLINE wstring PGEntry:: get_plain_wtext() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_plain_wtext(); } @@ -587,7 +587,7 @@ get_plain_wtext() const { //////////////////////////////////////////////////////////////////// INLINE wstring PGEntry:: get_wtext() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _text.get_wtext(); } @@ -599,6 +599,6 @@ get_wtext() const { //////////////////////////////////////////////////////////////////// INLINE void PGEntry:: set_accept_enabled(bool enabled) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _accept_enabled = enabled; } diff --git a/panda/src/pgui/pgEntry.cxx b/panda/src/pgui/pgEntry.cxx index 8966e7d333..0e2d63c678 100644 --- a/panda/src/pgui/pgEntry.cxx +++ b/panda/src/pgui/pgEntry.cxx @@ -124,7 +124,7 @@ PGEntry(const PGEntry ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGEntry:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGEntry(*this); } @@ -137,7 +137,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void PGEntry:: xform(const LMatrix4f &mat) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::xform(mat); _text_render_root.set_mat(_text_render_root.get_mat() * mat); } @@ -169,7 +169,7 @@ xform(const LMatrix4f &mat) { //////////////////////////////////////////////////////////////////// bool PGEntry:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::cull_callback(trav, data); update_text(); update_cursor(); @@ -191,7 +191,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { //////////////////////////////////////////////////////////////////// void PGEntry:: press(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (get_active()) { if (param.has_button()) { // Make sure _text is initialized properly. @@ -300,7 +300,7 @@ press(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGEntry:: keystroke(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (get_active()) { if (param.has_keycode()) { // Make sure _text is initialized properly. @@ -407,7 +407,7 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGEntry:: candidate(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (get_active()) { if (param.has_candidate()) { // Save the candidate string so it can be displayed. @@ -432,7 +432,7 @@ candidate(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGEntry:: accept(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_accept_event(param.get_button()); play_sound(event); @@ -448,7 +448,7 @@ accept(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGEntry:: accept_failed(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_accept_failed_event(param.get_button()); play_sound(event); @@ -466,7 +466,7 @@ accept_failed(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGEntry:: overflow(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_overflow_event(); play_sound(event); @@ -481,7 +481,7 @@ overflow(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGEntry:: type(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_type_event(); play_sound(event); @@ -496,7 +496,7 @@ type(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGEntry:: erase(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGMouseWatcherParameter *ep = new PGMouseWatcherParameter(param); string event = get_erase_event(); play_sound(event); @@ -514,7 +514,7 @@ erase(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGEntry:: setup(float width, int num_lines) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); setup_minimal(width, num_lines); TextNode *text_node = get_text_def(S_focus); @@ -582,7 +582,7 @@ setup(float width, int num_lines) { //////////////////////////////////////////////////////////////////// void PGEntry:: setup_minimal(float width, int num_lines) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_text(string()); _cursor_position = 0; set_max_chars(0); @@ -621,7 +621,7 @@ setup_minimal(float width, int num_lines) { //////////////////////////////////////////////////////////////////// void PGEntry:: set_text_def(int state, TextNode *node) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertv(state >= 0 && state < 1000); // Sanity check. if (node == (TextNode *)NULL && state >= (int)_text_defs.size()) { // If we're setting it to NULL, we don't need to slot a new one. @@ -641,7 +641,7 @@ set_text_def(int state, TextNode *node) { //////////////////////////////////////////////////////////////////// TextNode *PGEntry:: get_text_def(int state) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (state < 0 || state >= (int)_text_defs.size()) { // If we don't have a definition, use the global one. return get_text_node(); @@ -661,7 +661,7 @@ get_text_def(int state) const { //////////////////////////////////////////////////////////////////// void PGEntry:: set_active(bool active) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::set_active(active); update_state(); } @@ -674,7 +674,7 @@ set_active(bool active) { //////////////////////////////////////////////////////////////////// void PGEntry:: set_focus(bool focus) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::set_focus(focus); _blink_start = ClockObject::get_global_clock()->get_frame_time(); update_state(); @@ -690,7 +690,7 @@ set_focus(bool focus) { //////////////////////////////////////////////////////////////////// bool PGEntry:: is_wtext() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); for (int i = 0; i < _text.get_num_characters(); ++i) { wchar_t ch = _text.get_character(i); if ((ch & ~0x7f) != 0) { diff --git a/panda/src/pgui/pgItem.I b/panda/src/pgui/pgItem.I index 618ee8b160..7f369ebf71 100644 --- a/panda/src/pgui/pgItem.I +++ b/panda/src/pgui/pgItem.I @@ -37,7 +37,7 @@ set_name(const string &name) { //////////////////////////////////////////////////////////////////// INLINE PGMouseWatcherRegion *PGItem:: get_region() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _region; } @@ -52,7 +52,7 @@ get_region() const { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: set_notify(PGItemNotify *notify) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_notify != (PGItemNotify *)NULL) { _notify->remove_item(this); } @@ -70,7 +70,7 @@ set_notify(PGItemNotify *notify) { //////////////////////////////////////////////////////////////////// INLINE bool PGItem:: has_notify() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_notify != (PGItemNotify *)NULL); } @@ -83,7 +83,7 @@ has_notify() const { //////////////////////////////////////////////////////////////////// INLINE PGItemNotify *PGItem:: get_notify() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _notify; } @@ -112,7 +112,7 @@ set_frame(float left, float right, float bottom, float top) { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: set_frame(const LVecBase4f &frame) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (!_has_frame || _frame != frame) { _has_frame = true; _frame = frame; @@ -129,7 +129,7 @@ set_frame(const LVecBase4f &frame) { //////////////////////////////////////////////////////////////////// INLINE const LVecBase4f &PGItem:: get_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertr(has_frame(), _frame); return _frame; } @@ -142,7 +142,7 @@ get_frame() const { //////////////////////////////////////////////////////////////////// INLINE bool PGItem:: has_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _has_frame; } @@ -155,7 +155,7 @@ has_frame() const { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: clear_frame() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_has_frame) { _has_frame = false; frame_changed(); @@ -173,7 +173,7 @@ clear_frame() { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: set_state(int state) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _state = state; } @@ -185,7 +185,7 @@ set_state(int state) { //////////////////////////////////////////////////////////////////// INLINE int PGItem:: get_state() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _state; } @@ -197,7 +197,7 @@ get_state() const { //////////////////////////////////////////////////////////////////// INLINE bool PGItem:: get_active() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_flags & F_active) != 0; } @@ -209,7 +209,7 @@ get_active() const { //////////////////////////////////////////////////////////////////// INLINE bool PGItem:: get_focus() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_flags & F_focus) != 0; } @@ -221,7 +221,7 @@ get_focus() const { //////////////////////////////////////////////////////////////////// INLINE bool PGItem:: get_background_focus() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_flags & F_background_focus) != 0; } @@ -234,7 +234,7 @@ get_background_focus() const { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: set_suppress_flags(int suppress_flags) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _region->set_suppress_flags(suppress_flags); } @@ -247,7 +247,7 @@ set_suppress_flags(int suppress_flags) { //////////////////////////////////////////////////////////////////// INLINE int PGItem:: get_suppress_flags() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _region->get_suppress_flags(); } @@ -261,7 +261,7 @@ get_suppress_flags() const { //////////////////////////////////////////////////////////////////// INLINE const string &PGItem:: get_id() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _region->get_name(); } @@ -280,7 +280,7 @@ get_id() const { //////////////////////////////////////////////////////////////////// INLINE void PGItem:: set_id(const string &id) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _region->set_name(id); } @@ -423,7 +423,7 @@ get_keystroke_prefix() { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_enter_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_enter_prefix() + get_id(); } @@ -436,7 +436,7 @@ get_enter_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_exit_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_exit_prefix() + get_id(); } @@ -451,7 +451,7 @@ get_exit_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_within_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_within_prefix() + get_id(); } @@ -467,7 +467,7 @@ get_within_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_without_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_without_prefix() + get_id(); } @@ -479,7 +479,7 @@ get_without_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_focus_in_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_focus_in_prefix() + get_id(); } @@ -491,7 +491,7 @@ get_focus_in_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_focus_out_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_focus_out_prefix() + get_id(); } @@ -505,7 +505,7 @@ get_focus_out_event() const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_press_event(const ButtonHandle &button) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_press_prefix() + button.get_name() + "-" + get_id(); } @@ -519,7 +519,7 @@ get_press_event(const ButtonHandle &button) const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_repeat_event(const ButtonHandle &button) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_repeat_prefix() + button.get_name() + "-" + get_id(); } @@ -533,7 +533,7 @@ get_repeat_event(const ButtonHandle &button) const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_release_event(const ButtonHandle &button) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_release_prefix() + button.get_name() + "-" + get_id(); } @@ -545,7 +545,7 @@ get_release_event(const ButtonHandle &button) const { //////////////////////////////////////////////////////////////////// INLINE string PGItem:: get_keystroke_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_keystroke_prefix() + get_id(); } @@ -581,7 +581,7 @@ get_focus_item() { //////////////////////////////////////////////////////////////////// INLINE LMatrix4f PGItem:: get_frame_inv_xform() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _frame_inv_xform; } diff --git a/panda/src/pgui/pgItem.cxx b/panda/src/pgui/pgItem.cxx index 48ce10dd9f..c3227632ad 100644 --- a/panda/src/pgui/pgItem.cxx +++ b/panda/src/pgui/pgItem.cxx @@ -143,7 +143,7 @@ PGItem(const PGItem ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGItem:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGItem(*this); } @@ -156,7 +156,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void PGItem:: transform_changed() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PandaNode::transform_changed(); if (has_notify()) { get_notify()->item_transform_changed(this); @@ -172,7 +172,7 @@ transform_changed() { //////////////////////////////////////////////////////////////////// void PGItem:: draw_mask_changed() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PandaNode::draw_mask_changed(); if (has_notify()) { get_notify()->item_draw_mask_changed(this); @@ -206,7 +206,7 @@ draw_mask_changed() { //////////////////////////////////////////////////////////////////// bool PGItem:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); bool this_node_hidden = data.is_this_node_hidden(trav); if (!this_node_hidden && has_frame() && get_active()) { // The item has a frame, so we want to generate a region for it @@ -305,7 +305,7 @@ compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const { - ReMutexHolder holder(_lock, current_thread); + LightReMutexHolder holder(_lock, current_thread); int num_vertices = 0; // First, get ourselves a fresh, empty bounding volume. @@ -354,7 +354,7 @@ void PGItem:: r_prepare_scene(const RenderState *state, PreparedGraphicsObjects *prepared_objects, Thread *current_thread) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); StateDefs::iterator di; for (di = _state_defs.begin(); di != _state_defs.end(); ++di) { NodePath &root = (*di)._root; @@ -377,7 +377,7 @@ r_prepare_scene(const RenderState *state, //////////////////////////////////////////////////////////////////// void PGItem:: xform(const LMatrix4f &mat) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); // Transform the frame. LPoint3f ll(_frame[0], 0.0f, _frame[2]); LPoint3f ur(_frame[1], 0.0f, _frame[3]); @@ -417,7 +417,7 @@ bool PGItem:: activate_region(const LMatrix4f &transform, int sort, const ClipPlaneAttrib *cpa, const ScissorAttrib *sa) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); // Transform all four vertices, and get the new bounding box. This // way the region works (mostly) even if has been rotated. LPoint3f ll(_frame[0], 0.0f, _frame[2]); @@ -514,7 +514,7 @@ activate_region(const LMatrix4f &transform, int sort, //////////////////////////////////////////////////////////////////// void PGItem:: enter_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::enter_region(" << param << ")\n"; @@ -541,7 +541,7 @@ enter_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGItem:: exit_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::exit_region(" << param << ")\n"; @@ -571,7 +571,7 @@ exit_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGItem:: within_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::within_region(" << param << ")\n"; @@ -596,7 +596,7 @@ within_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGItem:: without_region(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::without_region(" << param << ")\n"; @@ -620,7 +620,7 @@ without_region(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGItem:: focus_in() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::focus_in()\n"; @@ -643,7 +643,7 @@ focus_in() { //////////////////////////////////////////////////////////////////// void PGItem:: focus_out() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::focus_out()\n"; @@ -667,7 +667,7 @@ focus_out() { //////////////////////////////////////////////////////////////////// void PGItem:: press(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::press(" << param << ", " << background << ")\n"; @@ -699,7 +699,7 @@ press(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGItem:: release(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::release(" << param << ", " << background << ")\n"; @@ -725,7 +725,7 @@ release(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGItem:: keystroke(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::keystroke(" << param << ", " << background << ")\n"; @@ -751,7 +751,7 @@ keystroke(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGItem:: candidate(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::candidate(" << param << ", " << background << ")\n"; @@ -773,7 +773,7 @@ candidate(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGItem:: move(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (pgui_cat.is_debug()) { pgui_cat.debug() << *this << "::move(" << param << ")\n"; @@ -863,7 +863,7 @@ background_candidate(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGItem:: set_active(bool active) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (active) { _flags |= F_active; } else { @@ -890,7 +890,7 @@ set_active(bool active) { //////////////////////////////////////////////////////////////////// void PGItem:: set_focus(bool focus) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (focus) { if (!get_active()) { // Cannot set focus on an inactive item. @@ -935,7 +935,7 @@ set_focus(bool focus) { //////////////////////////////////////////////////////////////////// void PGItem:: set_background_focus(bool focus) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (focus != get_background_focus()) { if (focus) { // Activate background focus. @@ -965,7 +965,7 @@ set_background_focus(bool focus) { //////////////////////////////////////////////////////////////////// int PGItem:: get_num_state_defs() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _state_defs.size(); } @@ -978,7 +978,7 @@ get_num_state_defs() const { //////////////////////////////////////////////////////////////////// bool PGItem:: has_state_def(int state) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (state < 0 || state >= (int)_state_defs.size()) { return false; } @@ -994,7 +994,7 @@ has_state_def(int state) const { //////////////////////////////////////////////////////////////////// void PGItem:: clear_state_def(int state) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (state < 0 || state >= (int)_state_defs.size()) { return; } @@ -1016,7 +1016,7 @@ clear_state_def(int state) { //////////////////////////////////////////////////////////////////// NodePath &PGItem:: get_state_def(int state) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertr(state >= 0 && state < 1000, get_state_def(0)); // Sanity check. slot_state_def(state); @@ -1041,7 +1041,7 @@ get_state_def(int state) { //////////////////////////////////////////////////////////////////// NodePath PGItem:: instance_to_state_def(int state, const NodePath &path) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (path.is_empty()) { // If the source is empty, quietly do nothing. return NodePath(); @@ -1060,7 +1060,7 @@ instance_to_state_def(int state, const NodePath &path) { //////////////////////////////////////////////////////////////////// PGFrameStyle PGItem:: get_frame_style(int state) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (state < 0 || state >= (int)_state_defs.size()) { return PGFrameStyle(); } @@ -1075,7 +1075,7 @@ get_frame_style(int state) { //////////////////////////////////////////////////////////////////// void PGItem:: set_frame_style(int state, const PGFrameStyle &style) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); // Get the state def node, mainly to ensure that this state is // slotted and listed as having been defined. NodePath &root = get_state_def(state); @@ -1096,7 +1096,7 @@ set_frame_style(int state, const PGFrameStyle &style) { //////////////////////////////////////////////////////////////////// void PGItem:: set_sound(const string &event, AudioSound *sound) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _sounds[event] = sound; } @@ -1108,7 +1108,7 @@ set_sound(const string &event, AudioSound *sound) { //////////////////////////////////////////////////////////////////// void PGItem:: clear_sound(const string &event) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _sounds.erase(event); } @@ -1120,7 +1120,7 @@ clear_sound(const string &event) { //////////////////////////////////////////////////////////////////// AudioSound *PGItem:: get_sound(const string &event) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); Sounds::const_iterator si = _sounds.find(event); if (si != _sounds.end()) { return (*si).second; @@ -1136,7 +1136,7 @@ get_sound(const string &event) const { //////////////////////////////////////////////////////////////////// bool PGItem:: has_sound(const string &event) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_sounds.count(event) != 0); } #endif // HAVE_AUDIO @@ -1170,7 +1170,7 @@ get_text_node() { void PGItem:: play_sound(const string &event) { #ifdef HAVE_AUDIO - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); Sounds::const_iterator si = _sounds.find(event); if (si != _sounds.end()) { AudioSound *sound = (*si).second; diff --git a/panda/src/pgui/pgItem.h b/panda/src/pgui/pgItem.h index 6d017305dd..71d1f5e179 100644 --- a/panda/src/pgui/pgItem.h +++ b/panda/src/pgui/pgItem.h @@ -29,8 +29,8 @@ #include "textNode.h" #include "plane.h" #include "pmap.h" -#include "reMutex.h" -#include "reMutexHolder.h" +#include "lightReMutex.h" +#include "lightReMutexHolder.h" class PGTop; class MouseWatcherParameter; @@ -199,7 +199,7 @@ private: bool clip_frame(pvector &source_points, const Planef &plane) const; protected: - ReMutex _lock; + LightReMutex _lock; private: PGItemNotify *_notify; diff --git a/panda/src/pgui/pgScrollFrame.I b/panda/src/pgui/pgScrollFrame.I index c13ba5bc38..c5015bea03 100644 --- a/panda/src/pgui/pgScrollFrame.I +++ b/panda/src/pgui/pgScrollFrame.I @@ -34,7 +34,7 @@ set_virtual_frame(float left, float right, float bottom, float top) { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: set_virtual_frame(const LVecBase4f &frame) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _has_virtual_frame = true; _virtual_frame = frame; @@ -53,7 +53,7 @@ set_virtual_frame(const LVecBase4f &frame) { //////////////////////////////////////////////////////////////////// INLINE const LVecBase4f &PGScrollFrame:: get_virtual_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _has_virtual_frame ? _virtual_frame : get_clip_frame(); } @@ -66,7 +66,7 @@ get_virtual_frame() const { //////////////////////////////////////////////////////////////////// INLINE bool PGScrollFrame:: has_virtual_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _has_virtual_frame; } @@ -80,7 +80,7 @@ has_virtual_frame() const { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: clear_virtual_frame() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _has_virtual_frame = false; } @@ -96,7 +96,7 @@ clear_virtual_frame() { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: set_manage_pieces(bool manage_pieces) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _manage_pieces = manage_pieces; _needs_remanage = true; _needs_recompute_clip = true; @@ -110,7 +110,7 @@ set_manage_pieces(bool manage_pieces) { //////////////////////////////////////////////////////////////////// INLINE bool PGScrollFrame:: get_manage_pieces() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _manage_pieces; } @@ -128,7 +128,7 @@ get_manage_pieces() const { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: set_auto_hide(bool auto_hide) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _auto_hide = auto_hide; if (_auto_hide) { set_manage_pieces(true); @@ -144,7 +144,7 @@ set_auto_hide(bool auto_hide) { //////////////////////////////////////////////////////////////////// INLINE bool PGScrollFrame:: get_auto_hide() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _auto_hide; } @@ -158,7 +158,7 @@ get_auto_hide() const { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: set_horizontal_slider(PGSliderBar *horizontal_slider) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_horizontal_slider != (PGSliderBar *)NULL) { _horizontal_slider->set_notify(NULL); } @@ -190,7 +190,7 @@ clear_horizontal_slider() { //////////////////////////////////////////////////////////////////// INLINE PGSliderBar *PGScrollFrame:: get_horizontal_slider() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _horizontal_slider; } @@ -204,7 +204,7 @@ get_horizontal_slider() const { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: set_vertical_slider(PGSliderBar *vertical_slider) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_vertical_slider != (PGSliderBar *)NULL) { _vertical_slider->set_notify(NULL); } @@ -236,7 +236,7 @@ clear_vertical_slider() { //////////////////////////////////////////////////////////////////// INLINE PGSliderBar *PGScrollFrame:: get_vertical_slider() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _vertical_slider; } @@ -248,7 +248,7 @@ get_vertical_slider() const { //////////////////////////////////////////////////////////////////// INLINE void PGScrollFrame:: recompute() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); recompute_clip(); recompute_canvas(); } diff --git a/panda/src/pgui/pgScrollFrame.cxx b/panda/src/pgui/pgScrollFrame.cxx index acd4756b75..f1b8520719 100644 --- a/panda/src/pgui/pgScrollFrame.cxx +++ b/panda/src/pgui/pgScrollFrame.cxx @@ -76,7 +76,7 @@ PGScrollFrame(const PGScrollFrame ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGScrollFrame:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGScrollFrame(*this); } @@ -107,7 +107,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// bool PGScrollFrame:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_manage_pieces && _needs_remanage) { remanage(); } @@ -129,7 +129,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: xform(const LMatrix4f &mat) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGVirtualFrame::xform(mat); _needs_remanage = true; @@ -146,7 +146,7 @@ void PGScrollFrame:: setup(float width, float height, float left, float right, float bottom, float top, float slider_width, float bevel) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -200,7 +200,7 @@ setup(float width, float height, //////////////////////////////////////////////////////////////////// void PGScrollFrame:: remanage() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_remanage = false; const LVecBase4f &frame = get_frame(); @@ -317,7 +317,7 @@ remanage() { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: frame_changed() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGVirtualFrame::frame_changed(); _needs_remanage = true; _needs_recompute_clip = true; @@ -331,7 +331,7 @@ frame_changed() { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: item_transform_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute_clip = true; } @@ -343,7 +343,7 @@ item_transform_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: item_frame_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute_clip = true; } @@ -355,7 +355,7 @@ item_frame_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: item_draw_mask_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_remanage = true; _needs_recompute_clip = true; } @@ -368,7 +368,7 @@ item_draw_mask_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: slider_bar_adjust(PGSliderBar *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute_canvas = true; } @@ -380,7 +380,7 @@ slider_bar_adjust(PGSliderBar *) { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: recompute_clip() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute_clip = false; _needs_recompute_canvas = true; @@ -408,7 +408,7 @@ recompute_clip() { //////////////////////////////////////////////////////////////////// void PGScrollFrame:: recompute_canvas() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute_canvas = false; const LVecBase4f &clip = get_clip_frame(); @@ -435,7 +435,7 @@ float PGScrollFrame:: interpolate_canvas(float clip_min, float clip_max, float canvas_min, float canvas_max, PGSliderBar *slider_bar) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); float t = 0.0f; if (slider_bar != (PGSliderBar *)NULL) { t = slider_bar->get_ratio(); diff --git a/panda/src/pgui/pgSliderBar.I b/panda/src/pgui/pgSliderBar.I index f1e3298a0a..ec548b63ba 100755 --- a/panda/src/pgui/pgSliderBar.I +++ b/panda/src/pgui/pgSliderBar.I @@ -60,7 +60,7 @@ get_notify() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_axis(const LVector3f &axis) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _axis = axis; _needs_remanage = true; _needs_recompute = true; @@ -74,7 +74,7 @@ set_axis(const LVector3f &axis) { //////////////////////////////////////////////////////////////////// INLINE const LVector3f &PGSliderBar:: get_axis() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _axis; } @@ -85,7 +85,7 @@ get_axis() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_range(float min_value, float max_value) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertv(min_value != max_value); _min_value = min_value; _max_value = max_value; @@ -104,7 +104,7 @@ set_range(float min_value, float max_value) { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_min_value() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _min_value; } @@ -116,7 +116,7 @@ get_min_value() const { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_max_value() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _max_value; } @@ -128,7 +128,7 @@ get_max_value() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_scroll_size(float value) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _scroll_value = value; _needs_recompute = true; } @@ -140,7 +140,7 @@ set_scroll_size(float value) { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_scroll_size() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _scroll_value; } @@ -155,7 +155,7 @@ get_scroll_size() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_page_size(float value) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _page_value = value; _needs_recompute = true; } @@ -167,7 +167,7 @@ set_page_size(float value) { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_page_size() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _page_value; } @@ -180,7 +180,7 @@ get_page_size() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_value(float value) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_ratio((value - _min_value) / (_max_value - _min_value)); } @@ -191,7 +191,7 @@ set_value(float value) { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_value() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_ratio() * (_max_value - _min_value) + _min_value; } @@ -203,7 +203,7 @@ get_value() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_ratio(float ratio) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (!is_button_down()) { internal_set_ratio(ratio); } @@ -217,7 +217,7 @@ set_ratio(float ratio) { //////////////////////////////////////////////////////////////////// INLINE float PGSliderBar:: get_ratio() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _ratio; } @@ -231,7 +231,7 @@ get_ratio() const { //////////////////////////////////////////////////////////////////// INLINE bool PGSliderBar:: is_button_down() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _dragging || _mouse_button_page || (_scroll_button_held != (PGItem *)NULL); } @@ -246,7 +246,7 @@ is_button_down() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_resize_thumb(bool resize_thumb) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _resize_thumb = resize_thumb; _needs_recompute = true; } @@ -259,7 +259,7 @@ set_resize_thumb(bool resize_thumb) { //////////////////////////////////////////////////////////////////// INLINE bool PGSliderBar:: get_resize_thumb() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _resize_thumb; } @@ -274,7 +274,7 @@ get_resize_thumb() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_manage_pieces(bool manage_pieces) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _manage_pieces = manage_pieces; _needs_remanage = true; _needs_recompute = true; @@ -288,7 +288,7 @@ set_manage_pieces(bool manage_pieces) { //////////////////////////////////////////////////////////////////// INLINE bool PGSliderBar:: get_manage_pieces() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _manage_pieces; } @@ -306,7 +306,7 @@ get_manage_pieces() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_thumb_button(PGButton *thumb_button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_thumb_button != (PGButton *)NULL) { _thumb_button->set_notify(NULL); } @@ -338,7 +338,7 @@ clear_thumb_button() { //////////////////////////////////////////////////////////////////// INLINE PGButton *PGSliderBar:: get_thumb_button() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _thumb_button; } @@ -356,7 +356,7 @@ get_thumb_button() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_left_button(PGButton *left_button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_left_button != (PGButton *)NULL) { _left_button->set_notify(NULL); } @@ -389,7 +389,7 @@ clear_left_button() { //////////////////////////////////////////////////////////////////// INLINE PGButton *PGSliderBar:: get_left_button() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _left_button; } @@ -407,7 +407,7 @@ get_left_button() const { //////////////////////////////////////////////////////////////////// INLINE void PGSliderBar:: set_right_button(PGButton *right_button) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_right_button != (PGButton *)NULL) { _right_button->set_notify(NULL); } @@ -440,7 +440,7 @@ clear_right_button() { //////////////////////////////////////////////////////////////////// INLINE PGButton *PGSliderBar:: get_right_button() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _right_button; } @@ -465,7 +465,7 @@ get_adjust_prefix() { //////////////////////////////////////////////////////////////////// INLINE string PGSliderBar:: get_adjust_event() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return get_adjust_prefix() + get_id(); } diff --git a/panda/src/pgui/pgSliderBar.cxx b/panda/src/pgui/pgSliderBar.cxx index 74813e9333..32006b153d 100755 --- a/panda/src/pgui/pgSliderBar.cxx +++ b/panda/src/pgui/pgSliderBar.cxx @@ -98,7 +98,7 @@ PGSliderBar(const PGSliderBar ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGSliderBar:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGSliderBar(*this); } @@ -111,7 +111,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// void PGSliderBar:: press(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (param.has_mouse()) { _mouse_pos = param.get_mouse(); } @@ -140,7 +140,7 @@ press(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: release(const MouseWatcherParameter ¶m, bool background) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (MouseButton::is_mouse_button(param.get_button())) { _mouse_button_page = false; } @@ -158,7 +158,7 @@ release(const MouseWatcherParameter ¶m, bool background) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: move(const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _mouse_pos = param.get_mouse(); if (_dragging) { // We only get here if we the user originally clicked on the @@ -197,7 +197,7 @@ move(const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// bool PGSliderBar:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_manage_pieces && _needs_remanage) { remanage(); } @@ -231,7 +231,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: xform(const LMatrix4f &mat) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::xform(mat); _axis = _axis * mat; @@ -254,7 +254,7 @@ xform(const LMatrix4f &mat) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: adjust() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); string event = get_adjust_event(); play_sound(event); throw_event(event); @@ -280,7 +280,7 @@ adjust() { //////////////////////////////////////////////////////////////////// void PGSliderBar:: setup_scroll_bar(bool vertical, float length, float width, float bevel) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -354,7 +354,7 @@ setup_scroll_bar(bool vertical, float length, float width, float bevel) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: setup_slider(bool vertical, float length, float width, float bevel) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -410,7 +410,7 @@ setup_slider(bool vertical, float length, float width, float bevel) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: set_active(bool active) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::set_active(active); // This also implicitly sets the managed pieces. @@ -434,7 +434,7 @@ set_active(bool active) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: remanage() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_remanage = false; const LVecBase4f &frame = get_frame(); @@ -486,7 +486,7 @@ remanage() { //////////////////////////////////////////////////////////////////// void PGSliderBar:: recompute() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute = false; if (_min_value != _max_value) { @@ -603,7 +603,7 @@ recompute() { //////////////////////////////////////////////////////////////////// void PGSliderBar:: frame_changed() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PGItem::frame_changed(); _needs_remanage = true; _needs_recompute = true; @@ -617,7 +617,7 @@ frame_changed() { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_transform_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute = true; } @@ -629,7 +629,7 @@ item_transform_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_frame_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute = true; } @@ -641,7 +641,7 @@ item_frame_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_draw_mask_changed(PGItem *) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _needs_recompute = true; } @@ -653,7 +653,7 @@ item_draw_mask_changed(PGItem *) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_press(PGItem *item, const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (param.has_mouse()) { _mouse_pos = param.get_mouse(); } @@ -678,7 +678,7 @@ item_press(PGItem *item, const MouseWatcherParameter ¶m) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_release(PGItem *item, const MouseWatcherParameter &) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (item == _scroll_button_held) { _scroll_button_held = NULL; @@ -698,7 +698,7 @@ item_release(PGItem *item, const MouseWatcherParameter &) { //////////////////////////////////////////////////////////////////// void PGSliderBar:: item_move(PGItem *item, const MouseWatcherParameter ¶m) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _mouse_pos = param.get_mouse(); if (item == _thumb_button) { if (_dragging) { diff --git a/panda/src/pgui/pgVirtualFrame.I b/panda/src/pgui/pgVirtualFrame.I index 6c4baed0b1..e388313650 100644 --- a/panda/src/pgui/pgVirtualFrame.I +++ b/panda/src/pgui/pgVirtualFrame.I @@ -37,7 +37,7 @@ set_clip_frame(float left, float right, float bottom, float top) { //////////////////////////////////////////////////////////////////// INLINE const LVecBase4f &PGVirtualFrame:: get_clip_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _has_clip_frame ? _clip_frame : get_frame(); } @@ -50,7 +50,7 @@ get_clip_frame() const { //////////////////////////////////////////////////////////////////// INLINE bool PGVirtualFrame:: has_clip_frame() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _has_clip_frame; } @@ -63,7 +63,7 @@ has_clip_frame() const { //////////////////////////////////////////////////////////////////// INLINE void PGVirtualFrame:: set_canvas_transform(const TransformState *transform) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _canvas_node->set_transform(transform); } @@ -76,7 +76,7 @@ set_canvas_transform(const TransformState *transform) { //////////////////////////////////////////////////////////////////// INLINE const TransformState *PGVirtualFrame:: get_canvas_transform() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _canvas_node->get_transform(); } @@ -88,7 +88,7 @@ get_canvas_transform() const { //////////////////////////////////////////////////////////////////// INLINE PandaNode *PGVirtualFrame:: get_canvas_node() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _canvas_node; } @@ -99,6 +99,6 @@ get_canvas_node() const { //////////////////////////////////////////////////////////////////// INLINE PandaNode *PGVirtualFrame:: get_canvas_parent() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _canvas_parent; } diff --git a/panda/src/pgui/pgVirtualFrame.cxx b/panda/src/pgui/pgVirtualFrame.cxx index da0cee35bb..3def951f11 100644 --- a/panda/src/pgui/pgVirtualFrame.cxx +++ b/panda/src/pgui/pgVirtualFrame.cxx @@ -72,7 +72,7 @@ PGVirtualFrame(const PGVirtualFrame ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGVirtualFrame:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGVirtualFrame(*this); } @@ -94,7 +94,7 @@ make_copy() const { void PGVirtualFrame:: r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, Thread *current_thread) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); PandaNode::r_copy_children(from, inst_map, current_thread); // Reassign the canvas_node to point to the new copy, if it's there. @@ -131,7 +131,7 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, //////////////////////////////////////////////////////////////////// void PGVirtualFrame:: setup(float width, float height) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -162,7 +162,7 @@ setup(float width, float height) { //////////////////////////////////////////////////////////////////// void PGVirtualFrame:: set_clip_frame(const LVecBase4f &frame) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (!_has_clip_frame || _clip_frame != frame) { _has_clip_frame = true; _clip_frame = frame; @@ -186,7 +186,7 @@ set_clip_frame(const LVecBase4f &frame) { //////////////////////////////////////////////////////////////////// void PGVirtualFrame:: clear_clip_frame() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_has_clip_frame) { _has_clip_frame = false; diff --git a/panda/src/pgui/pgWaitBar.I b/panda/src/pgui/pgWaitBar.I index acdc5db800..e241b5d59e 100644 --- a/panda/src/pgui/pgWaitBar.I +++ b/panda/src/pgui/pgWaitBar.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE void PGWaitBar:: set_range(float range) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _range = range; _bar_state = -1; } @@ -32,7 +32,7 @@ set_range(float range) { //////////////////////////////////////////////////////////////////// INLINE float PGWaitBar:: get_range() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _range; } @@ -44,7 +44,7 @@ get_range() const { //////////////////////////////////////////////////////////////////// INLINE void PGWaitBar:: set_value(float value) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _value = value; _bar_state = -1; } @@ -56,7 +56,7 @@ set_value(float value) { //////////////////////////////////////////////////////////////////// INLINE float PGWaitBar:: get_value() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _value; } @@ -67,7 +67,7 @@ get_value() const { //////////////////////////////////////////////////////////////////// INLINE float PGWaitBar:: get_percent() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return (_value / _range) * 100.0f; } @@ -79,7 +79,7 @@ get_percent() const { //////////////////////////////////////////////////////////////////// INLINE void PGWaitBar:: set_bar_style(const PGFrameStyle &style) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); _bar_style = style; _bar_state = -1; } @@ -92,6 +92,6 @@ set_bar_style(const PGFrameStyle &style) { //////////////////////////////////////////////////////////////////// INLINE PGFrameStyle PGWaitBar:: get_bar_style() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _bar_style; } diff --git a/panda/src/pgui/pgWaitBar.cxx b/panda/src/pgui/pgWaitBar.cxx index 40ccfe805f..c7a85e6df9 100644 --- a/panda/src/pgui/pgWaitBar.cxx +++ b/panda/src/pgui/pgWaitBar.cxx @@ -67,7 +67,7 @@ PGWaitBar(const PGWaitBar ©) : //////////////////////////////////////////////////////////////////// PandaNode *PGWaitBar:: make_copy() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return new PGWaitBar(*this); } @@ -98,7 +98,7 @@ make_copy() const { //////////////////////////////////////////////////////////////////// bool PGWaitBar:: cull_callback(CullTraverser *trav, CullTraverserData &data) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); update(); return PGItem::cull_callback(trav, data); } @@ -111,7 +111,7 @@ cull_callback(CullTraverser *trav, CullTraverserData &data) { //////////////////////////////////////////////////////////////////// void PGWaitBar:: setup(float width, float height, float range) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); set_state(0); clear_state_def(0); @@ -139,7 +139,7 @@ setup(float width, float height, float range) { //////////////////////////////////////////////////////////////////// void PGWaitBar:: update() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); int state = get_state(); // If the bar was last drawn in this state and is still current, we diff --git a/panda/src/pipeline/Sources.pp b/panda/src/pipeline/Sources.pp index ab3ee08b07..8d218a19bb 100644 --- a/panda/src/pipeline/Sources.pp +++ b/panda/src/pipeline/Sources.pp @@ -36,6 +36,12 @@ cycleDataWriter.h cycleDataWriter.I \ cyclerHolder.h cyclerHolder.I \ externalThread.h \ + lightMutex.I lightMutex.h \ + lightMutexDirect.h lightMutexDirect.I \ + lightMutexHolder.I lightMutexHolder.h \ + lightReMutex.I lightReMutex.h \ + lightReMutexDirect.h lightReMutexDirect.I \ + lightReMutexHolder.I lightReMutexHolder.h \ mainThread.h \ mutexDebug.h mutexDebug.I \ mutexDirect.h mutexDirect.I \ @@ -85,6 +91,12 @@ cycleDataWriter.cxx \ cyclerHolder.cxx \ externalThread.cxx \ + lightMutex.cxx \ + lightMutexDirect.cxx \ + lightMutexHolder.cxx \ + lightReMutex.cxx \ + lightReMutexDirect.cxx \ + lightReMutexHolder.cxx \ mainThread.cxx \ mutexDebug.cxx \ mutexDirect.cxx \ @@ -134,6 +146,12 @@ cycleDataWriter.h cycleDataWriter.I \ cyclerHolder.h cyclerHolder.I \ externalThread.h \ + lightMutex.I lightMutex.h \ + lightMutexDirect.h lightMutexDirect.I \ + lightMutexHolder.I lightMutexHolder.h \ + lightReMutex.I lightReMutex.h \ + lightReMutexDirect.h lightReMutexDirect.I \ + lightReMutexHolder.I lightReMutexHolder.h \ mainThread.h \ mutexDebug.h mutexDebug.I \ mutexDirect.h mutexDirect.I \ diff --git a/panda/src/pipeline/lightMutex.I b/panda/src/pipeline/lightMutex.I new file mode 100644 index 0000000000..7f6a3096cf --- /dev/null +++ b/panda/src/pipeline/lightMutex.I @@ -0,0 +1,90 @@ +// Filename: lightMutex.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutex:: +#ifdef DEBUG_THREADS +LightMutex() : MutexDebug(string(), false, true) +#else +LightMutex() +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutex:: +#ifdef DEBUG_THREADS +LightMutex(const char *name) : MutexDebug(string(name), false, true) +#else +LightMutex(const char *) +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Constructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutex:: +#ifdef DEBUG_THREADS +LightMutex(const string &name) : MutexDebug(name, false, true) +#else +LightMutex(const string &) +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutex:: +~LightMutex() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Copy Constructor +// Access: Private +// Description: Do not attempt to copy lightMutexes. +//////////////////////////////////////////////////////////////////// +INLINE LightMutex:: +#ifdef DEBUG_THREADS +LightMutex(const LightMutex ©) : MutexDebug(string(), false, true) +#else + LightMutex(const LightMutex ©) +#endif // DEBUG_THREADS +{ + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutex::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy lightMutexes. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutex:: +operator = (const LightMutex ©) { + nassertv(false); +} diff --git a/panda/src/pipeline/lightMutex.cxx b/panda/src/pipeline/lightMutex.cxx new file mode 100644 index 0000000000..7c1415a7a0 --- /dev/null +++ b/panda/src/pipeline/lightMutex.cxx @@ -0,0 +1,15 @@ +// Filename: lightMutex.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightMutex.h" diff --git a/panda/src/pipeline/lightMutex.h b/panda/src/pipeline/lightMutex.h new file mode 100644 index 0000000000..5cd03a90b4 --- /dev/null +++ b/panda/src/pipeline/lightMutex.h @@ -0,0 +1,62 @@ +// Filename: lightMutex.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTMUTEX_H +#define LIGHTMUTEX_H + +#include "pandabase.h" +#include "mutexDebug.h" +#include "lightMutexDirect.h" + +//////////////////////////////////////////////////////////////////// +// Class : LightMutex +// Description : This is a standard, non-reentrant mutex, similar to +// the Mutex class. It is different from Mutex in the +// case of SIMPLE_THREADS: in this case, the LightMutex +// class compiles to nothing; it performs no locking +// whatsoever. It is therefore useful only to protect +// very small sections of code, during which you are +// confident there will be no thread yields. +// +// In the normal, system-threaded implementation, this +// class is exactly the same as Mutex. +// +// ConditionVars cannot be used with LightMutex; they +// work only with Mutex. +// +// This class inherits its implementation either from +// MutexDebug or LightMutexDirect, depending on the +// definition of DEBUG_THREADS. +//////////////////////////////////////////////////////////////////// +#ifdef DEBUG_THREADS +class EXPCL_PANDA_PIPELINE LightMutex : public MutexDebug +#else +class EXPCL_PANDA_PIPELINE LightMutex : public LightMutexDirect +#endif // DEBUG_THREADS +{ +PUBLISHED: + INLINE LightMutex(); +public: + INLINE LightMutex(const char *name); +PUBLISHED: + INLINE LightMutex(const string &name); + INLINE ~LightMutex(); +private: + INLINE LightMutex(const LightMutex ©); + INLINE void operator = (const LightMutex ©); +}; + +#include "lightMutex.I" + +#endif diff --git a/panda/src/pipeline/lightMutexDirect.I b/panda/src/pipeline/lightMutexDirect.I new file mode 100644 index 0000000000..a4d7fdfb8e --- /dev/null +++ b/panda/src/pipeline/lightMutexDirect.I @@ -0,0 +1,146 @@ +// Filename: lightMutexDirect.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::Constructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutexDirect:: +LightMutexDirect() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::Destructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutexDirect:: +~LightMutexDirect() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::Copy Constructor +// Access: Private +// Description: Do not attempt to copy lightMutexes. +//////////////////////////////////////////////////////////////////// +INLINE LightMutexDirect:: +LightMutexDirect(const LightMutexDirect ©) { + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy lightMutexes. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexDirect:: +operator = (const LightMutexDirect ©) { + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::lock +// Access: Published +// Description: Grabs the lightMutex if it is available. If it is not +// available, blocks until it becomes available, then +// grabs it. In either case, the function does not +// return until the lightMutex is held; you should then call +// unlock(). +// +// This method is considered const so that you can lock +// and unlock const lightMutexes, mainly to allow thread-safe +// access to otherwise const data. +// +// Also see LightMutexHolder. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexDirect:: +lock() const { + TAU_PROFILE("void LightMutexDirect::lock()", " ", TAU_USER); + ((LightMutexDirect *)this)->_impl.lock(); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::release +// Access: Published +// Description: Releases the lightMutex. It is an error to call this if +// the lightMutex was not already locked. +// +// This method is considered const so that you can lock +// and unlock const lightMutexes, mainly to allow thread-safe +// access to otherwise const data. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexDirect:: +release() const { + TAU_PROFILE("void LightMutexDirect::release()", " ", TAU_USER); + ((LightMutexDirect *)this)->_impl.release(); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::debug_is_locked +// Access: Published +// Description: Returns true if the current thread has locked the +// LightMutex, false otherwise. This method is only intended +// for use in debugging, hence the method name; in the +// LightMutexDirect case, it always returns true, since +// there's not a reliable way to determine this +// otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool LightMutexDirect:: +debug_is_locked() const { + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::set_name +// Access: Public +// Description: The lightMutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexDirect:: +set_name(const string &) { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::clear_name +// Access: Public +// Description: The lightMutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexDirect:: +clear_name() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::has_name +// Access: Public +// Description: The lightMutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE bool LightMutexDirect:: +has_name() const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::get_name +// Access: Public +// Description: The lightMutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE string LightMutexDirect:: +get_name() const { + return string(); +} diff --git a/panda/src/pipeline/lightMutexDirect.cxx b/panda/src/pipeline/lightMutexDirect.cxx new file mode 100644 index 0000000000..2a3e82b245 --- /dev/null +++ b/panda/src/pipeline/lightMutexDirect.cxx @@ -0,0 +1,30 @@ +// Filename: lightMutexDirect.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightMutexDirect.h" + +#ifndef DEBUG_THREADS + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexDirect::output +// Access: Public +// Description: This method is declared virtual in LightMutexDebug, but +// non-virtual in LightMutexDirect. +//////////////////////////////////////////////////////////////////// +void LightMutexDirect:: +output(ostream &out) const { + out << "LightMutex " << (void *)this; +} + +#endif // !DEBUG_THREADS diff --git a/panda/src/pipeline/lightMutexDirect.h b/panda/src/pipeline/lightMutexDirect.h new file mode 100644 index 0000000000..00f5d7e201 --- /dev/null +++ b/panda/src/pipeline/lightMutexDirect.h @@ -0,0 +1,65 @@ +// Filename: lightMutexDirect.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTMUTEXDIRECT_H +#define LIGHTMUTEXDIRECT_H + +#include "pandabase.h" +#include "mutexImpl.h" + +class Thread; + +#ifndef DEBUG_THREADS + +//////////////////////////////////////////////////////////////////// +// Class : LightMutexDirect +// Description : This class implements a lightweight Mutex by making +// direct calls to the underlying implementation layer. +// It doesn't perform any debugging operations. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PIPELINE LightMutexDirect { +protected: + INLINE LightMutexDirect(); + INLINE ~LightMutexDirect(); +private: + INLINE LightMutexDirect(const LightMutexDirect ©); + INLINE void operator = (const LightMutexDirect ©); + +PUBLISHED: + BLOCKING INLINE void lock() const; + INLINE void release() const; + INLINE bool debug_is_locked() const; + + INLINE void set_name(const string &name); + INLINE void clear_name(); + INLINE bool has_name() const; + INLINE string get_name() const; + + void output(ostream &out) const; + +private: + MutexImpl _impl; +}; + +INLINE ostream & +operator << (ostream &out, const LightMutexDirect &m) { + m.output(out); + return out; +} + +#include "lightMutexDirect.I" + +#endif // !DEBUG_THREADS + +#endif diff --git a/panda/src/pipeline/lightMutexHolder.I b/panda/src/pipeline/lightMutexHolder.I new file mode 100644 index 0000000000..885b61e74b --- /dev/null +++ b/panda/src/pipeline/lightMutexHolder.I @@ -0,0 +1,81 @@ +// Filename: lightMutexHolder.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexHolder::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutexHolder:: +LightMutexHolder(const LightMutex &mutex) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex = &mutex; + _mutex->lock(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexHolder::Constructor +// Access: Public +// Description: If the LightMutexHolder constructor is given a pointer to +// a LightMutex object (instead of an actual object), it will +// first check to see if the pointer is NULL, and +// allocate a new LightMutex if it is. This is intended as a +// convenience for functions that may need to reference +// a LightMutex at static init time, when it is impossible to +// guarantee ordering of initializers. +//////////////////////////////////////////////////////////////////// +INLINE LightMutexHolder:: +LightMutexHolder(LightMutex *&mutex) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + if (mutex == (LightMutex *)NULL) { + mutex = new LightMutex; + } + _mutex = mutex; + _mutex->lock(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexHolder::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightMutexHolder:: +~LightMutexHolder() { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex->release(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexHolder::Copy Constructor +// Access: Private +// Description: Do not attempt to copy LightMutexHolders. +//////////////////////////////////////////////////////////////////// +INLINE LightMutexHolder:: +LightMutexHolder(const LightMutexHolder ©) { + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightMutexHolder::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy LightMutexHolders. +//////////////////////////////////////////////////////////////////// +INLINE void LightMutexHolder:: +operator = (const LightMutexHolder ©) { + nassertv(false); +} diff --git a/panda/src/pipeline/lightMutexHolder.cxx b/panda/src/pipeline/lightMutexHolder.cxx new file mode 100644 index 0000000000..61453ccb82 --- /dev/null +++ b/panda/src/pipeline/lightMutexHolder.cxx @@ -0,0 +1,15 @@ +// Filename: lightMutexHolder.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightMutexHolder.h" diff --git a/panda/src/pipeline/lightMutexHolder.h b/panda/src/pipeline/lightMutexHolder.h new file mode 100644 index 0000000000..7f9ad4c41c --- /dev/null +++ b/panda/src/pipeline/lightMutexHolder.h @@ -0,0 +1,44 @@ +// Filename: lightMutexHolder.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTMUTEXHOLDER_H +#define LIGHTMUTEXHOLDER_H + +#include "pandabase.h" +#include "lightMutex.h" + +class Thread; + +//////////////////////////////////////////////////////////////////// +// Class : LightMutexHolder +// Description : Similar to MutexHolder, but for a light mutex. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PIPELINE LightMutexHolder { +public: + INLINE LightMutexHolder(const LightMutex &mutex); + INLINE LightMutexHolder(LightMutex *&mutex); + INLINE ~LightMutexHolder(); +private: + INLINE LightMutexHolder(const LightMutexHolder ©); + INLINE void operator = (const LightMutexHolder ©); + +private: +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + const LightMutex *_mutex; +#endif +}; + +#include "lightMutexHolder.I" + +#endif diff --git a/panda/src/pipeline/lightReMutex.I b/panda/src/pipeline/lightReMutex.I new file mode 100644 index 0000000000..1ace101e29 --- /dev/null +++ b/panda/src/pipeline/lightReMutex.I @@ -0,0 +1,75 @@ +// Filename: lightReMutex.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutex::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutex:: +#ifdef DEBUG_THREADS +LightReMutex() : MutexDebug(string(), true, true) +#else +LightReMutex() +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutex::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutex:: +#ifdef DEBUG_THREADS +LightReMutex(const char *name) : MutexDebug(string(name), true, true) +#else +LightReMutex(const char *) +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutex::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutex:: +#ifdef DEBUG_THREADS +LightReMutex(const string &name) : MutexDebug(name, true, true) +#else +LightReMutex(const string &) +#endif // DEBUG_THREADS +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutex::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutex:: +~LightReMutex() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutex::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy mutexes. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutex:: +operator = (const LightReMutex ©) { + nassertv(false); +} diff --git a/panda/src/pipeline/lightReMutex.cxx b/panda/src/pipeline/lightReMutex.cxx new file mode 100644 index 0000000000..e64f8ed730 --- /dev/null +++ b/panda/src/pipeline/lightReMutex.cxx @@ -0,0 +1,15 @@ +// Filename: lightReMutex.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightReMutex.h" diff --git a/panda/src/pipeline/lightReMutex.h b/panda/src/pipeline/lightReMutex.h new file mode 100644 index 0000000000..cc506acacb --- /dev/null +++ b/panda/src/pipeline/lightReMutex.h @@ -0,0 +1,51 @@ +// Filename: lightReMutex.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTREMUTEX_H +#define LIGHTREMUTEX_H + +#include "pandabase.h" +#include "mutexDebug.h" +#include "lightReMutexDirect.h" + +//////////////////////////////////////////////////////////////////// +// Class : LightReMutex +// Description : A lightweight reentrant mutex. See LightMutex and +// ReMutex. +// +// This class inherits its implementation either from +// MutexDebug or LightReMutexDirect, depending on the +// definition of DEBUG_THREADS. +//////////////////////////////////////////////////////////////////// +#ifdef DEBUG_THREADS +class EXPCL_PANDA_PIPELINE LightReMutex : public MutexDebug +#else +class EXPCL_PANDA_PIPELINE LightReMutex : public LightReMutexDirect +#endif // DEBUG_THREADS +{ +PUBLISHED: + INLINE LightReMutex(); +public: + INLINE LightReMutex(const char *name); +PUBLISHED: + INLINE LightReMutex(const string &name); + INLINE ~LightReMutex(); +private: + INLINE LightReMutex(const LightReMutex ©); + INLINE void operator = (const LightReMutex ©); +}; + +#include "lightReMutex.I" + +#endif diff --git a/panda/src/pipeline/lightReMutexDirect.I b/panda/src/pipeline/lightReMutexDirect.I new file mode 100644 index 0000000000..0d3d9c504e --- /dev/null +++ b/panda/src/pipeline/lightReMutexDirect.I @@ -0,0 +1,200 @@ +// Filename: lightReMutexDirect.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::Constructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexDirect:: +LightReMutexDirect() +#ifndef HAVE_REMUTEXIMPL + : _cvar_impl(_lock_impl) +#endif +{ +#ifndef HAVE_REMUTEXIMPL + _locking_thread = NULL; + _lock_count = 0; +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::Destructor +// Access: Protected +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexDirect:: +~LightReMutexDirect() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::Copy Constructor +// Access: Private +// Description: Do not attempt to copy lightReMutexes. +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexDirect:: +LightReMutexDirect(const LightReMutexDirect ©) +#ifndef HAVE_REMUTEXIMPL + : _cvar_impl(_lock_impl) +#endif +{ + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy lightReMutexes. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +operator = (const LightReMutexDirect ©) { + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::lock +// Access: Published +// Description: Grabs the lightReMutex if it is available. If it is not +// available, blocks until it becomes available, then +// grabs it. In either case, the function does not +// return until the lightReMutex is held; you should then call +// unlock(). +// +// This method is considered const so that you can lock +// and unlock const lightReMutexes, mainly to allow thread-safe +// access to otherwise const data. +// +// Also see LightReMutexHolder. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +lock() const { + TAU_PROFILE("void LightReMutexDirect::lock()", " ", TAU_USER); + ((LightReMutexDirect *)this)->_impl.lock(); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::lock +// Access: Published +// Description: This variant on lock() accepts the current thread as +// a parameter, if it is already known, as an +// optimization. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +lock(Thread *current_thread) const { + TAU_PROFILE("void LightReMutexDirect::lock(Thread *)", " ", TAU_USER); +#ifdef HAVE_REMUTEXIMPL + ((LightReMutexDirect *)this)->_impl.lock(); +#else + ((LightReMutexDirect *)this)->_impl.do_lock(current_thread); +#endif // HAVE_REMUTEXIMPL +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::elevate_lock +// Access: Published +// Description: This method increments the lock count, assuming the +// calling thread already holds the lock. After this +// call, release() will need to be called one additional +// time to release the lock. +// +// This method really performs the same function as +// lock(), but it offers a potential (slight) +// performance benefit when the calling thread knows +// that it already holds the lock. It is an error to +// call this when the calling thread does not hold the +// lock. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +elevate_lock() const { + TAU_PROFILE("void LightReMutexDirect::elevate_lock()", " ", TAU_USER); +#ifdef HAVE_REMUTEXIMPL + ((LightReMutexDirect *)this)->_impl.lock(); +#else + ((LightReMutexDirect *)this)->_impl.do_elevate_lock(); +#endif // HAVE_REMUTEXIMPL +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::release +// Access: Published +// Description: Releases the lightReMutex. It is an error to call this if +// the lightReMutex was not already locked. +// +// This method is considered const so that you can lock +// and unlock const lightReMutexes, mainly to allow thread-safe +// access to otherwise const data. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +release() const { + TAU_PROFILE("void LightReMutexDirect::release()", " ", TAU_USER); + ((LightReMutexDirect *)this)->_impl.release(); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::debug_is_locked +// Access: Published +// Description: Returns true if the current thread has locked the +// LightReMutex, false otherwise. This method is only intended +// for use in debugging, hence the method name; in the +// LightReMutexDirect case, it always returns true, since +// there's not a reliable way to determine this +// otherwise. +//////////////////////////////////////////////////////////////////// +INLINE bool LightReMutexDirect:: +debug_is_locked() const { + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::set_name +// Access: Public +// Description: The mutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +set_name(const string &) { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::clear_name +// Access: Public +// Description: The mutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexDirect:: +clear_name() { +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::has_name +// Access: Public +// Description: The mutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE bool LightReMutexDirect:: +has_name() const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::get_name +// Access: Public +// Description: The mutex name is only defined when compiling in +// DEBUG_THREADS mode. +//////////////////////////////////////////////////////////////////// +INLINE string LightReMutexDirect:: +get_name() const { + return string(); +} diff --git a/panda/src/pipeline/lightReMutexDirect.cxx b/panda/src/pipeline/lightReMutexDirect.cxx new file mode 100644 index 0000000000..bd43110698 --- /dev/null +++ b/panda/src/pipeline/lightReMutexDirect.cxx @@ -0,0 +1,27 @@ +// Filename: lightReMutexDirect.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightReMutexDirect.h" +#include "thread.h" + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexDirect::output +// Access: Published +// Description: This method is declared virtual in MutexDebug, but +// non-virtual in LightReMutexDirect. +//////////////////////////////////////////////////////////////////// +void LightReMutexDirect:: +output(ostream &out) const { + out << "LightReMutex " << (void *)this; +} diff --git a/panda/src/pipeline/lightReMutexDirect.h b/panda/src/pipeline/lightReMutexDirect.h new file mode 100644 index 0000000000..d022e8ebe4 --- /dev/null +++ b/panda/src/pipeline/lightReMutexDirect.h @@ -0,0 +1,72 @@ +// Filename: lightReMutexDirect.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTREMUTEXDIRECT_H +#define LIGHTREMUTEXDIRECT_H + +#include "pandabase.h" +#include "mutexImpl.h" +#include "reMutexDirect.h" + +class Thread; + +//////////////////////////////////////////////////////////////////// +// Class : LightReMutexDirect +// Description : This class implements a standard lightReMutex by making +// direct calls to the underlying implementation layer. +// It doesn't perform any debugging operations. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PIPELINE LightReMutexDirect { +protected: + INLINE LightReMutexDirect(); + INLINE ~LightReMutexDirect(); +private: + INLINE LightReMutexDirect(const LightReMutexDirect ©); + INLINE void operator = (const LightReMutexDirect ©); + +PUBLISHED: + BLOCKING INLINE void lock() const; + BLOCKING INLINE void lock(Thread *current_thread) const; + INLINE void elevate_lock() const; + INLINE void release() const; + + INLINE bool debug_is_locked() const; + + INLINE void set_name(const string &name); + INLINE void clear_name(); + INLINE bool has_name() const; + INLINE string get_name() const; + + void output(ostream &out) const; + +private: +#ifdef HAVE_REMUTEXIMPL + ReMutexImpl _impl; + +#else + // If we don't have a reentrant mutex, use the one we hand-rolled in + // ReMutexDirect. + ReMutexDirect _impl; +#endif // HAVE_REMUTEXIMPL +}; + +INLINE ostream & +operator << (ostream &out, const LightReMutexDirect &m) { + m.output(out); + return out; +} + +#include "lightReMutexDirect.I" + +#endif diff --git a/panda/src/pipeline/lightReMutexHolder.I b/panda/src/pipeline/lightReMutexHolder.I new file mode 100644 index 0000000000..3cf1419fc2 --- /dev/null +++ b/panda/src/pipeline/lightReMutexHolder.I @@ -0,0 +1,96 @@ +// Filename: lightReMutexHolder.I +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexHolder:: +LightReMutexHolder(const LightReMutex &mutex) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex = &mutex; + _mutex->lock(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Constructor +// Access: Public +// Description: This variant on the constructor accepts the current +// thread as a parameter, if it is already known, as an +// optimization. +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexHolder:: +LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex = &mutex; + _mutex->lock(current_thread); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Constructor +// Access: Public +// Description: If the LightReMutexHolder constructor is given a pointer to +// a LightReMutex object (instead of an actual object), it will +// first check to see if the pointer is NULL, and +// allocate a new LightReMutex if it is. This is intended as a +// convenience for functions that may need to reference +// a LightReMutex at static init time, when it is impossible to +// guarantee ordering of initializers. +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexHolder:: +LightReMutexHolder(LightReMutex *&mutex) { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + if (mutex == (LightReMutex *)NULL) { + mutex = new LightReMutex; + } + _mutex = mutex; + _mutex->lock(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Destructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexHolder:: +~LightReMutexHolder() { +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + _mutex->release(); +#endif +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Copy Constructor +// Access: Private +// Description: Do not attempt to copy LightReMutexHolders. +//////////////////////////////////////////////////////////////////// +INLINE LightReMutexHolder:: +LightReMutexHolder(const LightReMutexHolder ©) { + nassertv(false); +} + +//////////////////////////////////////////////////////////////////// +// Function: LightReMutexHolder::Copy Assignment Operator +// Access: Private +// Description: Do not attempt to copy LightReMutexHolders. +//////////////////////////////////////////////////////////////////// +INLINE void LightReMutexHolder:: +operator = (const LightReMutexHolder ©) { + nassertv(false); +} diff --git a/panda/src/pipeline/lightReMutexHolder.cxx b/panda/src/pipeline/lightReMutexHolder.cxx new file mode 100644 index 0000000000..f5d4656153 --- /dev/null +++ b/panda/src/pipeline/lightReMutexHolder.cxx @@ -0,0 +1,15 @@ +// Filename: lightReMutexHolder.cxx +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "lightReMutexHolder.h" diff --git a/panda/src/pipeline/lightReMutexHolder.h b/panda/src/pipeline/lightReMutexHolder.h new file mode 100644 index 0000000000..add59cbb74 --- /dev/null +++ b/panda/src/pipeline/lightReMutexHolder.h @@ -0,0 +1,45 @@ +// Filename: lightReMutexHolder.h +// Created by: drose (08Oct08) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef LIGHTREMUTEXHOLDER_H +#define LIGHTREMUTEXHOLDER_H + +#include "pandabase.h" +#include "lightReMutex.h" + +class Thread; + +//////////////////////////////////////////////////////////////////// +// Class : LightReMutexHolder +// Description : Similar to MutexHolder, but for a light reentrant mutex. +//////////////////////////////////////////////////////////////////// +class EXPCL_PANDA_PIPELINE LightReMutexHolder { +public: + INLINE LightReMutexHolder(const LightReMutex &mutex); + INLINE LightReMutexHolder(const LightReMutex &mutex, Thread *current_thread); + INLINE LightReMutexHolder(LightReMutex *&mutex); + INLINE ~LightReMutexHolder(); +private: + INLINE LightReMutexHolder(const LightReMutexHolder ©); + INLINE void operator = (const LightReMutexHolder ©); + +private: +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) + const LightReMutex *_mutex; +#endif +}; + +#include "lightReMutexHolder.I" + +#endif diff --git a/panda/src/pipeline/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx index 16653600e7..f243b8f74e 100755 --- a/panda/src/pipeline/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -26,13 +26,19 @@ MutexTrueImpl *MutexDebug::_global_lock; // Description: //////////////////////////////////////////////////////////////////// MutexDebug:: -MutexDebug(const string &name, bool allow_recursion) : +MutexDebug(const string &name, bool allow_recursion, bool lightweight) : Namable(name), _allow_recursion(allow_recursion), + _lightweight(lightweight), _locking_thread(NULL), _lock_count(0), _cvar_impl(*get_global_lock()) { +#ifndef SIMPLE_THREADS + // If we're using real threads, there's no such thing as a + // lightweight mutex. + _lightweight = false; +#endif } //////////////////////////////////////////////////////////////////// @@ -57,6 +63,9 @@ MutexDebug:: //////////////////////////////////////////////////////////////////// void MutexDebug:: output(ostream &out) const { + if (_lightweight) { + out << "Light"; + } if (_allow_recursion) { out << "ReMutex " << get_name() << " " << (void *)this; } else { @@ -99,76 +108,74 @@ do_lock() { } else { // The mutex is locked by some other thread. -#ifdef PHONY_MUTEX - // In this case, we don't really have mutexes anyway. - MissedThreads::iterator mi = _missed_threads.insert(MissedThreads::value_type(this_thread, 0)).first; - if ((*mi).second == 0) { - thread_cat.info() - << *this_thread << " not stopped by " << *this << " (held by " - << *_locking_thread << ")\n"; + if (_lightweight) { + // In this case, it's not a real mutex. Just watch it go by. + MissedThreads::iterator mi = _missed_threads.insert(MissedThreads::value_type(this_thread, 0)).first; + if ((*mi).second == 0) { + thread_cat.info() + << *this_thread << " not stopped by " << *this << " (held by " + << *_locking_thread << ")\n"; + } else { + if (!_allow_recursion) { + ostringstream ostr; + ostr << *this_thread << " attempted to double-lock non-reentrant " + << *this; + nassert_raise(ostr.str()); + } + } + ++((*mi).second); + } else { - if (!_allow_recursion) { - ostringstream ostr; - ostr << *this_thread << " attempted to double-lock non-reentrant " - << *this; - nassert_raise(ostr.str()); + // This is the real case. It's a real mutex, so block if necessary. + + // Check for deadlock. + MutexDebug *next_mutex = this; + while (next_mutex != NULL) { + if (next_mutex->_locking_thread == this_thread) { + // Whoops, the thread is blocked on me! Deadlock! + report_deadlock(this_thread); + nassert_raise("Deadlock"); + return; + } + Thread *next_thread = next_mutex->_locking_thread; + if (next_thread == NULL) { + // Looks like this mutex isn't actually locked, which means + // the last thread isn't really blocked--it just hasn't woken + // up yet to discover that. In any case, no deadlock. + break; + } + + // The last thread is blocked on this "next thread"'s mutex, but + // what mutex is the next thread blocked on? + next_mutex = next_thread->_blocked_on_mutex; } - } - ++((*mi).second); - -#else // PHONY_MUTEX - // This is the real case. We have mutexes, so enforce it. - - // Check for deadlock. - MutexDebug *next_mutex = this; - while (next_mutex != NULL) { - if (next_mutex->_locking_thread == this_thread) { - // Whoops, the thread is blocked on me! Deadlock! - report_deadlock(this_thread); - nassert_raise("Deadlock"); - - _global_lock->release(); - return; + + // OK, no deadlock detected. Carry on. + this_thread->_blocked_on_mutex = this; + + // Go to sleep on the condition variable until it's unlocked. + + if (thread_cat->is_debug()) { + thread_cat.debug() + << *this_thread << " blocking on " << *this << " (held by " + << *_locking_thread << ")\n"; } - Thread *next_thread = next_mutex->_locking_thread; - if (next_thread == NULL) { - // Looks like this mutex isn't actually locked, which means - // the last thread isn't really blocked--it just hasn't woken - // up yet to discover that. In any case, no deadlock. - break; + + while (_locking_thread != (Thread *)NULL) { + _cvar_impl.wait(); } - - // The last thread is blocked on this "next thread"'s mutex, but - // what mutex is the next thread blocked on? - next_mutex = next_thread->_blocked_on_mutex; + + if (thread_cat.is_debug()) { + thread_cat.debug() + << *this_thread << " awake on " << *this << "\n"; + } + + this_thread->_blocked_on_mutex = NULL; + + _locking_thread = this_thread; + ++_lock_count; + nassertv(_lock_count == 1); } - - // OK, no deadlock detected. Carry on. - this_thread->_blocked_on_mutex = this; - - // Go to sleep on the condition variable until it's unlocked. - - if (thread_cat->is_debug()) { - thread_cat.debug() - << *this_thread << " blocking on " << *this << " (held by " - << *_locking_thread << ")\n"; - } - - while (_locking_thread != (Thread *)NULL) { - _cvar_impl.wait(); - } - - if (thread_cat.is_debug()) { - thread_cat.debug() - << *this_thread << " awake on " << *this << "\n"; - } - - this_thread->_blocked_on_mutex = NULL; - - _locking_thread = this_thread; - ++_lock_count; - nassertv(_lock_count == 1); -#endif // PHONY_MUTEX } } @@ -187,28 +194,28 @@ do_release() { Thread *this_thread = Thread::get_current_thread(); if (_locking_thread != this_thread) { -#ifdef PHONY_MUTEX - // No real mutexes. This just means we blew past a mutex without - // locking it, above. + // We're not holding this mutex. - MissedThreads::iterator mi = _missed_threads.find(this_thread); - nassertv(mi != _missed_threads.end()); - nassertv((*mi).second > 0); - --((*mi).second); + if (_lightweight) { + // Not a real mutex. This just means we blew past a mutex + // without locking it, above. - if ((*mi).second == 0) { - _missed_threads.erase(mi); + MissedThreads::iterator mi = _missed_threads.find(this_thread); + nassertv(mi != _missed_threads.end()); + nassertv((*mi).second > 0); + --((*mi).second); + + if ((*mi).second == 0) { + _missed_threads.erase(mi); + } + + } else { + // In the real-mutex case, this is an error condition. + ostringstream ostr; + ostr << *this_thread << " attempted to release " + << *this << " which it does not own"; + nassert_raise(ostr.str()); } - -#else // PHONY_MUTEX - // In the real-mutex case, this is an error condition. - ostringstream ostr; - ostr << *this_thread << " attempted to release " - << *this << " which it does not own"; - nassert_raise(ostr.str()); -#endif // PHONY_MUTEX - - _global_lock->release(); return; } @@ -219,18 +226,18 @@ do_release() { // That was the last lock held by this thread. Release the lock. _locking_thread = (Thread *)NULL; -#ifdef PHONY_MUTEX - if (!_missed_threads.empty()) { - // Promote some other thread to be the honorary lock holder. - MissedThreads::iterator mi = _missed_threads.begin(); - _locking_thread = (*mi).first; - _lock_count = (*mi).second; - _missed_threads.erase(mi); - nassertv(_lock_count > 0); + if (_lightweight) { + if (!_missed_threads.empty()) { + // Promote some other thread to be the honorary lock holder. + MissedThreads::iterator mi = _missed_threads.begin(); + _locking_thread = (*mi).first; + _lock_count = (*mi).second; + _missed_threads.erase(mi); + nassertv(_lock_count > 0); + } + } else { + _cvar_impl.signal(); } -#else - _cvar_impl.signal(); -#endif } } @@ -247,13 +254,13 @@ do_debug_is_locked() const { return true; } -#ifdef PHONY_MUTEX - MissedThreads::const_iterator mi = _missed_threads.find(this_thread); - if (mi != _missed_threads.end()) { - nassertr((*mi).second > 0, false); - return true; + if (_lightweight) { + MissedThreads::const_iterator mi = _missed_threads.find(this_thread); + if (mi != _missed_threads.end()) { + nassertr((*mi).second > 0, false); + return true; + } } -#endif return false; } diff --git a/panda/src/pipeline/mutexDebug.h b/panda/src/pipeline/mutexDebug.h index 7525b5e170..4dd10f9b2f 100644 --- a/panda/src/pipeline/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -23,14 +23,6 @@ #ifdef DEBUG_THREADS -#if defined(SIMPLE_THREADS) && defined(SIMPLE_THREADS_NO_MUTEX) -// In this mode, we don't actually lock and unlock a mutex. We just -// wave at them as they go by. This actually involves a bit more -// work, here in the debug mode, than a real mutex, because we have to -// track all the threads that failed to lock the mutex. -#define PHONY_MUTEX -#endif - //////////////////////////////////////////////////////////////////// // Class : MutexDebug // Description : This class implements a standard mutex the hard way, @@ -39,7 +31,7 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA_PIPELINE MutexDebug : public Namable { protected: - MutexDebug(const string &name, bool allow_recursion); + MutexDebug(const string &name, bool allow_recursion, bool lightweight); virtual ~MutexDebug(); private: INLINE MutexDebug(const MutexDebug ©); @@ -67,12 +59,13 @@ private: INLINE static MutexTrueImpl *get_global_lock(); bool _allow_recursion; + bool _lightweight; Thread *_locking_thread; int _lock_count; -#ifdef PHONY_MUTEX + + // For _lightweight mutexes. typedef pmap MissedThreads; MissedThreads _missed_threads; -#endif ConditionVarImpl _cvar_impl; diff --git a/panda/src/pipeline/mutexHolder.I b/panda/src/pipeline/mutexHolder.I index 9582ed9266..f61298e65c 100644 --- a/panda/src/pipeline/mutexHolder.I +++ b/panda/src/pipeline/mutexHolder.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE MutexHolder:: MutexHolder(const Mutex &mutex) { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex = &mutex; _mutex->lock(); #endif @@ -39,7 +39,7 @@ MutexHolder(const Mutex &mutex) { //////////////////////////////////////////////////////////////////// INLINE MutexHolder:: MutexHolder(Mutex *&mutex) { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) if (mutex == (Mutex *)NULL) { mutex = new Mutex; } @@ -55,7 +55,7 @@ MutexHolder(Mutex *&mutex) { //////////////////////////////////////////////////////////////////// INLINE MutexHolder:: ~MutexHolder() { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex->release(); #endif } diff --git a/panda/src/pipeline/mutexHolder.h b/panda/src/pipeline/mutexHolder.h index 9ed6a5aee5..90131399ba 100644 --- a/panda/src/pipeline/mutexHolder.h +++ b/panda/src/pipeline/mutexHolder.h @@ -39,10 +39,8 @@ private: // If HAVE_THREADS is defined, the Mutex class implements an actual // mutex object of some kind. If HAVE_THREADS is not defined, this // will be a MutexDummyImpl, which does nothing much anyway, so we - // might as well not even store a pointer to one--but MutexDummyImpl - // does perform some circularity testing in the case that NDEBUG is - // not defined, so we go ahead and store a pointer in that case too. -#if defined(HAVE_THREADS) || !defined(NDEBUG) + // might as well not even store a pointer to one. +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) const Mutex *_mutex; #endif }; diff --git a/panda/src/pipeline/mutexTrueImpl.h b/panda/src/pipeline/mutexTrueImpl.h index c6b620d726..7c6e8dbe50 100644 --- a/panda/src/pipeline/mutexTrueImpl.h +++ b/panda/src/pipeline/mutexTrueImpl.h @@ -33,13 +33,13 @@ // until we have defined the whole ThreadSimpleManager and related // infrastructure. -#if defined(THREAD_SIMPLE_IMPL) && !defined(SIMPLE_THREADS_NO_MUTEX) +#ifdef THREAD_SIMPLE_IMPL #include "mutexSimpleImpl.h" typedef MutexSimpleImpl MutexTrueImpl; #undef HAVE_REMUTEXTRUEIMPL -#else +#else // THREAD_SIMPLE_IMPL typedef MutexImpl MutexTrueImpl; #if HAVE_REMUTEXIMPL @@ -49,7 +49,7 @@ typedef ReMutexImpl ReMutexTrueImpl; #undef HAVE_REMUTEXTRUEIMPL #endif // HAVE_REMUTEXIMPL -#endif +#endif // THREAD_SIMPLE_IMPL #endif diff --git a/panda/src/pipeline/pipeline_composite1.cxx b/panda/src/pipeline/pipeline_composite1.cxx index 4c16385f6f..381f5f8720 100644 --- a/panda/src/pipeline/pipeline_composite1.cxx +++ b/panda/src/pipeline/pipeline_composite1.cxx @@ -18,3 +18,8 @@ #include "cycleDataStageWriter.cxx" #include "cycleDataWriter.cxx" #include "cyclerHolder.cxx" +#include "externalThread.cxx" +#include "lightMutexDirect.cxx" +#include "lightMutexHolder.cxx" +#include "lightReMutexDirect.cxx" +#include "lightReMutexHolder.cxx" diff --git a/panda/src/pipeline/pipeline_composite2.cxx b/panda/src/pipeline/pipeline_composite2.cxx index 29d177e2bd..3b2b99bd07 100644 --- a/panda/src/pipeline/pipeline_composite2.cxx +++ b/panda/src/pipeline/pipeline_composite2.cxx @@ -1,4 +1,3 @@ -#include "externalThread.cxx" #include "mainThread.cxx" #include "mutexDebug.cxx" #include "mutexDirect.cxx" diff --git a/panda/src/pipeline/pmutex.I b/panda/src/pipeline/pmutex.I index 7eeac98592..406265ae2a 100644 --- a/panda/src/pipeline/pmutex.I +++ b/panda/src/pipeline/pmutex.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex() : MutexDebug(string(), false) +Mutex() : MutexDebug(string(), false, false) #else Mutex() #endif // DEBUG_THREADS @@ -34,7 +34,7 @@ Mutex() //////////////////////////////////////////////////////////////////// INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex(const char *name) : MutexDebug(string(name), false) +Mutex(const char *name) : MutexDebug(string(name), false, false) #else Mutex(const char *) #endif // DEBUG_THREADS @@ -48,7 +48,7 @@ Mutex(const char *) //////////////////////////////////////////////////////////////////// INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex(const string &name) : MutexDebug(name, false) +Mutex(const string &name) : MutexDebug(name, false, false) #else Mutex(const string &) #endif // DEBUG_THREADS @@ -71,7 +71,7 @@ INLINE Mutex:: //////////////////////////////////////////////////////////////////// INLINE Mutex:: #ifdef DEBUG_THREADS -Mutex(const Mutex ©) : MutexDebug(string(), false) +Mutex(const Mutex ©) : MutexDebug(string(), false, false) #else Mutex(const Mutex ©) #endif // DEBUG_THREADS diff --git a/panda/src/pipeline/reMutex.I b/panda/src/pipeline/reMutex.I index 12654037c1..b7b2809805 100644 --- a/panda/src/pipeline/reMutex.I +++ b/panda/src/pipeline/reMutex.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex() : MutexDebug(string(), true) +ReMutex() : MutexDebug(string(), true, false) #else ReMutex() #endif // DEBUG_THREADS @@ -34,7 +34,7 @@ ReMutex() //////////////////////////////////////////////////////////////////// INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex(const char *name) : MutexDebug(string(name), true) +ReMutex(const char *name) : MutexDebug(string(name), true, false) #else ReMutex(const char *) #endif // DEBUG_THREADS @@ -48,7 +48,7 @@ ReMutex(const char *) //////////////////////////////////////////////////////////////////// INLINE ReMutex:: #ifdef DEBUG_THREADS -ReMutex(const string &name) : MutexDebug(name, true) +ReMutex(const string &name) : MutexDebug(name, true, false) #else ReMutex(const string &) #endif // DEBUG_THREADS diff --git a/panda/src/pipeline/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx index 512c8572c4..486296a730 100755 --- a/panda/src/pipeline/reMutexDirect.cxx +++ b/panda/src/pipeline/reMutexDirect.cxx @@ -15,6 +15,8 @@ #include "reMutexDirect.h" #include "thread.h" +#ifndef DEBUG_THREADS + //////////////////////////////////////////////////////////////////// // Function: ReMutexDirect::output // Access: Published @@ -143,3 +145,5 @@ do_release() { _lock_impl.release(); } #endif // !HAVE_REMUTEXTRUEIMPL + +#endif // !DEBUG_THREADS diff --git a/panda/src/pipeline/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h index 4e9b99e2ff..03b0d984e9 100644 --- a/panda/src/pipeline/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -21,6 +21,8 @@ class Thread; +#ifndef DEBUG_THREADS + //////////////////////////////////////////////////////////////////// // Class : ReMutexDirect // Description : This class implements a standard reMutex by making @@ -67,6 +69,8 @@ private: MutexTrueImpl _lock_impl; ConditionVarImpl _cvar_impl; #endif // HAVE_REMUTEXTRUEIMPL + + friend class LightReMutexDirect; }; INLINE ostream & @@ -77,4 +81,6 @@ operator << (ostream &out, const ReMutexDirect &m) { #include "reMutexDirect.I" +#endif // !DEBUG_THREADS + #endif diff --git a/panda/src/pipeline/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I index 042aced46a..8a5212eae0 100644 --- a/panda/src/pipeline/reMutexHolder.I +++ b/panda/src/pipeline/reMutexHolder.I @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////// INLINE ReMutexHolder:: ReMutexHolder(const ReMutex &mutex) { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex = &mutex; _mutex->lock(); #endif @@ -35,7 +35,7 @@ ReMutexHolder(const ReMutex &mutex) { //////////////////////////////////////////////////////////////////// INLINE ReMutexHolder:: ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex = &mutex; _mutex->lock(current_thread); #endif @@ -54,7 +54,7 @@ ReMutexHolder(const ReMutex &mutex, Thread *current_thread) { //////////////////////////////////////////////////////////////////// INLINE ReMutexHolder:: ReMutexHolder(ReMutex *&mutex) { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) if (mutex == (ReMutex *)NULL) { mutex = new ReMutex; } @@ -70,7 +70,7 @@ ReMutexHolder(ReMutex *&mutex) { //////////////////////////////////////////////////////////////////// INLINE ReMutexHolder:: ~ReMutexHolder() { -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) _mutex->release(); #endif } diff --git a/panda/src/pipeline/reMutexHolder.h b/panda/src/pipeline/reMutexHolder.h index 3b868dc840..0941501126 100644 --- a/panda/src/pipeline/reMutexHolder.h +++ b/panda/src/pipeline/reMutexHolder.h @@ -35,7 +35,7 @@ private: INLINE void operator = (const ReMutexHolder ©); private: -#if defined(HAVE_THREADS) || !defined(NDEBUG) +#if defined(HAVE_THREADS) || defined(DEBUG_THREADS) const ReMutex *_mutex; #endif }; diff --git a/panda/src/pstatclient/pStatClient.I b/panda/src/pstatclient/pStatClient.I index bf5457451a..0fb59ef624 100644 --- a/panda/src/pstatclient/pStatClient.I +++ b/panda/src/pstatclient/pStatClient.I @@ -75,7 +75,7 @@ get_max_rate() const { //////////////////////////////////////////////////////////////////// INLINE int PStatClient:: get_num_collectors() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _num_collectors; } @@ -99,7 +99,7 @@ get_collector_def(int index) const { //////////////////////////////////////////////////////////////////// INLINE int PStatClient:: get_num_threads() const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return _num_threads; } @@ -211,7 +211,7 @@ resume_after_pause() { //////////////////////////////////////////////////////////////////// INLINE bool PStatClient:: client_connect(string hostname, int port) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); client_disconnect(); return get_impl()->client_connect(hostname, port); } @@ -261,7 +261,7 @@ has_impl() const { //////////////////////////////////////////////////////////////////// INLINE PStatClientImpl *PStatClient:: get_impl() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (_impl == (PStatClientImpl *)NULL) { _impl = new PStatClientImpl(this); } diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 8f0a49ccef..06e54f35b8 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -164,7 +164,7 @@ get_collector_fullname(int index) const { //////////////////////////////////////////////////////////////////// PStatThread PStatClient:: get_thread(int index) const { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertr(index >= 0 && index < _num_threads, PStatThread()); return PStatThread((PStatClient *)this, index); } @@ -370,7 +370,7 @@ thread_tick(const string &sync_name) { //////////////////////////////////////////////////////////////////// void PStatClient:: client_main_tick() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (has_impl()) { _impl->client_main_tick(); @@ -395,7 +395,7 @@ client_main_tick() { //////////////////////////////////////////////////////////////////// void PStatClient:: client_thread_tick(const string &sync_name) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (has_impl()) { MultiThingsByName::const_iterator ni = @@ -418,7 +418,7 @@ client_thread_tick(const string &sync_name) { //////////////////////////////////////////////////////////////////// void PStatClient:: client_disconnect() { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (has_impl()) { _impl->client_disconnect(); delete _impl; @@ -479,7 +479,7 @@ get_global_pstats() { //////////////////////////////////////////////////////////////////// PStatCollector PStatClient:: make_collector_with_relname(int parent_index, string relname) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); if (relname.empty()) { relname = "Unnamed"; @@ -519,7 +519,7 @@ make_collector_with_relname(int parent_index, string relname) { //////////////////////////////////////////////////////////////////// PStatCollector PStatClient:: make_collector_with_name(int parent_index, const string &name) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); nassertr(parent_index >= 0 && parent_index < _num_collectors, PStatCollector()); @@ -588,7 +588,7 @@ do_get_current_thread() const { //////////////////////////////////////////////////////////////////// PStatThread PStatClient:: make_thread(Thread *thread) { - ReMutexHolder holder(_lock); + LightReMutexHolder holder(_lock); return do_make_thread(thread); } @@ -688,7 +688,7 @@ is_started(int collector_index, int thread_index) const { InternalThread *thread = get_thread_ptr(thread_index); if (client_is_connected() && collector->is_active() && thread->_is_active) { - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { // Not started. return false; @@ -719,7 +719,7 @@ start(int collector_index, int thread_index) { InternalThread *thread = get_thread_ptr(thread_index); if (client_is_connected() && collector->is_active() && thread->_is_active) { - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { // This collector wasn't already started in this thread; record // a new data point. @@ -749,7 +749,7 @@ start(int collector_index, int thread_index, float as_of) { InternalThread *thread = get_thread_ptr(thread_index); if (client_is_connected() && collector->is_active() && thread->_is_active) { - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { // This collector wasn't already started in this thread; record // a new data point. @@ -779,7 +779,7 @@ stop(int collector_index, int thread_index) { InternalThread *thread = get_thread_ptr(thread_index); if (client_is_connected() && collector->is_active() && thread->_is_active) { - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { if (pstats_cat.is_debug()) { pstats_cat.debug() @@ -820,7 +820,7 @@ stop(int collector_index, int thread_index, float as_of) { InternalThread *thread = get_thread_ptr(thread_index); if (client_is_connected() && collector->is_active() && thread->_is_active) { - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); if (collector->_per_thread[thread_index]._nested_count == 0) { if (pstats_cat.is_debug()) { pstats_cat.debug() @@ -860,7 +860,7 @@ clear_level(int collector_index, int thread_index) { Collector *collector = get_collector_ptr(collector_index); InternalThread *thread = get_thread_ptr(thread_index); - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); collector->_per_thread[thread_index]._has_level = true; collector->_per_thread[thread_index]._level = 0.0; @@ -889,7 +889,7 @@ set_level(int collector_index, int thread_index, double level) { // connected or the collector is already active, since we might // connect the client later, and we will want to have an accurate // value at that time. - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); level *= collector->get_def(this, collector_index)->_factor; @@ -917,7 +917,7 @@ add_level(int collector_index, int thread_index, double increment) { Collector *collector = get_collector_ptr(collector_index); InternalThread *thread = get_thread_ptr(thread_index); - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); increment *= collector->get_def(this, collector_index)->_factor; @@ -942,7 +942,7 @@ get_level(int collector_index, int thread_index) const { Collector *collector = get_collector_ptr(collector_index); InternalThread *thread = get_thread_ptr(thread_index); - MutexHolder holder(thread->_thread_lock); + LightMutexHolder holder(thread->_thread_lock); double factor = collector->get_def(this, collector_index)->_factor; @@ -1139,7 +1139,7 @@ activate_hook(Thread *thread) { //////////////////////////////////////////////////////////////////// void PStatClient::Collector:: make_def(const PStatClient *client, int this_index) { - ReMutexHolder holder(client->_lock); + LightReMutexHolder holder(client->_lock); if (_def == (PStatCollectorDef *)NULL) { _def = new PStatCollectorDef(this_index, _name); if (_parent_index != this_index) { diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index bc0b6e5c14..650458f896 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -20,10 +20,10 @@ #include "pStatFrameData.h" #include "pStatClientImpl.h" #include "pStatCollectorDef.h" -#include "reMutex.h" -#include "pmutex.h" -#include "reMutexHolder.h" -#include "mutexHolder.h" +#include "lightReMutex.h" +#include "lightMutex.h" +#include "lightReMutexHolder.h" +#include "lightMutexHolder.h" #include "pmap.h" #include "thread.h" #include "weakPointerTo.h" @@ -142,7 +142,7 @@ private: private: // This mutex protects everything in this class. - ReMutex _lock; + LightReMutex _lock; typedef pmap ThingsByName; typedef pmap MultiThingsByName; @@ -214,7 +214,7 @@ private: // This mutex is used to protect writes to _frame_data for this // particular thread, as well as writes to the _per_thread data // for this particular thread in the Collector class, above. - Mutex _thread_lock; + LightMutex _thread_lock; }; typedef InternalThread *ThreadPointer; void *_threads; // ThreadPointer *_threads; diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index 2c8e5d5744..5c719a63fb 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -20,7 +20,7 @@ #include "bam.h" #include "bamWriter.h" #include "bamReader.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include @@ -48,7 +48,7 @@ BamWriter:: StateMap::iterator si; for (si = _state_map.begin(); si != _state_map.end(); ++si) { TypedWritable *object = (TypedWritable *)(*si).first; - MutexHolder holder(TypedWritable::_bam_writers_lock); + LightMutexHolder holder(TypedWritable::_bam_writers_lock); nassertv(object->_bam_writers != (TypedWritable::BamWriters *)NULL); TypedWritable::BamWriters::iterator wi = find(object->_bam_writers->begin(), object->_bam_writers->end(), this); @@ -513,7 +513,7 @@ enqueue_object(const TypedWritable *object) { _state_map.insert(StateMap::value_type(object, StoreState(_next_object_id))).second; nassertr(inserted, false); { - MutexHolder holder(TypedWritable::_bam_writers_lock); + LightMutexHolder holder(TypedWritable::_bam_writers_lock); if (object->_bam_writers == ((TypedWritable::BamWriters *)NULL)) { ((TypedWritable *)object)->_bam_writers = new TypedWritable::BamWriters; } diff --git a/panda/src/putil/copyOnWriteObject.h b/panda/src/putil/copyOnWriteObject.h index 48b87b25a5..ee9cd439d3 100644 --- a/panda/src/putil/copyOnWriteObject.h +++ b/panda/src/putil/copyOnWriteObject.h @@ -25,7 +25,11 @@ // Should we implement full thread protection for CopyOnWritePointer? // If we can be assured that no other thread will interrupt while a // write pointer is held, we don't need thread protection. -#if defined(HAVE_THREADS) && !(defined(SIMPLE_THREADS) && defined(SIMPLE_THREADS_NO_MUTEX)) + +// Nowadays, this is the same thing as asking if HAVE_THREADS is +// defined. Maybe we'll just replace COW_THREADED with HAVE_THREADS +// in the future. +#ifdef HAVE_THREADS #define COW_THREADED 1 #else #undef COW_THREADED diff --git a/panda/src/putil/typedWritable.cxx b/panda/src/putil/typedWritable.cxx index 35b9084abc..bc18be8075 100644 --- a/panda/src/putil/typedWritable.cxx +++ b/panda/src/putil/typedWritable.cxx @@ -14,9 +14,9 @@ #include "typedWritable.h" #include "bamWriter.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" -Mutex TypedWritable::_bam_writers_lock; +LightMutex TypedWritable::_bam_writers_lock; TypeHandle TypedWritable::_type_handle; TypedWritable* const TypedWritable::Null = (TypedWritable*)0L; @@ -32,7 +32,7 @@ TypedWritable:: if (_bam_writers != (BamWriters *)NULL) { BamWriters temp; { - MutexHolder holder(_bam_writers_lock); + LightMutexHolder holder(_bam_writers_lock); _bam_writers->swap(temp); delete _bam_writers; _bam_writers = NULL; diff --git a/panda/src/putil/typedWritable.h b/panda/src/putil/typedWritable.h index b557e71dd3..fc3a0357fd 100644 --- a/panda/src/putil/typedWritable.h +++ b/panda/src/putil/typedWritable.h @@ -18,7 +18,7 @@ #include "typedObject.h" #include "vector_typedWritable.h" #include "pvector.h" -#include "pmutex.h" +#include "lightMutex.h" class BamReader; class BamWriter; @@ -59,7 +59,7 @@ private: // those tables when it destructs. typedef pvector BamWriters; BamWriters *_bam_writers; - static Mutex _bam_writers_lock; + static LightMutex _bam_writers_lock; PUBLISHED: static TypeHandle get_class_type() { diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index a79e0739b9..301c31840d 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -20,7 +20,7 @@ #include "virtualFileSystem.h" #include "nodePath.h" #include "loader.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" FontPool *FontPool::_global_ptr = (FontPool *)NULL; @@ -42,7 +42,7 @@ write(ostream &out) { //////////////////////////////////////////////////////////////////// bool FontPool:: ns_has_font(const string &str) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); string index_str; Filename filename; @@ -72,7 +72,7 @@ ns_load_font(const string &str) { lookup_filename(str, index_str, filename, face_index); { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Fonts::const_iterator ti; ti = _fonts.find(index_str); @@ -126,7 +126,7 @@ ns_load_font(const string &str) { { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // Look again. It may have been loaded by another thread. Fonts::const_iterator ti; @@ -149,7 +149,7 @@ ns_load_font(const string &str) { //////////////////////////////////////////////////////////////////// void FontPool:: ns_add_font(const string &str, TextFont *font) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); string index_str; Filename filename; @@ -167,7 +167,7 @@ ns_add_font(const string &str, TextFont *font) { //////////////////////////////////////////////////////////////////// void FontPool:: ns_release_font(const string &filename) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Fonts::iterator ti; ti = _fonts.find(filename); @@ -183,7 +183,7 @@ ns_release_font(const string &filename) { //////////////////////////////////////////////////////////////////// void FontPool:: ns_release_all_fonts() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _fonts.clear(); } @@ -195,7 +195,7 @@ ns_release_all_fonts() { //////////////////////////////////////////////////////////////////// int FontPool:: ns_garbage_collect() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); int num_released = 0; Fonts new_set; @@ -225,7 +225,7 @@ ns_garbage_collect() { //////////////////////////////////////////////////////////////////// void FontPool:: ns_list_contents(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); out << _fonts.size() << " fonts:\n"; Fonts::const_iterator ti; diff --git a/panda/src/text/fontPool.h b/panda/src/text/fontPool.h index e71d31af31..430e9166ad 100644 --- a/panda/src/text/fontPool.h +++ b/panda/src/text/fontPool.h @@ -20,7 +20,7 @@ #include "texture.h" #include "textFont.h" #include "filename.h" -#include "pmutex.h" +#include "lightMutex.h" #include "pmap.h" //////////////////////////////////////////////////////////////////// @@ -64,7 +64,7 @@ private: static FontPool *get_ptr(); static FontPool *_global_ptr; - Mutex _lock; + LightMutex _lock; typedef pmap Fonts; Fonts _fonts; }; diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 301a6148bb..7370d78769 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -30,7 +30,7 @@ #include "geomPoints.h" #include "dcast.h" #include "indent.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" #include "nearly_zero.h" #include @@ -111,7 +111,7 @@ MouseWatcher:: //////////////////////////////////////////////////////////////////// bool MouseWatcher:: remove_region(MouseWatcherRegion *region) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); remove_region_from(_current_regions, region); if (region == _preferred_region) { @@ -138,7 +138,7 @@ remove_region(MouseWatcherRegion *region) { //////////////////////////////////////////////////////////////////// MouseWatcherRegion *MouseWatcher:: get_over_region(const LPoint2f &pos) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Regions regions; get_over_regions(regions, pos); @@ -163,7 +163,7 @@ get_over_region(const LPoint2f &pos) const { //////////////////////////////////////////////////////////////////// bool MouseWatcher:: add_group(MouseWatcherGroup *group) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // See if the group is in the set/vector already PT(MouseWatcherGroup) pt = group; @@ -196,8 +196,8 @@ add_group(MouseWatcherGroup *group) { //////////////////////////////////////////////////////////////////// bool MouseWatcher:: remove_group(MouseWatcherGroup *group) { - MutexHolder holder(_lock); - MutexHolder holder2(group->_lock); + LightMutexHolder holder(_lock); + LightMutexHolder holder2(group->_lock); group->do_sort_regions(); @@ -255,10 +255,10 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { return true; } - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); - MutexHolder holder2(old_group->_lock); - MutexHolder holder3(new_group->_lock); + LightMutexHolder holder2(old_group->_lock); + LightMutexHolder holder3(new_group->_lock); old_group->do_sort_regions(); new_group->do_sort_regions(); @@ -351,7 +351,7 @@ replace_group(MouseWatcherGroup *old_group, MouseWatcherGroup *new_group) { //////////////////////////////////////////////////////////////////// int MouseWatcher:: get_num_groups() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _groups.size(); } @@ -363,7 +363,7 @@ get_num_groups() const { //////////////////////////////////////////////////////////////////// MouseWatcherGroup *MouseWatcher:: get_group(int n) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); nassertr(n >= 0 && n < (int)_groups.size(), NULL); return _groups[n]; } @@ -534,7 +534,7 @@ note_activity() { //////////////////////////////////////////////////////////////////// void MouseWatcher:: output(ostream &out) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); DataNode::output(out); int count = _regions.size(); @@ -558,7 +558,7 @@ write(ostream &out, int indent_level) const { << "MouseWatcher " << get_name() << ":\n"; MouseWatcherGroup::write(out, indent_level + 2); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (!_groups.empty()) { Groups::const_iterator gi; for (gi = _groups.begin(); gi != _groups.end(); ++gi) { @@ -1380,7 +1380,7 @@ void MouseWatcher:: do_transmit_data(DataGraphTraverser *trav, const DataNodeTransmit &input, DataNodeTransmit &output) { Thread *current_thread = trav->get_current_thread(); - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); bool activity = false; diff --git a/panda/src/tform/mouseWatcherGroup.cxx b/panda/src/tform/mouseWatcherGroup.cxx index baae78b872..17e2668616 100644 --- a/panda/src/tform/mouseWatcherGroup.cxx +++ b/panda/src/tform/mouseWatcherGroup.cxx @@ -15,7 +15,7 @@ #include "mouseWatcherGroup.h" #include "lineSegs.h" #include "indent.h" -#include "mutexHolder.h" +#include "lightMutexHolder.h" TypeHandle MouseWatcherGroup::_type_handle; @@ -55,7 +55,7 @@ void MouseWatcherGroup:: add_region(MouseWatcherRegion *region) { PT(MouseWatcherRegion) pt = region; - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); // We will only bother to check for duplicates in the region list if // we are building a development Panda. The overhead for doing this @@ -87,7 +87,7 @@ add_region(MouseWatcherRegion *region) { //////////////////////////////////////////////////////////////////// bool MouseWatcherGroup:: has_region(MouseWatcherRegion *region) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); PT(MouseWatcherRegion) ptr = region; @@ -111,7 +111,7 @@ has_region(MouseWatcherRegion *region) const { //////////////////////////////////////////////////////////////////// bool MouseWatcherGroup:: remove_region(MouseWatcherRegion *region) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return do_remove_region(region); } @@ -124,7 +124,7 @@ remove_region(MouseWatcherRegion *region) { //////////////////////////////////////////////////////////////////// MouseWatcherRegion *MouseWatcherGroup:: find_region(const string &name) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Regions::const_iterator ri; for (ri = _regions.begin(); ri != _regions.end(); ++ri) { @@ -144,7 +144,7 @@ find_region(const string &name) const { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: clear_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _regions.clear(); _sorted = true; @@ -165,7 +165,7 @@ clear_regions() { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: sort_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_sort_regions(); } @@ -177,7 +177,7 @@ sort_regions() { //////////////////////////////////////////////////////////////////// bool MouseWatcherGroup:: is_sorted() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _sorted; } @@ -189,7 +189,7 @@ is_sorted() const { //////////////////////////////////////////////////////////////////// int MouseWatcherGroup:: get_num_regions() const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); return _regions.size(); } @@ -204,7 +204,7 @@ get_num_regions() const { //////////////////////////////////////////////////////////////////// MouseWatcherRegion *MouseWatcherGroup:: get_region(int n) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); if (n >= 0 && n < (int)_regions.size()) { return _regions[n]; } @@ -228,7 +228,7 @@ output(ostream &out) const { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: write(ostream &out, int indent_level) const { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); Regions::const_iterator ri; for (ri = _regions.begin(); ri != _regions.end(); ++ri) { @@ -248,7 +248,7 @@ write(ostream &out, int indent_level) const { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_show_regions(render2d, bin_name, draw_order); } #endif // NDEBUG @@ -263,7 +263,7 @@ show_regions(const NodePath &render2d, const string &bin_name, int draw_order) { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: set_color(const Colorf &color) { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); _color = color; do_update_regions(); @@ -279,7 +279,7 @@ set_color(const Colorf &color) { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: hide_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_hide_regions(); } #endif // NDEBUG @@ -293,7 +293,7 @@ hide_regions() { //////////////////////////////////////////////////////////////////// void MouseWatcherGroup:: update_regions() { - MutexHolder holder(_lock); + LightMutexHolder holder(_lock); do_update_regions(); } #endif // NDEBUG diff --git a/panda/src/tform/mouseWatcherGroup.h b/panda/src/tform/mouseWatcherGroup.h index dbeb7297a6..b411f6a80d 100644 --- a/panda/src/tform/mouseWatcherGroup.h +++ b/panda/src/tform/mouseWatcherGroup.h @@ -22,7 +22,7 @@ #include "referenceCount.h" #include "pvector.h" #include "nodePath.h" -#include "pmutex.h" +#include "lightMutex.h" //////////////////////////////////////////////////////////////////// // Class : MouseWatcherGroup @@ -78,7 +78,7 @@ protected: // This mutex protects the above list of regions, as well as the // below list of vizzes. It is also referenced directly by // MouseWatcher, a derived class. - Mutex _lock; + LightMutex _lock; private: #ifndef NDEBUG diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index a4b8553eae..5418457030 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -22,8 +22,8 @@ #include "graphicsWindow.h" #include "graphicsPipe.h" #include "tinyGraphicsStateGuardian.h" -#include "pmutex.h" -#include "reMutex.h" +#include "lightMutex.h" +#include "lightReMutex.h" class FrameBufferProperties; @@ -114,7 +114,7 @@ private: public: // This Mutex protects any X library calls, which all have to be // single-threaded. - static ReMutex _x_mutex; + static LightReMutex _x_mutex; public: static TypeHandle get_class_type() { diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index 5da966e86f..aeef9e645b 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -28,7 +28,7 @@ #include "pStatTimer.h" #include "textEncoder.h" #include "throw_event.h" -#include "reMutexHolder.h" +#include "lightReMutexHolder.h" #include #include @@ -255,7 +255,7 @@ supports_pixel_zoom() const { //////////////////////////////////////////////////////////////////// void TinyXGraphicsWindow:: process_events() { - ReMutexHolder holder(TinyXGraphicsPipe::_x_mutex); + LightReMutexHolder holder(TinyXGraphicsPipe::_x_mutex); GraphicsWindow::process_events();