[complement-svn] SF.net SVN: complement: [1645] trunk/complement/explore/test/virtual_time
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-07-27 04:05:11
|
Revision: 1645 http://complement.svn.sourceforge.net/complement/?rev=1645&view=rev Author: complement Date: 2007-07-26 21:04:28 -0700 (Thu, 26 Jul 2007) Log Message: ----------- add lock to VTSend in VTDispatcher Modified Paths: -------------- trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-07-26 10:40:08 UTC (rev 1644) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-07-27 04:04:28 UTC (rev 1645) @@ -467,6 +467,10 @@ void VTDispatcher::VTSend( const stem::Event& e, group_type grp ) { + // This method not called from Dispatch, but work on the same level and in the same + // scope, so this lock (from stem::EventHandler) required here: + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + const pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); @@ -535,10 +539,11 @@ void VTHandler::Init::__at_fork_child() { - if ( *_rcount != 0 ) { - VTHandler::_vtdsp->~VTDispatcher(); - VTHandler::_vtdsp = new( VTHandler::_vtdsp ) VTDispatcher(); - } + // VTDispatcher not start threads (at least yet), so following not required: + // if ( *_rcount != 0 ) { + // VTHandler::_vtdsp->~VTDispatcher(); + // VTHandler::_vtdsp = new( VTHandler::_vtdsp ) VTDispatcher(); + // } } void VTHandler::Init::__at_fork_parent() @@ -548,6 +553,8 @@ void VTHandler::Init::_guard( int direction ) { static xmt::recursive_mutex _init_lock; + + xmt::recursive_scoped_lock lk(_init_lock); static int _count = 0; if ( direction ) { @@ -556,7 +563,7 @@ _rcount = &_count; pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); #endif - VTHandler::_vtdsp = new VTDispatcher(); + VTHandler::_vtdsp = new VTDispatcher( 2, "vtd" ); } } else { --_count; @@ -575,12 +582,16 @@ void VTHandler::VTSend( const stem::Event& ev ) { + ev.src( self_id() ); + // _vtdsp->VTSend( ev, grp ); } VTHandler::VTHandler() : EventHandler() { new( Init_buf ) Init(); + + // _vtdsp->Subscribe( self_id(), ... , ... ); } VTHandler::VTHandler( const char *info ) : Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-07-26 10:40:08 UTC (rev 1644) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-07-27 04:04:28 UTC (rev 1645) @@ -219,24 +219,27 @@ VTDispatcher() { } + VTDispatcher( const char *info ) : + stem::EventHandler( info ) + { } + VTDispatcher( stem::addr_type id ) : stem::EventHandler( id ) { } + VTDispatcher( stem::addr_type id, const char *info ) : + stem::EventHandler( id, info ) + { } + void VTDispatch( const stem::Event_base<VTmess>& ); void VTSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); private: - typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; - // oid_type map_gid( group_type ); - // gid_type -> (oid_type, oid_type, ...) - // in our case we can use gid = hi bits | oid - void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); vt_map_type vtmap; @@ -248,7 +251,7 @@ class VTHandler : public stem::EventHandler { - public: + private: class Init { public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |