complement-svn Mailing List for Complement (Page 12)
Status: Pre-Alpha
Brought to you by:
complement
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(61) |
Nov
(76) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(33) |
Feb
(41) |
Mar
(16) |
Apr
|
May
(22) |
Jun
(14) |
Jul
(64) |
Aug
(60) |
Sep
(35) |
Oct
(34) |
Nov
(10) |
Dec
(5) |
2008 |
Jan
(4) |
Feb
(24) |
Mar
(10) |
Apr
(30) |
May
(15) |
Jun
(50) |
Jul
(20) |
Aug
(7) |
Sep
(8) |
Oct
(10) |
Nov
|
Dec
|
From: <com...@us...> - 2007-08-23 13:57:51
|
Revision: 1703 http://complement.svn.sourceforge.net/complement/?rev=1703&view=rev Author: complement Date: 2007-08-23 06:57:49 -0700 (Thu, 23 Aug 2007) Log Message: ----------- correct interpretation; real transmit of virtual synchrony message Modified Paths: -------------- trunk/complement/explore/lib/janus/ut/vt_remote.cc Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-23 09:02:15 UTC (rev 1702) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-23 13:57:49 UTC (rev 1703) @@ -103,7 +103,7 @@ void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { - cerr << "Hello " << xmt::getpid() << endl; + // cerr << "Hello " << xmt::getpid() << endl; ++count; // VTNewMember_data( ev, "" ); @@ -116,7 +116,7 @@ void YaRemote::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) { - // cerr << "Hello" << endl; + cerr << "VSOutMember" << endl; ++ocount; } @@ -141,8 +141,6 @@ int EXAM_IMPL(vtime_operations::remote) { - cerr << "============\n"; - const char fname[] = "/tmp/yanus_test.shm"; xmt::shm_alloc<0> seg; xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; @@ -163,29 +161,35 @@ // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); // obj1.manager()->settrs( &std::cerr ); - obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); - obj1.vtdispatcher()->settrs( &std::cerr ); + // obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + // obj1.vtdispatcher()->settrs( &std::cerr ); EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); obj1.vtdispatcher()->connect( "localhost", 6980 ); - cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; -#if 1 while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { xmt::Thread::yield(); xmt::delay( xmt::timespec( 0, 1000000 ) ); } -#else + + /* ****************************************************************************** + This variant is wrong, because of group_size don't guarantee that information + in the object is relevant (i.e. VSsync happens); for example, in case below + group_size already 2, but no janus string stored yet. + while ( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) < 2 ) { xmt::Thread::yield(); xmt::delay( xmt::timespec( 0, 1000000 ) ); } -#endif + * ****************************************************************************** */ + // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2 ); - cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; obj1.JoinGroup( janus::vs_base::first_user_group ); @@ -194,6 +198,7 @@ EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; + obj1.wait(); } exit(0); @@ -214,16 +219,21 @@ // xmt::delay( xmt::timespec( 0, 1000000 ) ); // } - // stem::Event ev( VS_DUMMY_MESS ); - // ev.dest( janus::vs_base::first_user_group ); // group - // ev.value() = "hello"; + obj1.wait_greeting(); - // obj1.JaSend( ev ); + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( janus::vs_base::first_user_group ); + ev.value() = "hello"; - // obj1.wait_greeting(); + obj1.JaSend( ev ); int stat; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + // cerr << obj1.vtdispatcher()->vs_known_processes() << endl; + // cerr << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; } (&b)->~__barrier<true>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 09:02:29
|
Revision: 1702 http://complement.svn.sourceforge.net/complement/?rev=1702&view=rev Author: complement Date: 2007-08-23 02:02:15 -0700 (Thu, 23 Aug 2007) Log Message: ----------- Janus code moved from vtime.h, vtime.cc to janus.h, janus.cc; libjanus: version 0.3.0; * vshostmgr.h, vshostmgr.cc: object for management virtual syncrony processes; * vshostmgr.h, vshostmgr.cc, janus.h, janus.cc, vtime.h, vtime.cc: procedure of entry into group with remote virtual synchrony objects; * ut/vt_remote.cc: test for interprocess virtual synchrony, entry into group. Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ChangeLog trunk/complement/explore/lib/janus/Makefile.inc trunk/complement/explore/lib/janus/ut/Makefile.inc trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_object.cc trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vtime.cc Added Paths: ----------- trunk/complement/explore/include/janus/janus.h trunk/complement/explore/include/janus/vshostmgr.h trunk/complement/explore/lib/janus/janus.cc trunk/complement/explore/lib/janus/vshostmgr.cc Added: trunk/complement/explore/include/janus/janus.h =================================================================== --- trunk/complement/explore/include/janus/janus.h (rev 0) +++ trunk/complement/explore/include/janus/janus.h 2007-08-23 09:02:15 UTC (rev 1702) @@ -0,0 +1,160 @@ +// -*- C++ -*- Time-stamp: <07/08/23 12:36:32 ptr> + +#ifndef __janus_h +#define __janus_h + +#include <ostream> +#include <iterator> + +#include <mt/xmt.h> +#include <stem/Event.h> +#include <stem/EventHandler.h> + +#include <janus/vtime.h> + +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + +namespace janus { + +class Janus : + public stem::EventHandler, + public vs_base +{ + private: +#ifdef __USE_STLPORT_HASH + typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef std::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef __gnu_cxx::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef std::tr1::unordered_multimap<group_type, oid_type> gid_map_type; +#endif + + public: + typedef std::iterator_traits<gid_map_type::iterator>::difference_type difference_type; + + enum traceflags { + notrace = 0, + tracenet = 1, + tracedispatch = 2, + tracefault = 4, + tracedelayed = 8, + tracegroup = 0x10 + }; + + Janus() : + _trflags( notrace ), + _trs( 0 ), + _hostmgr( 0 ) + { } + + Janus( const char *info ) : + stem::EventHandler( info ), + _trflags( notrace ), + _trs( 0 ), + _hostmgr( 0 ) + { } + + Janus( stem::addr_type id ) : + stem::EventHandler( id ), + _trflags( notrace ), + _trs( 0 ), + _hostmgr( 0 ) + { } + + Janus( stem::addr_type id, const char *info ) : + stem::EventHandler( id, info ), + _trflags( notrace ), + _trs( 0 ), + _hostmgr( 0 ) + { } + + ~Janus(); + + void JaDispatch( const stem::Event_base<VSmess>& ); + + void VSNewMember( const stem::Event_base<VSsync_rq>& e ); + void VSNewRemoteMemberDirect( const stem::Event_base<VSsync_rq>& e ); + void VSNewRemoteMemberRevert( const stem::Event_base<VSsync_rq>& e ); + + void JaSend( const stem::Event& e, group_type ); + void Subscribe( stem::addr_type, oid_type, group_type ); + void Unsubscribe( oid_type, group_type ); + void Unsubscribe( oid_type ); + void get_gvtime( group_type, stem::addr_type, gvtime_type& ); + void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); + + void settrf( unsigned f ); + void unsettrf( unsigned f ); + void resettrf( unsigned f ); + void cleantrf(); + unsigned trflags() const; + void settrs( std::ostream * ); + + void connect( const char *, int ); + void serve( int ); + size_t vs_known_processes() const; + + difference_type group_size( group_type ) const; + + private: + void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); + void check_and_send_delayed( detail::vtime_obj_rec& ); + + vt_map_type vtmap; + gid_map_type grmap; + + xmt::mutex _lock_tr; + unsigned _trflags; + std::ostream *_trs; + + protected: + + class VSHostMgr *_hostmgr; + + friend class VTHandler::Init; + friend class VTHandler; + friend class VSHostMgr; + + private: + + DECLARE_RESPONSE_TABLE( Janus, stem::EventHandler ); +}; + +} // namespace janus + +#ifdef __USE_STLPORT_HASH +# undef __USE_STLPORT_HASH +#endif +#ifdef __USE_STD_HASH +# undef __USE_STD_HASH +#endif +#ifdef __USE_STLPORT_TR1 +# undef __USE_STLPORT_TR1 +#endif +#ifdef __USE_STD_TR1 +# undef __USE_STD_TR1 +#endif + +#endif // __janus_h Added: trunk/complement/explore/include/janus/vshostmgr.h =================================================================== --- trunk/complement/explore/include/janus/vshostmgr.h (rev 0) +++ trunk/complement/explore/include/janus/vshostmgr.h 2007-08-23 09:02:15 UTC (rev 1702) @@ -0,0 +1,82 @@ +// -*- C++ -*- Time-stamp: <07/08/23 12:36:32 ptr> + +#ifndef __vshostmgr_h +#define __vshostmgr_h + +#include <janus/vtime.h> + +#include <stem/NetTransport.h> +#include <stem/Event.h> +#include <sockios/sockmgr.h> + +#include <list> + +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + +namespace janus { + +class VSHostMgr : + public janus::VTHandler +{ + private: + // typedef std::list<stem::gaddr_type> vshost_container_t; +#ifdef __USE_STLPORT_TR1 + typedef std::tr1::unordered_set<stem::gaddr_type> vshost_container_t; +#endif + + public: + typedef vshost_container_t::size_type size_type; + + VSHostMgr(); + VSHostMgr( stem::addr_type id, const char *info = 0 ); + VSHostMgr( const char *info ); + ~VSHostMgr(); + + // void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + void VSsync_time( const stem::Event_base<VSsync>& ev ); + + void connect( const char *, int ); + void serve( int ); + + size_type vs_known_processes() const + { + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + size_type tmp = vshost.size(); + return tmp; + } + + void Subscribe( stem::addr_type, oid_type, group_type ); + + private: + typedef std::list<stem::NetTransportMgr *> nmgr_container_t; + typedef std::list<std::sockmgr_stream_MP<stem::NetTransport> *> srv_container_t; + + vshost_container_t vshost; + nmgr_container_t _clients; + srv_container_t _servers; + + // DECLARE_RESPONSE_TABLE( VSHostMgr, janus::VTHandler ); +}; + +} // namespace janus + +#endif // __vshostmgr_h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 21:54:39 ptr> +// -*- C++ -*- Time-stamp: <07/08/23 10:16:54 ptr> #ifndef __vtime_h #define __vtime_h @@ -332,87 +332,19 @@ } // namespace detail -class Janus : - public stem::EventHandler +struct vs_base { - public: - enum traceflags { - notrace = 0, - tracenet = 1, - tracedispatch = 2, - tracefault = 4, - tracedelayed = 8, - tracegroup = 0x10 - }; - - Janus() : - _trflags( notrace ), - _trs( 0 ) - { } - - Janus( const char *info ) : - stem::EventHandler( info ), - _trflags( notrace ), - _trs( 0 ) - { } - - Janus( stem::addr_type id ) : - stem::EventHandler( id ), - _trflags( notrace ), - _trs( 0 ) - { } - - Janus( stem::addr_type id, const char *info ) : - stem::EventHandler( id, info ), - _trflags( notrace ), - _trs( 0 ) - { } - - void JaDispatch( const stem::Event_base<VSmess>& ); - - void JaSend( const stem::Event& e, group_type ); - void Subscribe( stem::addr_type, oid_type, group_type ); - void Unsubscribe( oid_type, group_type ); - void Unsubscribe( oid_type ); - void get_gvtime( group_type, stem::addr_type, gvtime_type& ); - void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); - - void settrf( unsigned f ); - void unsettrf( unsigned f ); - void resettrf( unsigned f ); - void cleantrf(); - unsigned trflags() const; - void settrs( std::ostream * ); - - private: -#ifdef __USE_STLPORT_HASH - typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; - typedef std::hash_multimap<group_type, oid_type> gid_map_type; -#endif -#ifdef __USE_STD_HASH - typedef __gnu_cxx::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; - typedef __gnu_cxx::hash_multimap<group_type, oid_type> gid_map_type; -#endif -#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) - typedef std::tr1::unordered_map<oid_type, detail::vtime_obj_rec> vt_map_type; - typedef std::tr1::unordered_multimap<group_type, oid_type> gid_map_type; -#endif - - void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); - void check_and_send_delayed( detail::vtime_obj_rec& ); - - vt_map_type vtmap; - gid_map_type grmap; - - xmt::mutex _lock_tr; - unsigned _trflags; - std::ostream *_trs; - - DECLARE_RESPONSE_TABLE( Janus, stem::EventHandler ); + enum { + vshosts_group = 0, + first_user_group = 10 + }; }; +class Janus; + class VTHandler : - public stem::EventHandler + public stem::EventHandler, + public vs_base { private: class Init @@ -434,8 +366,8 @@ virtual ~VTHandler(); void JaSend( const stem::Event& e ); - void JoinGroup( group_type grp ) - { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } + void JoinGroup( group_type grp ); + virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); virtual void VSsync_time( const stem::Event_base<VSsync>& ); @@ -451,19 +383,21 @@ protected: void VSNewMember_data( const stem::Event_base<VSsync_rq>&, const std::string& data ); - void get_gvtime( group_type g, gvtime_type& gvt ) - { _vtdsp->get_gvtime( g, self_id(), gvt ); } + void get_gvtime( group_type g, gvtime_type& gvt ); private: - static class Janus *_vtdsp; + static Janus *_vtdsp; + friend class Janus; DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); }; -#define VS_MESS 0x300 -#define VS_NEW_MEMBER 0x301 -#define VS_OUT_MEMBER 0x302 -#define VS_SYNC_TIME 0x303 +#define VS_MESS 0x300 +#define VS_NEW_MEMBER 0x301 +#define VS_OUT_MEMBER 0x302 +#define VS_SYNC_TIME 0x303 +#define VS_NEW_REMOTE_MEMBER 0x304 +#define VS_NEW_MEMBER_RV 0x305 #ifdef __USE_STLPORT_HASH # undef __USE_STLPORT_HASH Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,3 +1,26 @@ +2007-08-23 Petr Ovtchenkov <pt...@is...> + + * janus.h, janus.cc: Janus code moved from vtime.h, vtime.cc; + + * vtime.h, vtime.cc: Janus code moved to janus.h, janus.cc; + + * ut/vt_object.cc, ut/vt_handler.cc, ut/VTmess_core.cc: idem; + + * ut/vt_dispatch.cc: idem; + + * Makefile.inc: idem; + + * libjanus: version 0.3.0; + + * vshostmgr.h, vshostmgr.cc: object for management virtual syncrony + processes; + + * vshostmgr.h, vshostmgr.cc, janus.h, janus.cc, vtime.h, vtime.cc: + procedure of entry into group with remote virtual synchrony objects; + + * ut/vt_remote.cc: test for interprocess virtual synchrony, + entry into group. + 2007-08-17 Petr Ovtchenkov <ye...@ya...> * vtime.h: use available variant of hash_map/hash_set or Modified: trunk/complement/explore/lib/janus/Makefile.inc =================================================================== --- trunk/complement/explore/lib/janus/Makefile.inc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/Makefile.inc 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,7 +1,7 @@ -# -*- makefile -*- Time-stamp: <06/10/10 15:22:33 ptr> +# -*- makefile -*- Time-stamp: <07/08/21 11:08:32 ptr> LIBNAME = janus MAJOR = 0 -MINOR = 2 +MINOR = 3 PATCH = 0 -SRC_CC = vtime.cc +SRC_CC = vtime.cc janus.cc vshostmgr.cc Added: trunk/complement/explore/lib/janus/janus.cc =================================================================== --- trunk/complement/explore/lib/janus/janus.cc (rev 0) +++ trunk/complement/explore/lib/janus/janus.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -0,0 +1,658 @@ +// -*- C++ -*- Time-stamp: <07/08/23 12:36:32 ptr> + +#include <janus/janus.h> +#include <janus/vshostmgr.h> +#include <stem/EvManager.h> + +// #include <iostream> + +namespace janus { + +using namespace std; +using namespace xmt; +using namespace stem; + +Janus::~Janus() +{ + delete _hostmgr; +} + +void Janus::settrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags |= f; +} + +void Janus::unsettrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags &= (0xffffffff & ~f); +} + +void Janus::resettrf( unsigned f ) +{ + scoped_lock _x1( _lock_tr ); + _trflags = f; +} + +void Janus::cleantrf() +{ + scoped_lock _x1( _lock_tr ); + _trflags = 0; +} + +unsigned Janus::trflags() const +{ + scoped_lock _x1( _lock_tr ); + + return _trflags; +} + +void Janus::settrs( std::ostream *s ) +{ + scoped_lock _x1( _lock_tr ); + _trs = s; +} + +void Janus::JaDispatch( const stem::Event_base<VSmess>& m ) +{ + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = + grmap.equal_range( m.value().grp ); + + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i == vtmap.end() || i->second.stem_addr() == m.src() ) { // not for nobody and not for self + continue; + } + try { + // check local or remote? i->second.addr + // if remote, forward it to foreign VTDispatcher? + // looks, like local source shouldn't be here? + check_and_send( i->second, m ); + } + catch ( const out_of_range& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + } + catch ( const domain_error& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + } + } +} + +void Janus::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VSmess>& m ) +{ + if ( vt.deliver( m.value() ) ) { + stem::Event ev( m.value().code ); + ev.dest(vt.stem_addr()); + ev.src(m.src()); + ev.value() = m.value().mess; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Deliver " << m.value() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + Forward( ev ); + check_and_send_delayed( vt ); + } else { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedelayed) ) { + *_trs << "Delayed " << m.value() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VSmess>(m) ) ); // 0 should be timestamp + } +} + +void Janus::check_and_send_delayed( detail::vtime_obj_rec& vt ) +{ + typedef detail::vtime_obj_rec::dpool_t dpool_t; + bool more; + do { + more = false; + for ( dpool_t::iterator j = vt.dpool.begin(); j != vt.dpool.end(); ) { + if ( vt.deliver_delayed( j->second->value() ) ) { + stem::Event evd( j->second->value().code ); + evd.dest(vt.stem_addr()); + evd.src(j->second->src()); + evd.value() = j->second->value().mess; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Deliver delayed " << j->second->value() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + Forward( evd ); + delete j->second; + vt.dpool.erase( j++ ); + more = true; + } else { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { + *_trs << "Remain delayed " << j->second->value() + << "\nReason: "; + vt.trace_deliver( j->second->value(), *_trs ) << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + ++j; + } + } + } while ( more ); +} + +void Janus::JaSend( 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 ); + + for ( gid_map_type::const_iterator o = range.first; o != range.second; ++o ) { + vt_map_type::iterator i = vtmap.find( o->second ); + if ( i != vtmap.end() && i->second.stem_addr() == e.src() ) { // for self + detail::vtime_obj_rec& vt = i->second; + const oid_type& from = o->second; + stem::Event_base<VSmess> m( VS_MESS ); + m.value().src = from; // oid + m.value().code = e.code(); + m.value().mess = e.value(); + m.value().grp = grp; + // m.dest( ??? ); // local VT dispatcher? + m.src( e.src() ); + + // This is like VTDispatch, but VT stamp in every message different, + // in accordance with individual knowlage about object's VT. + + vt.next( from, grp ); // my counter + + for ( gid_map_type::const_iterator g = range.first; g != range.second; ++g ) { + vt_map_type::iterator k = vtmap.find( g->second ); + if ( k == vtmap.end() || k->second.stem_addr() == m.src() ) { // not for nobody and not for self + continue; + } + try { + vt.delta( m.value().gvt, from, g->second, grp ); + + // check local or remote? i->second.addr + // if remote, forward it to foreign VTDispatcher? + try { + /* const transport tr = */ manager()->transport( k->second.stem_addr() ); + gaddr_type ga = manager()->reflect( k->second.stem_addr() ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + addr_type a = manager()->reflect( ga ); + if ( a == badaddr ) { + a = manager()->SubscribeRemote( ga, "janus" ); + } + m.dest( a ); + Forward( m ); + vt.base_advance(g->second); // store last send VT to obj + } + } + catch ( const range_error& ) { + check_and_send( k->second, m ); + vt.base_advance(g->second); // store last send VT to obj + } + } + catch ( const out_of_range& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + } + catch ( const domain_error& err ) { + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << err.what() << " " + << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + } + } + + return; + } + } + + throw domain_error( "VT object not member of group" ); // Error: not group member +} + +void Janus::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = + grmap.equal_range( grp ); + + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() ) { + stem::Event_base<VSsync_rq> ev( VS_NEW_MEMBER ); + ev.dest( i->second.stem_addr() ); + ev.src( addr ); + ev.value().grp = grp; + Forward( ev ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_NEW_MEMBER G" << grp << " " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } + } + + vtmap[oid].add( addr, grp ); + grmap.insert( make_pair(grp,oid) ); + + // cerr << "**** " << grp << " " << xmt::getpid() << endl; + + if ( /* (grp != vshosts_group) && */ (_hostmgr != 0) ) { + _hostmgr->Subscribe( addr, oid, grp ); + } +} + +void Janus::Unsubscribe( oid_type oid, group_type grp ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + + vt_map_type::iterator i = vtmap.find( oid ); + while ( range.first != range.second ) { + if ( range.first->second == oid ) { + grmap.erase( range.first++ ); + } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); + ev.dest( j->second.stem_addr() ); + ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + ev.value().grp = grp; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_OUT_MEMBER " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + Forward( ev ); + } + ++range.first; + } + } + + if ( i != vtmap.end() ) { + if ( i->second.rm_group( grp ) ) { // no groups more + vtmap.erase( i ); + } + } + + if ( grp != vshosts_group ) { + } +} + +void Janus::Unsubscribe( oid_type oid ) +{ + // See comment on top of JaSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + vt_map_type::iterator i = vtmap.find( oid ); + if ( i != vtmap.end() ) { + list<group_type> grp_list; + i->second.groups_list( back_inserter( grp_list ) ); + for ( list<group_type>::const_iterator grp = grp_list.begin(); grp != grp_list.end(); ++grp ) { + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( *grp ); + + while ( range.first != range.second ) { + if ( range.first->second == oid ) { + grmap.erase( range.first++ ); + } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); + ev.dest( j->second.stem_addr() ); + ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + ev.value().grp = *grp; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_OUT_MEMBER " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + Forward( ev ); + } + ++range.first; + } + } + i->second.rm_group( *grp ); + } + vtmap.erase( i ); + } + + // if ( grp != vshosts_group ) { + // } +} + +void Janus::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) +{ + // See comment on top of JaSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() && i->second.stem_addr() == addr ) { + i->second.get_gvt( gvt ); + return; + } + } + + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member +} + +void Janus::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) +{ + // See comment on top of JaSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( grp ); + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() && i->second.stem_addr() == addr ) { +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "Set gvt G" << grp << " " << i->first + << " (" << addr << ") " << gvt << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + i->second.sync( grp, i->first, gvt ); + check_and_send_delayed( i->second ); + return; + } + } + + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + } + } + catch ( ... ) { + } + + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member +} + +void Janus::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + if ( ev.value().grp == vshosts_group ) { + ev.dest( _hostmgr->self_id() ); + Forward( ev ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "<-> VS_NEW_MEMBER G" << vshosts_group << " " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + gaddr_type ga = manager()->reflect( ev.src() ); + addr_type janus_addr = badaddr; + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + janus_addr = manager()->reflect( ga ); + if ( janus_addr == badaddr ) { + janus_addr = manager()->SubscribeRemote( ga, "janus" ); + } + } + stem::Event_base<VSsync_rq> evr( VS_NEW_MEMBER_RV ); + evr.dest( janus_addr ); + evr.value().grp = vshosts_group; + Send( evr ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_NEW_MEMBER_RV G" << vshosts_group << " " + << hex << showbase + << evr.src() << " -> " << evr.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + } +} + +void Janus::VSNewRemoteMemberDirect( const stem::Event_base<VSsync_rq>& ev ) +{ + if ( ev.value().grp != vshosts_group ) { + group_type grp = ev.value().grp; + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); + if ( range.first != range.second ) { // we have local? member within this group + gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr + addr_type addr = ev.src(); + gaddr_type ga = manager()->reflect( addr ); + addr_type janus_addr = badaddr; + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + janus_addr = manager()->reflect( ga ); + if ( janus_addr == badaddr ) { + janus_addr = manager()->SubscribeRemote( ga, "janus" ); + } + } + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() ) { + stem::Event_base<VSsync_rq> evs( VS_NEW_MEMBER ); + evs.dest( i->second.stem_addr() ); + evs.src( addr ); + evs.value().grp = grp; + Forward( evs ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_NEW_MEMBER (remote) G" << grp << " " + << hex << showbase + << evs.src() << " -> " << evs.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + stem::Event_base<VSsync_rq> evr( VS_NEW_MEMBER_RV ); + evr.dest( janus_addr ); + evr.src( i->second.stem_addr() ); + evr.value().grp = grp; + Forward( evr ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_NEW_MEMBER_RV G" << grp << " " + << hex << showbase + << evr.src() << " -> " << evr.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } + } + + vtmap[oid].add( addr, grp ); + grmap.insert( make_pair(grp,oid) ); + // cerr << "**** " << grp << " " << xmt::getpid() << endl; + } + } +} + +void Janus::VSNewRemoteMemberRevert( const stem::Event_base<VSsync_rq>& ev ) +{ + if ( ev.value().grp != vshosts_group ) { + group_type grp = ev.value().grp; + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); + if ( range.first != range.second ) { // we have local? member within this group + gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr + addr_type addr = ev.src(); + for ( ; range.first != range.second; ++range.first ) { + vt_map_type::iterator i = vtmap.find( range.first->second ); + if ( i != vtmap.end() && ((i->second.stem_addr() & stem::extbit) == 0 )) { + stem::Event_base<VSsync_rq> evs( VS_NEW_MEMBER ); + evs.dest( i->second.stem_addr() ); + evs.src( addr ); + evs.value().grp = grp; + Forward( evs ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << " -> VS_NEW_MEMBER (remote revert) G" << grp << " " + << hex << showbase + << evs.src() << " -> " << evs.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } + } + + vtmap[oid].add( addr, grp ); + grmap.insert( make_pair(grp,oid) ); + // cerr << "**** " << grp << " " << xmt::getpid() << endl; + } + } else { + gaddr_type oid = manager()->reflect( ev.src() ); // ???? oid == gaddr + addr_type addr = ev.src(); + + vtmap[oid].add( addr, vshosts_group ); + grmap.insert( make_pair(static_cast<group_type>(vshosts_group),oid) ); + // cerr << "**** " << vshosts_group << " " << xmt::getpid() << endl; + } +} + +void Janus::connect( const char *host, int port ) +{ + _hostmgr->connect( host, port ); +} + +void Janus::serve( int port ) +{ + _hostmgr->serve( port ); +} + +size_t Janus::vs_known_processes() const +{ + return _hostmgr->vs_known_processes(); +} + +Janus::difference_type Janus::group_size( group_type grp ) const +{ + // See comment on top of JaSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( grp ); + + return distance( range.first, range.second ); +} + +DEFINE_RESPONSE_TABLE( Janus ) + EV_Event_base_T_( ST_NULL, VS_MESS, JaDispatch, VSmess ) + EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER, VSNewMember, VSsync_rq ) + EV_Event_base_T_( ST_NULL, VS_NEW_REMOTE_MEMBER, VSNewRemoteMemberDirect, VSsync_rq ) + EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER_RV, VSNewRemoteMemberRevert, VSsync_rq ) +END_RESPONSE_TABLE + +} // namespace janus Modified: trunk/complement/explore/lib/janus/ut/Makefile.inc =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-23 09:02:15 UTC (rev 1702) @@ -3,6 +3,8 @@ PRGNAME = ut_vtime SRC_CC = ../vtime.cc \ + ../janus.cc \ + ../vshostmgr.cc \ unit_test.cc \ vt_operations.cc \ VTmess_core.cc \ Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -112,7 +112,7 @@ ev.value().gvt[0][t1] = 2; ev.value().gvt[1][t0] = 3; ev.value().gvt[1][t1] = 4; - ev.value().grp = 7; + ev.value().grp = janus::vs_base::first_user_group + 7; ev.value().mess = "data"; h.Send( ev ); @@ -125,7 +125,7 @@ EXAM_CHECK( h.gvt[0][t1] == 2 ); EXAM_CHECK( h.gvt[1][t0] == 3 ); EXAM_CHECK( h.gvt[1][t1] == 4 ); - EXAM_CHECK( h.grp == 7 ); + EXAM_CHECK( h.grp == (janus::vs_base::first_user_group + 7) ); EXAM_CHECK( h.mess == "data" ); ev.value().code = 3; @@ -141,7 +141,7 @@ EXAM_CHECK( h.gvt[0][t1] == 2 ); EXAM_CHECK( h.gvt[1][t0] == 3 ); EXAM_CHECK( h.gvt[1][t1] == 4 ); - EXAM_CHECK( h.grp == 7 ); + EXAM_CHECK( h.grp == (janus::vs_base::first_user_group + 7) ); EXAM_CHECK( h.mess == "more data" ); return EXAM_RESULT; Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,9 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/08/17 10:39:45 ptr> +// -*- C++ -*- Time-stamp: <07/08/21 11:09:27 ptr> #include "vt_operations.h" #include <iostream> + #include <janus/vtime.h> +#include <janus/janus.h> using namespace janus; using namespace std; @@ -79,15 +81,15 @@ const oid_type t1(1); const oid_type t2(2); - dsp.Subscribe( dummy1.self_id(), t1, 0 ); - dsp.Subscribe( dummy2.self_id(), t2, 0 ); + dsp.Subscribe( dummy1.self_id(), t1, janus::vs_base::first_user_group ); + dsp.Subscribe( dummy2.self_id(), t2, janus::vs_base::first_user_group ); stem::Event ev( VT_MESS2 ); ev.src( dummy1.self_id() ); ev.value() = "hello"; - dsp.JaSend( ev, 0 ); + dsp.JaSend( ev, janus::vs_base::first_user_group ); dummy2.wait(); @@ -107,16 +109,16 @@ const oid_type t2(2); const oid_type t3(3); - dsp.Subscribe( dummy1.self_id(), t1, 0 ); - dsp.Subscribe( dummy2.self_id(), t2, 0 ); - dsp.Subscribe( dummy3.self_id(), t3, 0 ); + dsp.Subscribe( dummy1.self_id(), t1, janus::vs_base::first_user_group ); + dsp.Subscribe( dummy2.self_id(), t2, janus::vs_base::first_user_group ); + dsp.Subscribe( dummy3.self_id(), t3, janus::vs_base::first_user_group ); stem::Event ev( VT_MESS2 ); ev.src( dummy1.self_id() ); ev.value() = "hello"; - dsp.JaSend( ev, 0 ); + dsp.JaSend( ev, janus::vs_base::first_user_group ); dummy2.wait(); dummy3.wait(); Modified: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -54,7 +54,7 @@ cnd.set( false ); gr.set( false ); - JoinGroup( 0 ); + JoinGroup( first_user_group ); } VTDummy::VTDummy( stem::addr_type id ) : @@ -65,7 +65,7 @@ cnd.set( false ); gr.set( false ); - JoinGroup( 0 ); + JoinGroup( first_user_group ); } VTDummy::VTDummy( stem::addr_type id, const char *info ) : @@ -76,7 +76,7 @@ cnd.set( false ); gr.set( false ); - JoinGroup( 0 ); + JoinGroup( first_user_group ); } VTDummy::~VTDummy() @@ -133,7 +133,7 @@ VTDummy dummy2; stem::Event ev( VS_DUMMY_MESS ); - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group ev.value() = "hello"; dummy1.JaSend( ev ); @@ -153,7 +153,7 @@ VTDummy dummy3; stem::Event ev( VS_DUMMY_MESS ); - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group ev.value() = "hello"; dummy1.JaSend( ev ); @@ -168,7 +168,7 @@ EXAM_CHECK( dummy1.count == 2 ); EXAM_CHECK( dummy1.msg == "" ); - ev.dest( 100 ); // not this group member + ev.dest( janus::vs_base::first_user_group + 100 ); // not this group member try { dummy1.JaSend( ev ); EXAM_ERROR( "exception expected" ); @@ -185,7 +185,7 @@ VTDummy dummy2; stem::Event ev( VS_DUMMY_MESS ); - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group ev.value() = "hello"; dummy1.JaSend( ev ); @@ -226,7 +226,7 @@ VTDummy dummy1; stem::Event ev( VS_DUMMY_MESS ); - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group ev.value() = "hello"; { @@ -255,7 +255,7 @@ VTDummy dummy2; stem::Event ev( VS_DUMMY_MESS ); - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group ev.value() = "hello"; dummy1.JaSend( ev ); @@ -277,7 +277,7 @@ dummy3.wait_greeting(); ev.value() = "hi"; - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group dummy1.JaSend( ev ); dummy2.wait(); @@ -303,7 +303,7 @@ dummy2.wait_greeting(); ev.value() = "hello"; - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group dummy1.JaSend( ev ); dummy2.wait(); @@ -317,7 +317,7 @@ dummy3.wait_greeting(); ev.value() = "hi"; - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group dummy1.JaSend( ev ); dummy3.wait(); @@ -334,7 +334,7 @@ dummy3.wait_greeting(); ev.value() = "more"; - ev.dest( 0 ); // group + ev.dest( janus::vs_base::first_user_group ); // group dummy1.JaSend( ev ); dummy2.wait(); Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -12,9 +12,9 @@ { detail::vtime_obj_rec ob; - const group_type gr0 = 0; - const group_type gr1 = 1; - const group_type gr2 = 2; + const group_type gr0 = janus::vs_base::first_user_group + 0; + const group_type gr1 = janus::vs_base::first_user_group + 1; + const group_type gr2 = janus::vs_base::first_user_group + 2; const oid_type obj0(0); const oid_type obj1(1); const oid_type obj2(2); Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,30 +1,41 @@ -// -*- C++ -*- Time-stamp: <07/08/17 10:07:52 ptr> +// -*- C++ -*- Time-stamp: <07/08/23 12:43:15 ptr> #include "vt_operations.h" #include <iostream> #include <janus/vtime.h> +#include <janus/janus.h> +#include <janus/vshostmgr.h> #include <stem/EvManager.h> #include <stem/NetTransport.h> +#include <stem/Event.h> +#include <stem/EvPack.h> #include <sockios/sockmgr.h> #include <sys/wait.h> #include <mt/xmt.h> #include <mt/shm.h> +#include <mt/time.h> +#include <list> +#include <sstream> + using namespace std; using namespace stem; using namespace xmt; using namespace janus; +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + class YaRemote : public janus::VTHandler { public: YaRemote(); - YaRemote( stem::addr_type id ); - YaRemote( stem::addr_type id, const char *info ); + YaRemote( stem::addr_type id, const char *info = 0 ); + YaRemote( const char *info ); ~YaRemote(); void handler( const stem::Event& ); @@ -51,9 +62,6 @@ DECLARE_RESPONSE_TABLE( YaRemote, janus::VTHandler ); }; -#define VS_DUMMY_MESS 0x1203 -#define VS_DUMMY_GREETING 0x1204 - YaRemote::YaRemote() : VTHandler(), count(0), @@ -61,30 +69,24 @@ { cnd.set( false ); gr.set( false ); - - JoinGroup( 0 ); } -YaRemote::YaRemote( stem::addr_type id ) : - VTHandler( id ), +YaRemote::YaRemote( stem::addr_type id, const char *info ) : + VTHandler( id, info ), count(0), ocount(0) { cnd.set( false ); gr.set( false ); - - JoinGroup( 0 ); } -YaRemote::YaRemote( stem::addr_type id, const char *info ) : - VTHandler( id, info ), +YaRemote::YaRemote( const char *info ) : + VTHandler( info ), count(0), ocount(0) { cnd.set( false ); gr.set( false ); - - JoinGroup( 0 ); } YaRemote::~YaRemote() @@ -101,7 +103,7 @@ void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) { - // cerr << "Hello " << ev.src() << endl; + cerr << "Hello " << xmt::getpid() << endl; ++count; // VTNewMember_data( ev, "" ); @@ -127,7 +129,9 @@ void YaRemote::greeting() { - gr.set( true ); + if ( count > 0 ) { + gr.set( true ); + } } DEFINE_RESPONSE_TABLE( YaRemote ) @@ -137,6 +141,8 @@ int EXAM_IMPL(vtime_operations::remote) { + cerr << "============\n"; + const char fname[] = "/tmp/yanus_test.shm"; xmt::shm_alloc<0> seg; xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; @@ -151,30 +157,73 @@ b.wait(); - NetTransportMgr mgr; + { + YaRemote obj1( "obj client" ); - addr_type zero = mgr.open( "localhost", 6980 ); + // obj1.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch ); + // obj1.manager()->settrs( &std::cerr ); - EXAM_CHECK_ASYNC( mgr.good() ); + obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + obj1.vtdispatcher()->settrs( &std::cerr ); - YaRemote obj2; + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 1 ); + obj1.vtdispatcher()->connect( "localhost", 6980 ); + + cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + +#if 1 + while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 1000000 ) ); + } +#else + while ( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) < 2 ) { + xmt::Thread::yield(); + xmt::delay( xmt::timespec( 0, 1000000 ) ); + } +#endif + + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) == 2 ); + cerr << obj1.vtdispatcher()->group_size(janus::vs_base::vshosts_group) << endl; + + obj1.JoinGroup( janus::vs_base::first_user_group ); + + obj1.wait_greeting(); + + EXAM_CHECK_ASYNC( obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) == 2 ); + + // cerr << "* " << obj1.vtdispatcher()->group_size(janus::vs_base::first_user_group) << endl; + } + exit(0); } catch ( xmt::fork_in_parent& child ) { - sockmgr_stream_MP<NetTransport> srv( 6980 ); + YaRemote obj1( "obj srv" ); - EXAM_REQUIRE( srv.good() ); + // obj1.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + // obj1.vtdispatcher()->settrs( &std::cerr ); + obj1.vtdispatcher()->serve( 6980 ); + + obj1.JoinGroup( janus::vs_base::first_user_group ); + b.wait(); - YaRemote obj1; + // while ( obj1.vtdispatcher()->vs_known_processes() < 2 ) { + // xmt::delay( xmt::timespec( 0, 1000000 ) ); + // } + // stem::Event ev( VS_DUMMY_MESS ); + // ev.dest( janus::vs_base::first_user_group ); // group + // ev.value() = "hello"; + + // obj1.JaSend( ev ); + + // obj1.wait_greeting(); + int stat; EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); - - srv.close(); - srv.wait(); } (&b)->~__barrier<true>(); Added: trunk/complement/explore/lib/janus/vshostmgr.cc =================================================================== --- trunk/complement/explore/lib/janus/vshostmgr.cc (rev 0) +++ trunk/complement/explore/lib/janus/vshostmgr.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -0,0 +1,222 @@ +// -*- C++ -*- Time-stamp: <07/08/23 11:24:18 ptr> + +#include <janus/vshostmgr.h> + +#include <iostream> +#include <janus/vtime.h> +#include <janus/janus.h> + +#include <stem/EvManager.h> +#include <stem/NetTransport.h> +#include <stem/Event.h> +#include <stem/EvPack.h> +#include <sockios/sockmgr.h> + +#include <mt/xmt.h> + +#include <list> +#include <sstream> + +namespace janus { + +using namespace std; +using namespace stem; +using namespace xmt; +using namespace janus; + +VSHostMgr::VSHostMgr() : + VTHandler() +{ + vshost.insert( gaddr_type( stem::janus_addr ) ); + JoinGroup( vshosts_group ); +} + +VSHostMgr::VSHostMgr( stem::addr_type id, const char *info ) : + VTHandler( id, info ) +{ + vshost.insert( gaddr_type( stem::janus_addr ) ); + JoinGroup( vshosts_group ); +} + +VSHostMgr::VSHostMgr( const char *info ) : + VTHandler( info ) +{ + // vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + + vshost.insert( gaddr_type( stem::janus_addr ) ); + JoinGroup( vshosts_group ); +} + +VSHostMgr::~VSHostMgr() +{ + while ( !_clients.empty() ) { + _clients.front()->close(); + _clients.front()->join(); + delete _clients.front(); + _clients.pop_front(); + } + while ( !_servers.empty() ) { + _servers.front()->close(); + _servers.front()->wait(); + delete _servers.front(); + _servers.pop_front(); + } +} + +void VSHostMgr::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // pack vshost, + stringstream s; + + gaddr_type ga = manager()->reflect( ev.src() ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + } + + vshost.insert( ga ); // address of remote Janus + + stem::__pack_base::__net_pack( s, static_cast<uint32_t>(vshost.size()) ); + for ( vshost_container_t::const_iterator i = vshost.begin(); i != vshost.end(); ++i ) { + i->net_pack( s ); + } + VTHandler::VSNewMember_data( ev, s.str() ); + // VTHandler::VSNewMember( ev ); +} + +void VSHostMgr::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // remove host from vshost + gaddr_type ga = manager()->reflect( ev.src() ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + } + + vshost_container_t::iterator i = vshost.find( ga ); + if ( i != vshost.end() ) { + vshost.erase( i ); + } +#ifdef __FIT_VS_TRACE + VTHandler::VSOutMember( ev ); +#endif +} + +void VSHostMgr::VSsync_time( const stem::Event_base<VSsync>& ev ) +{ + // extract ev.value().mess, sync with vshost + stringstream s( ev.value().mess ); + + uint32_t sz; + gaddr_type ga; + + stem::__pack_base::__net_unpack( s, sz ); + while ( sz-- > 0 ) { + ga.net_unpack( s ); + // vshost.push_back( ga ); + vshost.insert( ga ); + } + + VTHandler::VSsync_time(ev); +} + +void VSHostMgr::connect( const char *host, int port ) +{ + _clients.push_back( new NetTransportMgr() ); + + addr_type zero = _clients.back()->open( host, port ); + + gaddr_type ga = manager()->reflect( zero ); + if ( ga != gaddr_type() ) { + ga.addr = stem::janus_addr; + addr_type a = manager()->reflect( ga ); + if ( a == badaddr ) { + a = manager()->SubscribeRemote( ga, "janus" ); + } + stem::Event_base<VSsync_rq> ev( VS_NEW_MEMBER ); + ev.dest( a ); + ev.value().grp = vshosts_group; // special group + Send( ev ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(vtdispatcher()->_lock_tr); + if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { + *vtdispatcher()->_trs << "connect " << host << ":" << port << "\n" + << " -> VS_NEW_MEMBER G" << vshosts_group << " " + << hex << showbase + << self_id() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } +#ifdef __FIT_VS_TRACE + else { + try { + scoped_lock lk(vtdispatcher()->_lock_tr); + if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { + *vtdispatcher()->_trs << "connect " << host << ":" << port << " fail" << endl; + } + } + catch ( ... ) { + } + } +#endif // __FIT_VS_TRACE +} + +void VSHostMgr::serve( int port ) +{ + _servers.push_back( new sockmgr_stream_MP<NetTransport>( port ) ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(vtdispatcher()->_lock_tr); + if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { + *vtdispatcher()->_trs << "serve " << port + << (_servers.back()->good() ? " ok" : " fail" ) + << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE +} + +void VSHostMgr::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +{ + try { + manager()->transport( addr ); + } + catch ( const range_error& ) { + // only for local object + stem::Event_base<VSsync_rq> ev( VS_NEW_REMOTE_MEMBER ); + ev.src( addr ); + gaddr_type ga = manager()->reflect( stem::janus_addr ); + + for ( vshost_container_t::const_iterator i = vshost.begin(); i != vshost.end(); ++i ) { + if ( ga != *i ) { + ev.dest( manager()->reflect( *i ) ); + ev.value().grp = grp; + Forward( ev ); +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(vtdispatcher()->_lock_tr); + if ( vtdispatcher()->_trs != 0 && vtdispatcher()->_trs->good() && (vtdispatcher()->_trflags & Janus::tracenet) ) { + *vtdispatcher()->_trs << " -> VS_NEW_REMOTE_MEMBER G" << grp << " " + << hex << showbase + << ev.src() << " -> " << ev.dest() << dec << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + } + } + } +} + +// DEFINE_RESPONSE_TABLE( VSHostMgr ) +// EV_Event_base_T_( ST_NULL, VS_NEW_REMOTE_MEMBER, VSNewRemoteMemberDirect, VSsync_rq ) +// EV_Event_base_T_( ST_NULL, VS_NEW_MEMBER_RV, VSNewRemoteMemberRevert, VSsync_rq ) +// END_RESPONSE_TABLE + + +} // namespace janus Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-23 08:49:29 UTC (rev 1701) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-23 09:02:15 UTC (rev 1702) @@ -1,10 +1,10 @@ -// -*- C++ -*- Time-stamp: <07/08/17 22:28:55 ptr> +// -*- C++ -*- Time-stamp: <07/08/23 08:47:46 ptr> #include <janus/vtime.h> +#include <janus/janus.h> +#include <janus/vshostmgr.h> -#include <iostream> #include <stdint.h> -#include <stem/EvManager.h> namespace janus { @@ -543,442 +543,7 @@ } // namespace detail -void Janus::settrf( unsigned f ) -{ - scoped_lock _x1( _lock_tr ); - _trflags |= f; -} -void Janus::unsettrf( unsigned f ) -{ - scoped_lock _x1( _lock_tr ); - _trflags &= (0xffffffff & ~f); -} - -void Janus::resettrf( unsigned f ) -{ - scoped_lock _x1( _lock_tr ); - _trflags = f; -} - -void Janus::cleantrf() -{ - scoped_lock _x1( _lock_tr ); - _trflags = 0; -} - -unsigned Janus::trflags() const -{ - scoped_lock _x1( _lock_tr ); - - return _trflags; -} - -void Janus::settrs( std::ostream *s ) -{ - scoped_lock _x1( _lock_tr ); - _trs = s; -} - -void Janus::JaDispatch( const stem::Event_base<VSmess>& m ) -{ - pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = - grmap.equal_range( m.value().grp ); - - for ( ; range.first != range.second; ++range.first ) { - vt_map_type::iterator i = vtmap.find( range.first->second ); - if ( i == vtmap.end() || i->second.stem_addr() == m.src() ) { // not for nobody and not for self - continue; - } - try { - // check local or remote? i->second.addr - // if remote, forward it to foreign VTDispatcher? - // looks, like local source shouldn't be here? - check_and_send( i->second, m ); - } - catch ( const out_of_range& err ) { - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << err.what() << " " - << __FILE__ << ":" << __LINE__ << endl; - } - } - catch ( ... ) { - } - } - catch ( const domain_error& err ) { - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << err.what() << " " - << __FILE__ << ":" << __LINE__ << endl; - } - } - catch ( ... ) { - } - } - } -} - -void Janus::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VSmess>& m ) -{ - if ( vt.deliver( m.value() ) ) { - stem::Event ev( m.value().code ); - ev.dest(vt.stem_addr()); - ev.src(m.src()); - ev.value() = m.value().mess; -#ifdef __FIT_VS_TRACE - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { - *_trs << "Deliver " << m.value() << endl; - } - } - catch ( ... ) { - } -#endif // __FIT_VS_TRACE - Forward( ev ); - check_and_send_delayed( vt ); - } else { -#ifdef __FIT_VS_TRACE - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracedelayed) ) { - *_trs << "Delayed " << m.value() << endl; - } - } - catch ( ... ) { - } -#endif // __FIT_VS_TRACE - vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VSmess>(m) ) ); // 0 should be timestamp - } -} - -void Janus::check_and_send_delayed( detail::vtime_obj_rec& vt ) -{ - typedef detail::vtime_obj_rec::dpool_t dpool_t; - bool more; - do { - more = false; - for ( dpool_t::iterator j = vt.dpool.begin(); j != vt.dpool.end(); ) { - if ( vt.deliver_delayed( j->second->value() ) ) { - stem::Event evd( j->second->value().code ); - evd.dest(vt.stem_addr()); - evd.src(j->second->src()); - evd.value() = j->second->value().mess; -#ifdef __FIT_VS_TRACE - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { - *_trs << "Deliver delayed " << j->second->value() << endl; - } - } - catch ( ... ) { - } -#endif // __FIT_VS_TRACE - Forward( evd ); - delete j->second; - vt.dpool.erase( j++ ); - more = true; - } else { -#ifdef __FIT_VS_TRACE - try { - scoped_lock lk(_lock_tr); - if ( _trs != 0 && _trs->good() && (_trflags & tracedispatch) ) { - *_trs << "Remain delayed " << j->second->value() - << "\nReason: "; - vt.trace_deliver( j->second->value(), *_trs ) << endl; - } - } - catch ( ... ) { - } -#endif // __FIT_VS_TRACE - ++j; - } - } - } while ( more ); -} - -void Janus::JaSend( 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 ); - - for ( gid_map_type::const_iterator o = range.first; o != range.second; ++o ) { - vt_map_type::iterator i = vtmap.find( o->second ); - if ( i != vtmap.end() && i->second.stem_addr() == e.src() ) { // for self - detail::vtime_obj_rec& vt = i->second; - const oid_type& from = o->second; - stem::Event_base<VSmess> m( VS_MESS ); - m.value().src = from; // oid - m.value().code = e.code(); - m.value().mess = e.value(); - m.value().grp = grp; - // m.dest( ??? ); // local VT dispatcher? - m.src( e.src() ); - - // This is like VTDispatch, but VT stamp in every message different, - // in accordance with individual knowlage about object's VT. - - vt.next( from, grp ); // my counter - - for ( gid_map_type::const_iterator g = range.first; g != range.second; ++g ) { - vt_map_type::iterator k = vtmap.find( g->second ); - if ( k == vtmap.end() || k->second.stem_addr() == m.src() ) { // not for nobody and not for self - continue; - } - try { - vt.delta( m.value().gvt, from, g->second, grp ); - - ... [truncated message content] |
From: <com...@us...> - 2007-08-23 08:49:30
|
Revision: 1701 http://complement.svn.sourceforge.net/complement/?rev=1701&view=rev Author: complement Date: 2007-08-23 01:49:29 -0700 (Thu, 23 Aug 2007) Log Message: ----------- add __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION for gcc < 3.4 Modified Paths: -------------- trunk/complement/explore/include/config/_gcc.h trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/config/_gcc.h =================================================================== --- trunk/complement/explore/include/config/_gcc.h 2007-08-23 08:47:58 UTC (rev 1700) +++ trunk/complement/explore/include/config/_gcc.h 2007-08-23 08:49:29 UTC (rev 1701) @@ -1,35 +1,30 @@ -/* Time-stamp: <05/12/12 10:47:53 ptr> */ +/* Time-stamp: <07/08/21 10:39:52 ptr> */ /* - * - * Copyright (c) 2003 + * Copyright (c) 2003, 2007 * Petr Ovtchenkov * - * Licensed under the Academic Free License Version 2.1 + * Licensed under the Academic Free License Version 3.0 * - * This material is provided "as is", with absolutely no warranty expressed - * or implied. Any use is at your own risk. - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. - * */ #ifndef __config__gcc_h #define __config__gcc_h /* -#if defined(__GNUC__) && (__GNUC__==3) // gcc 3.1.1 at least +#if (__GNUC__==3) // gcc 3.1.1 at least # define __FIT_TYPENAME_TEMPLATE_PARAMETER_RET #endif */ -#if defined(__GNUC__) && ( __GNUC__ == 2 ) && (__GNUC_MINOR__ == 95) +#if ( __GNUC__ == 2 ) && (__GNUC_MINOR__ == 95) /* at least 2.95.3 #define __FIT_STD_AS_GLOBAL */ #endif +/* 3.3.6, but 3.4.6 and 4.1.1 free from this */ +#if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) +# define __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION +#endif + #endif /* __config__gcc_h */ Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-23 08:47:58 UTC (rev 1700) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-23 08:49:29 UTC (rev 1701) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/06 10:30:28 ptr> +// -*- C++ -*- Time-stamp: <07/08/21 10:42:14 ptr> /* * Copyright (c) 2007 @@ -49,7 +49,7 @@ static __t2 __test(...); public: -#if defined(__GNUC__) && (__GNUC__ < 4) +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION static const bool __value; #else static const bool __value = sizeof(__test<_Tp>(0)) == 1; @@ -57,7 +57,7 @@ }; -#if defined(__GNUC__) && (__GNUC__ < 4) +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION template <class _Tp> const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == 1; #endif @@ -74,14 +74,14 @@ static __t2 __test(...); public: -#if defined(__GNUC__) && (__GNUC__ < 4) +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION static const bool __value; #else static const bool __value = sizeof(__test<T>(0)) == 1; #endif }; -#if defined(__GNUC__) && (__GNUC__ < 4) +#ifdef __FIT_NO_INLINE_TEMPLATE_STATIC_INITIALISATION template <class T> const bool __uoc_aux<T>::__value = sizeof(__uoc_aux<T>::__test<T>(0)) == 1; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 08:48:00
|
Revision: 1700 http://complement.svn.sourceforge.net/complement/?rev=1700&view=rev Author: complement Date: 2007-08-23 01:47:58 -0700 (Thu, 23 Aug 2007) Log Message: ----------- inhibit copy of NetTransportMgr explicitly; libstem: library version 4.6.2 (due to address for janus). Modified Paths: -------------- trunk/complement/explore/include/stem/NetTransport.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/Makefile.inc Modified: trunk/complement/explore/include/stem/NetTransport.h =================================================================== --- trunk/complement/explore/include/stem/NetTransport.h 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/include/stem/NetTransport.h 2007-08-23 08:47:58 UTC (rev 1700) @@ -99,6 +99,10 @@ int join() { return _thr.join().iword; } + private: + NetTransportMgr( const NetTransportMgr& ); + NetTransportMgr& operator =( const NetTransportMgr& ); + protected: static xmt::Thread::ret_code _loop( void * ); xmt::Thread _thr; Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-23 08:47:58 UTC (rev 1700) @@ -1,3 +1,9 @@ +2007-08-23 Petr Ovtchenkov <pt...@is...> + + * NetTransport.h: inhibit copy of NetTransportMgr explicitly; + + * libstem: library version 4.6.2 (due to address for janus). + 2007-08-17 Petr Ovtchenkov <pt...@is...> * Event.h, EvManager.cc: add fixed address for janus Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-08-23 08:46:41 UTC (rev 1699) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-08-23 08:47:58 UTC (rev 1700) @@ -3,7 +3,7 @@ LIBNAME = stem MAJOR = 4 MINOR = 6 -PATCH = 1 +PATCH = 2 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-23 08:46:48
|
Revision: 1699 http://complement.svn.sourceforge.net/complement/?rev=1699&view=rev Author: complement Date: 2007-08-23 01:46:41 -0700 (Thu, 23 Aug 2007) Log Message: ----------- explicitly inhibit copy of basic_sockmgr and sockmgr_stream_MP. libsockios: Version 1.12.1 Modified Paths: -------------- trunk/complement/explore/include/sockios/sockmgr.h trunk/complement/explore/lib/sockios/ChangeLog trunk/complement/explore/lib/sockios/Makefile.inc Modified: trunk/complement/explore/include/sockios/sockmgr.h =================================================================== --- trunk/complement/explore/include/sockios/sockmgr.h 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/include/sockios/sockmgr.h 2007-08-23 08:46:41 UTC (rev 1699) @@ -102,6 +102,10 @@ } private: + basic_sockmgr( const basic_sockmgr& ); + basic_sockmgr& operator =( const basic_sockmgr& ); + + private: sock_base::socket_type _fd; // master socket unsigned long _mode; // open mode unsigned long _state; // state flags @@ -190,6 +194,11 @@ ~sockmgr_stream_MP() { loop_id.join(); } + private: + sockmgr_stream_MP( const sockmgr_stream_MP<Connect>& ); + sockmgr_stream_MP<Connect>& operator =( const sockmgr_stream_MP<Connect>& ); + + public: void open( const in_addr& addr, int port, sock_base::stype t = sock_base::sock_stream ); void open( unsigned long addr, int port, sock_base::stype t = sock_base::sock_stream ); void open( int port, sock_base::stype t = sock_base::sock_stream ); @@ -315,7 +324,7 @@ bool _shift_fd(); static void _close_by_signal( int ); bool _is_follow() const - { MT_REENTRANT( _flock, _1 ); return _follow; } + { xmt::scoped_lock lk( _flock ); bool tmp = _follow; return tmp; } }; #endif // !__FIT_NO_POLL Modified: trunk/complement/explore/lib/sockios/ChangeLog =================================================================== --- trunk/complement/explore/lib/sockios/ChangeLog 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/lib/sockios/ChangeLog 2007-08-23 08:46:41 UTC (rev 1699) @@ -1,3 +1,10 @@ +2007-08-23 Petr Ovtchenkov <pt...@is...> + + * sockmgr.h: explicitly inhibit copy of basic_sockmgr and + sockmgr_stream_MP. + + * libsockios: Version 1.12.1. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * include/sockios/sockstream: workaround for file openmode Modified: trunk/complement/explore/lib/sockios/Makefile.inc =================================================================== --- trunk/complement/explore/lib/sockios/Makefile.inc 2007-08-18 05:13:06 UTC (rev 1698) +++ trunk/complement/explore/lib/sockios/Makefile.inc 2007-08-23 08:46:41 UTC (rev 1699) @@ -3,7 +3,7 @@ LIBNAME = sockios MAJOR = 1 MINOR = 12 -PATCH = 0 +PATCH = 1 SRC_CC = _sockstream.cc _sockmgr.cc SRC_C = freebsd/getaddrinfo.c \ freebsd/ns_parse.c \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-18 05:13:11
|
Revision: 1698 http://complement.svn.sourceforge.net/complement/?rev=1698&view=rev Author: complement Date: 2007-08-17 22:13:06 -0700 (Fri, 17 Aug 2007) Log Message: ----------- add fixed address for janus [virtual synchrony dispatcher, janus subproject] Modified Paths: -------------- trunk/complement/explore/include/stem/Event.h trunk/complement/explore/lib/janus/vtime.cc trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvManager.cc Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/include/stem/Event.h 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 08:19:34 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:15:41 ptr> /* * @@ -40,6 +40,7 @@ extern const addr_type extbit; extern const addr_type default_addr; extern const addr_type ns_addr; +extern const addr_type janus_addr; extern const code_type badcode; struct gaddr_type : Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 10:39:02 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:28:55 ptr> #include <janus/vtime.h> @@ -1013,7 +1013,7 @@ _rcount = &_count; pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); #endif - VTHandler::_vtdsp = new Janus( 2, "vtd" ); + VTHandler::_vtdsp = new Janus( janus_addr, "janus" ); } } else { --_count; @@ -1040,24 +1040,18 @@ EventHandler() { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( const char *info ) : EventHandler( info ) { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( stem::addr_type id, const char *info ) : EventHandler( id, info ) { new( Init_buf ) Init(); - - // _vtdsp->Subscribe( id, oid_type( id ), /* grp */ 0 ); } VTHandler::~VTHandler() Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * Event.h, EvManager.cc: add fixed address for janus + [virtual synchrony dispatcher, janus subproject]. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * Makefile: let's try don't include boost's -I if macro Modified: trunk/complement/explore/lib/stem/EvManager.cc =================================================================== --- trunk/complement/explore/lib/stem/EvManager.cc 2007-08-17 18:06:59 UTC (rev 1697) +++ trunk/complement/explore/lib/stem/EvManager.cc 2007-08-18 05:13:06 UTC (rev 1698) @@ -1,8 +1,8 @@ -// -*- C++ -*- Time-stamp: <07/08/03 09:20:31 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 22:22:13 ptr> /* * - * Copyright (c) 1995-1999, 2002, 2003, 2005, 2006 + * Copyright (c) 1995-1999, 2002, 2003, 2005-2007 * Petr Ovtchenkov * * Copyright (c) 1999-2001 @@ -29,11 +29,12 @@ using namespace std; using namespace xmt; -const addr_type badaddr = 0xffffffff; -const code_type badcode = static_cast<code_type>(-1); -const addr_type extbit = 0x80000000; +const addr_type badaddr = 0xffffffff; +const code_type badcode = 0xffffffff; +const addr_type extbit = 0x80000000; const addr_type default_addr = 0x00000000; -const addr_type ns_addr = 0x00000001; +const addr_type ns_addr = 0x00000001; +const addr_type janus_addr = 0x00000002; const addr_type beglocaddr = 0x00000100; const addr_type endlocaddr = 0x3fffffff; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 18:07:00
|
Revision: 1697 http://complement.svn.sourceforge.net/complement/?rev=1697&view=rev Author: complement Date: 2007-08-17 11:06:59 -0700 (Fri, 17 Aug 2007) Log Message: ----------- mapped_type is correct for all, including proposed standard Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 16:25:13 UTC (rev 1696) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 18:06:59 UTC (rev 1697) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 10:38:35 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 21:54:39 ptr> #ifndef __vtime_h #define __vtime_h @@ -140,15 +140,9 @@ vtime& operator +=( const vtime_type::value_type& ); -#ifdef __USE_STD_TR1 - typedef vtime_unit_type data_type; -#else - typedef vtime_type::data_type data_type; -#endif - - data_type& operator[]( const vtime_type::key_type& k ) + vtime_type::mapped_type& operator[]( const vtime_type::key_type& k ) { return vt[k]; } - const data_type& operator[]( const vtime_type::key_type& k ) const + const vtime_type::mapped_type& operator[]( const vtime_type::key_type& k ) const { return vt[k]; } @@ -195,15 +189,9 @@ gvtime& operator +=( const gvtime_type::value_type& ); gvtime& operator +=( const gvtime& ); -#ifdef __USE_STD_TR1 - typedef vtime data_type; -#else - typedef gvtime_type::data_type data_type; -#endif - - data_type& operator[]( const gvtime_type::key_type k ) + gvtime_type::mapped_type& operator[]( const gvtime_type::key_type k ) { return gvt[k]; } - const data_type& operator[]( const gvtime_type::key_type k ) const + const gvtime_type::mapped_type& operator[]( const gvtime_type::key_type k ) const { return gvt[k]; } mutable gvtime_type gvt; @@ -302,13 +290,7 @@ void sync( group_type, const oid_type&, const gvtime_type& ); #ifdef __FIT_EXAM -#ifdef __USE_STD_TR1 - typedef vtime data_type; -#else - typedef gvtime_type::data_type data_type; -#endif - - const data_type& operator[]( const gvtime_type::key_type k ) const + const gvtime_type::mapped_type& operator[]( const gvtime_type::key_type k ) const { return vt[k]; } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 16:25:17
|
Revision: 1696 http://complement.svn.sourceforge.net/complement/?rev=1696&view=rev Author: complement Date: 2007-08-17 09:25:13 -0700 (Fri, 17 Aug 2007) Log Message: ----------- dancing with std::tr1::hashtable from libstdc++ team Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 16:13:09 UTC (rev 1695) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 16:25:13 UTC (rev 1696) @@ -141,7 +141,7 @@ vtime& operator +=( const vtime_type::value_type& ); #ifdef __USE_STD_TR1 - typedef vtime_type::value_type data_type; + typedef vtime_unit_type data_type; #else typedef vtime_type::data_type data_type; #endif @@ -196,7 +196,7 @@ gvtime& operator +=( const gvtime& ); #ifdef __USE_STD_TR1 - typedef gvtime_type::value_type data_type; + typedef vtime data_type; #else typedef gvtime_type::data_type data_type; #endif @@ -303,7 +303,7 @@ #ifdef __FIT_EXAM #ifdef __USE_STD_TR1 - typedef gvtime_type::value_type data_type; + typedef vtime data_type; #else typedef gvtime_type::data_type data_type; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 16:13:14
|
Revision: 1695 http://complement.svn.sourceforge.net/complement/?rev=1695&view=rev Author: complement Date: 2007-08-17 09:13:09 -0700 (Fri, 17 Aug 2007) Log Message: ----------- dancing with std::tr1::hashtable from libstdc++ team Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 15:24:30 UTC (rev 1694) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 16:13:09 UTC (rev 1695) @@ -41,15 +41,19 @@ } // namespace janus -#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) +#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) # define __HASH_NAMESPACE std #endif -#if defined(__USE_STD_HASH) || defined(__USE_STD_TR1) +#if defined(__USE_STD_HASH) # define __HASH_NAMESPACE __gnu_cxx #endif namespace __HASH_NAMESPACE { +#ifdef __USE_STD_TR1 +namespace tr1 { +#endif + template <> struct hash<janus::oid_type> { @@ -57,6 +61,10 @@ { return __x.addr; } }; +#ifdef __USE_STD_TR1 +} +#endif + } // namespace __HASH_NAMESPACE #undef __HASH_NAMESPACE @@ -132,9 +140,15 @@ vtime& operator +=( const vtime_type::value_type& ); - vtime_type::data_type& operator[]( const vtime_type::key_type& k ) +#ifdef __USE_STD_TR1 + typedef vtime_type::value_type data_type; +#else + typedef vtime_type::data_type data_type; +#endif + + data_type& operator[]( const vtime_type::key_type& k ) { return vt[k]; } - const vtime_type::data_type& operator[]( const vtime_type::key_type& k ) const + const data_type& operator[]( const vtime_type::key_type& k ) const { return vt[k]; } @@ -181,9 +195,15 @@ gvtime& operator +=( const gvtime_type::value_type& ); gvtime& operator +=( const gvtime& ); - gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) +#ifdef __USE_STD_TR1 + typedef gvtime_type::value_type data_type; +#else + typedef gvtime_type::data_type data_type; +#endif + + data_type& operator[]( const gvtime_type::key_type k ) { return gvt[k]; } - const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const + const data_type& operator[]( const gvtime_type::key_type k ) const { return gvt[k]; } mutable gvtime_type gvt; @@ -282,7 +302,13 @@ void sync( group_type, const oid_type&, const gvtime_type& ); #ifdef __FIT_EXAM - const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const +#ifdef __USE_STD_TR1 + typedef gvtime_type::value_type data_type; +#else + typedef gvtime_type::data_type data_type; +#endif + + const data_type& operator[]( const gvtime_type::key_type k ) const { return vt[k]; } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 15:31:39
|
Revision: 1693 http://complement.svn.sourceforge.net/complement/?rev=1693&view=rev Author: complement Date: 2007-08-17 08:22:41 -0700 (Fri, 17 Aug 2007) Log Message: ----------- fix build without STLport Modified Paths: -------------- trunk/complement/explore/lib/janus/ut/Makefile Modified: trunk/complement/explore/lib/janus/ut/Makefile =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile 2007-08-17 15:01:43 UTC (rev 1692) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-08-17 15:22:41 UTC (rev 1693) @@ -9,10 +9,15 @@ include ${SRCROOT}/Makefiles/gmake/top.mak # DEFS += -DUNIT_TEST -INCLUDES += -I${CoMT_INCLUDE_DIR} -I${BOOST_INCLUDE_DIR} -I.. +INCLUDES += -I${CoMT_INCLUDE_DIR} -I.. DEFS += -D__FIT_EXAM -LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} +LDFLAGS += -L${INSTALL_LIB_DIR} +ifdef WITHOUT_STLPORT +LDFLAGS += -Wl,-rpath=${INSTALL_LIB_DIR} +else +LDFLAGS += -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} +endif release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 15:31:13
|
Revision: 1694 http://complement.svn.sourceforge.net/complement/?rev=1694&view=rev Author: complement Date: 2007-08-17 08:24:30 -0700 (Fri, 17 Aug 2007) Log Message: ----------- hash in STD always in __gnu_cxx namespace Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 15:22:41 UTC (rev 1693) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 15:24:30 UTC (rev 1694) @@ -41,10 +41,10 @@ } // namespace janus -#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) # define __HASH_NAMESPACE std #endif -#ifdef __USE_STD_HASH +#if defined(__USE_STD_HASH) || defined(__USE_STD_TR1) # define __HASH_NAMESPACE __gnu_cxx #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 15:01:44
|
Revision: 1692 http://complement.svn.sourceforge.net/complement/?rev=1692&view=rev Author: complement Date: 2007-08-17 08:01:43 -0700 (Fri, 17 Aug 2007) Log Message: ----------- gcc 4.1.2 problems? Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:56:26 UTC (rev 1691) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-17 15:01:43 UTC (rev 1692) @@ -20,7 +20,7 @@ // libstdc++ v3, timestamp 20050519 (3.4.4) has __type_traits, // libstdc++ v3, timestamp 20060306 (3.4.6) has __type_traits, // while libstdc++ v3, 20050921 (4.0.2) not; use libstdc++ instead -# if 1 /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ +# if defined(STLPORT) || (defined(__GNUC__) && (__GNUC__ < 4)) /* !defined(__GLIBCXX__) || (defined(__GNUC__) && (__GNUC__ < 4)) */ namespace std { @@ -49,11 +49,18 @@ static __t2 __test(...); public: - static const bool __value; // = sizeof(__test<_Tp>(0)) == 1; +#if defined(__GNUC__) && (__GNUC__ < 4) + static const bool __value; +#else + static const bool __value = sizeof(__test<_Tp>(0)) == 1; +#endif + }; +#if defined(__GNUC__) && (__GNUC__ < 4) template <class _Tp> const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == 1; +#endif template <class T> struct __uoc_aux : // union or class @@ -67,11 +74,17 @@ static __t2 __test(...); public: - static const bool __value; // = sizeof(__test<T>(0)) == 1; +#if defined(__GNUC__) && (__GNUC__ < 4) + static const bool __value; +#else + static const bool __value = sizeof(__test<T>(0)) == 1; +#endif }; +#if defined(__GNUC__) && (__GNUC__ < 4) template <class T> const bool __uoc_aux<T>::__value = sizeof(__uoc_aux<T>::__test<T>(0)) == 1; +#endif template <class T> class __empty @@ -624,7 +637,7 @@ } // namespace std -# else // __GLIBCXX__ && (__GNUC__ >= 4) +# else // __GLIBCXX__ && (__GNUC__ >= 4) && !STLPORT # include <tr1/type_traits> # endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:56:27
|
Revision: 1691 http://complement.svn.sourceforge.net/complement/?rev=1691&view=rev Author: complement Date: 2007-08-17 05:56:26 -0700 (Fri, 17 Aug 2007) Log Message: ----------- use correct namespace for hash specialization; clean signaling defines Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:43:35 UTC (rev 1690) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:56:26 UTC (rev 1691) @@ -41,8 +41,15 @@ } // namespace janus -namespace std { +#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +# define __HASH_NAMESPACE std +#endif +#ifdef __USE_STD_HASH +# define __HASH_NAMESPACE __gnu_cxx +#endif +namespace __HASH_NAMESPACE { + template <> struct hash<janus::oid_type> { @@ -50,8 +57,10 @@ { return __x.addr; } }; -} // namespace std +} // namespace __HASH_NAMESPACE +#undef __HASH_NAMESPACE + namespace janus { typedef uint32_t vtime_unit_type; @@ -448,6 +457,19 @@ #define VS_OUT_MEMBER 0x302 #define VS_SYNC_TIME 0x303 +#ifdef __USE_STLPORT_HASH +# undef __USE_STLPORT_HASH +#endif +#ifdef __USE_STD_HASH +# undef __USE_STD_HASH +#endif +#ifdef __USE_STLPORT_TR1 +# undef __USE_STLPORT_TR1 +#endif +#ifdef __USE_STD_TR1 +# undef __USE_STD_TR1 +#endif + } // namespace janus namespace std { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:43:37
|
Revision: 1690 http://complement.svn.sourceforge.net/complement/?rev=1690&view=rev Author: complement Date: 2007-08-17 05:43:35 -0700 (Fri, 17 Aug 2007) Log Message: ----------- typo Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:42:07 UTC (rev 1689) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:43:35 UTC (rev 1690) @@ -24,12 +24,7 @@ # define __USE_STD_TR1 # endif #endif - -#include <unordered_map> -#include <unordered_set> - #include <iterator> - #include <istream> #include <ostream> #include <stdexcept> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:42:09
|
Revision: 1689 http://complement.svn.sourceforge.net/complement/?rev=1689&view=rev Author: complement Date: 2007-08-17 05:42:07 -0700 (Fri, 17 Aug 2007) Log Message: ----------- made code acceptable for gcc 3.3 [remove inline initialization of statics in template] Modified Paths: -------------- trunk/complement/explore/include/misc/type_traits.h trunk/complement/explore/lib/misc/ChangeLog Modified: trunk/complement/explore/include/misc/type_traits.h =================================================================== --- trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:26:22 UTC (rev 1688) +++ trunk/complement/explore/include/misc/type_traits.h 2007-08-17 12:42:07 UTC (rev 1689) @@ -49,9 +49,12 @@ static __t2 __test(...); public: - static const bool __value = sizeof(__test<_Tp>(0)) == 1; + static const bool __value; // = sizeof(__test<_Tp>(0)) == 1; }; +template <class _Tp> +const bool __instance<_Tp>::__value = sizeof(__instance<_Tp>::__test<_Tp>(0)) == 1; + template <class T> struct __uoc_aux : // union or class public __select_types @@ -64,10 +67,13 @@ static __t2 __test(...); public: - static const bool __value = sizeof(__test<T>(0)) == 1; + static const bool __value; // = sizeof(__test<T>(0)) == 1; }; template <class T> +const bool __uoc_aux<T>::__value = sizeof(__uoc_aux<T>::__test<T>(0)) == 1; + +template <class T> class __empty { }; Modified: trunk/complement/explore/lib/misc/ChangeLog =================================================================== --- trunk/complement/explore/lib/misc/ChangeLog 2007-08-17 12:26:22 UTC (rev 1688) +++ trunk/complement/explore/lib/misc/ChangeLog 2007-08-17 12:42:07 UTC (rev 1689) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * type_traits.h: made code acceptable for gcc 3.3 [remove + inline initialization of statics in template]. + 2007-08-03 Petr Ovtchenkov <pt...@is...> * type_traits.h: select appropriate TR1 type_traits implementation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 12:26:24
|
Revision: 1688 http://complement.svn.sourceforge.net/complement/?rev=1688&view=rev Author: complement Date: 2007-08-17 05:26:22 -0700 (Fri, 17 Aug 2007) Log Message: ----------- use available variant of hash_map/hash_set or unordered_map/unordered_set Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ChangeLog Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-17 11:16:43 UTC (rev 1687) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 12:26:22 UTC (rev 1688) @@ -6,8 +6,28 @@ #include <algorithm> #include <list> #include <vector> -#include <hash_map> -#include <hash_set> +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + +#include <unordered_map> +#include <unordered_set> + #include <iterator> #include <istream> @@ -41,7 +61,15 @@ typedef uint32_t vtime_unit_type; typedef stem::addr_type group_type; // required, used in VTSend +#ifdef __USE_STLPORT_HASH typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; +#endif +#ifdef __USE_STD_HASH +typedef __gnu_cxx::hash_map<oid_type, vtime_unit_type> vtime_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +typedef std::tr1::unordered_map<oid_type, vtime_unit_type> vtime_type; +#endif bool operator <=( const vtime_type& l, const vtime_type& r ); inline bool operator >=( const vtime_type& l, const vtime_type& r ) @@ -115,7 +143,15 @@ // typedef std::pair<group_type, vtime> vtime_group_type; // typedef std::list<vtime_group_type> gvtime_type; +#ifdef __USE_STLPORT_HASH typedef std::hash_map<group_type, vtime> gvtime_type; +#endif +#ifdef __USE_STD_HASH +typedef __gnu_cxx::hash_map<group_type, vtime> gvtime_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +typedef std::tr1::unordered_map<group_type, vtime> gvtime_type; +#endif gvtime_type& operator +=( gvtime_type&, const gvtime_type::value_type& ); gvtime_type& operator +=( gvtime_type&, const gvtime_type& ); @@ -247,9 +283,21 @@ #endif private: +#ifdef __USE_STLPORT_HASH typedef std::hash_set<group_type> groups_container_type; typedef std::hash_map<oid_type, gvtime_type> delta_vtime_type; typedef std::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_set<group_type> groups_container_type; + typedef __gnu_cxx::hash_map<oid_type, gvtime_type> delta_vtime_type; + typedef __gnu_cxx::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_set<group_type> groups_container_type; + typedef std::tr1::unordered_map<oid_type, gvtime_type> delta_vtime_type; + typedef std::tr1::unordered_map<oid_type, gvtime_type> snd_delta_vtime_t; +#endif stem::addr_type addr; // stem address of object delta_vtime_type lvt; // last recieve VT from neighbours @@ -324,9 +372,19 @@ unsigned trflags() const; void settrs( std::ostream * ); - private: + private: +#ifdef __USE_STLPORT_HASH typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef __gnu_cxx::hash_multimap<group_type, oid_type> gid_map_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_map<oid_type, detail::vtime_obj_rec> vt_map_type; + typedef std::tr1::unordered_multimap<group_type, oid_type> gid_map_type; +#endif void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); void check_and_send_delayed( detail::vtime_obj_rec& ); Modified: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog 2007-08-17 11:16:43 UTC (rev 1687) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-08-17 12:26:22 UTC (rev 1688) @@ -1,3 +1,8 @@ +2007-08-17 Petr Ovtchenkov <ye...@ya...> + + * vtime.h: use available variant of hash_map/hash_set or + unordered_map/unordered_set. + 2007-08-17 Petr Ovtchenkov <pt...@is...> * vtime.cc, vtime.h: namespace vt moved to janus; VTDispatcher This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 11:16:45
|
Revision: 1687 http://complement.svn.sourceforge.net/complement/?rev=1687&view=rev Author: complement Date: 2007-08-17 04:16:43 -0700 (Fri, 17 Aug 2007) Log Message: ----------- use ${CXXFLAGS} when detect position of files and libraries; this useful for multilib gcc configuration, when something like -m32 select libraries family. Modified Paths: -------------- trunk/complement/explore/Makefiles/ChangeLog trunk/complement/explore/Makefiles/gmake/app/gcc.mak trunk/complement/explore/Makefiles/gmake/lib/gcc.mak Modified: trunk/complement/explore/Makefiles/ChangeLog =================================================================== --- trunk/complement/explore/Makefiles/ChangeLog 2007-08-17 07:42:35 UTC (rev 1686) +++ trunk/complement/explore/Makefiles/ChangeLog 2007-08-17 11:16:43 UTC (rev 1687) @@ -1,3 +1,10 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * gmake/app/gcc.mak, gmake/lib/gcc.mak: use ${CXXFLAGS} when + detect position of files and libraries; this useful for + multilib gcc configuration, when something like -m32 select + libraries family. + 2007-08-08 Petr Ovtchenkov <pt...@is...> * gmake/app/rules.mak: use special link string for Digital Mars Modified: trunk/complement/explore/Makefiles/gmake/app/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2007-08-17 07:42:35 UTC (rev 1686) +++ trunk/complement/explore/Makefiles/gmake/app/gcc.mak 2007-08-17 11:16:43 UTC (rev 1687) @@ -83,7 +83,7 @@ ifdef _USE_NOSTDLIB # Check whether gcc builded with --disable-shared -ifeq ($(shell ${CXX} -print-file-name=libgcc_eh.a),libgcc_eh.a) +ifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_eh.a),libgcc_eh.a) # gcc builded with --disable-shared, (no library libgcc_eh.a); all exception support in libgcc.a _LGCC_EH := _LGCC_S := -lgcc @@ -102,30 +102,30 @@ # ifeq ($(CXX_VERSION_MAJOR),3) ifeq ($(OSNAME),linux) -START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),openbsd) -START_OBJ := $(shell for o in crt0.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crt0.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),freebsd) # FreeBSD < 5.3 should use -lc_r, while FreeBSD >= 5.3 use -lpthread PTHR := $(shell if [ ${OSREL_MAJOR} -gt 5 ] ; then echo "pthread" ; else if [ ${OSREL_MAJOR} -lt 5 ] ; then echo "c_r" ; else if [ ${OSREL_MINOR} -lt 3 ] ; then echo "c_r" ; else echo "pthread"; fi ; fi ; fi) -START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -l${PTHR} -lc -lm endif ifeq ($(OSNAME),netbsd) -START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),sunos) -START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),darwin) Modified: trunk/complement/explore/Makefiles/gmake/lib/gcc.mak =================================================================== --- trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-17 07:42:35 UTC (rev 1686) +++ trunk/complement/explore/Makefiles/gmake/lib/gcc.mak 2007-08-17 11:16:43 UTC (rev 1687) @@ -93,7 +93,7 @@ NOSTDLIB := # Check whether gcc builded with --disable-shared -ifeq ($(shell ${CXX} -print-file-name=libgcc_eh.a),libgcc_eh.a) +ifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_eh.a),libgcc_eh.a) # gcc builded with --disable-shared, (no library libgcc_eh.a); all exception support in libgcc.a _LGCC_EH := _LGCC_S := -lgcc @@ -114,31 +114,31 @@ # Include whole language support archive (libsupc++.a) into libstlport: # all C++ issues are in libstlport now. ifeq ($(OSNAME),linux) -START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) #START_A_OBJ := $(shell for o in crti.o crtbeginT.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),openbsd) -START_OBJ := $(shell for o in crtbeginS.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtendS.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtendS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),freebsd) # FreeBSD < 5.3 should use -lc_r, while FreeBSD >= 5.3 use -lpthread PTHR := $(shell if [ ${OSREL_MAJOR} -gt 5 ] ; then echo "pthread" ; else if [ ${OSREL_MAJOR} -lt 5 ] ; then echo "c_r" ; else if [ ${OSREL_MINOR} -lt 3 ] ; then echo "c_r" ; else echo "pthread"; fi ; fi ; fi) -START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS := ${STLPORT_LIB} ${_LGCC_S} -l${PTHR} -lc -lm endif ifeq ($(OSNAME),netbsd) -START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm endif ifeq ($(OSNAME),sunos) -START_OBJ := $(shell for o in crti.o crtbegin.o; do ${CXX} -print-file-name=$$o; done) -END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} -print-file-name=$$o; done) +START_OBJ := $(shell for o in crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) +END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) STDLIBS := ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm -lrt endif ifeq ($(OSNAME),darwin) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 07:42:39
|
Revision: 1686 http://complement.svn.sourceforge.net/complement/?rev=1686&view=rev Author: complement Date: 2007-08-17 00:42:35 -0700 (Fri, 17 Aug 2007) Log Message: ----------- chronicle Added Paths: ----------- trunk/complement/explore/lib/janus/ChangeLog Added: trunk/complement/explore/lib/janus/ChangeLog =================================================================== --- trunk/complement/explore/lib/janus/ChangeLog (rev 0) +++ trunk/complement/explore/lib/janus/ChangeLog 2007-08-17 07:42:35 UTC (rev 1686) @@ -0,0 +1,91 @@ +2007-08-17 Petr Ovtchenkov <pt...@is...> + + * vtime.cc, vtime.h: namespace vt moved to janus; VTDispatcher + renamed to Janus; VTmess renamed to VSmess. + +2007-08-16 Petr Ovtchenkov <pt...@is...> + + * Repository: step to interprocess virtual synchrony; + experiments with virtual synchrony ready for library + [janus subproject] and moved from tests to lib/janus. + +2007-08-13 Petr Ovtchenkov <pt...@is...> + + * Repository: entrance into group looks fine. + +2007-08-03 Petr Ovtchenkov <pt...@is...> + + * vtime.h, vtime.cc: subscribe/unsubscribe operations for VTHandler; + + * test/Makefile, test/Makefile.inc, test/vt_handler.cc: test for above; + + * test/vt_operations.h: ditto. + +2007-07-27 Petr Ovtchenkov <pt...@is...> + + * vtime.h, vtime.cc: add lock to VTSend in VTDispatcher; + replace oid_type from POD to stem::gaddr_type. + + * test/VTmess_core.cc, test/vt_dispatch.cc: idem; + + * test/vt_object.cc, test/vt_operations.cc: idem; + + * test/VTmess_core.cc, test/vt_dispatch.cc: add constructors + with reasonable defaults for gaddr_type; + + * test/vt_object.cc, test/vt_operations.cc: idem. + +2007-07-26 Petr Ovtchenkov <pt...@is...> + + * test/Makefile.inc, test/unit_test.cc: split unit tests; + + * test/VTmess_core.cc, vt_dispatch.cc, vt_object.cc: ditto; + + * test/vt_operations.cc, vt_operations.h: ditto; + + * vtime.h, vtime.cc: looks like VTDispatcher work; + + * test/unit_test.cc, test/vt_dispatch.cc, test/vt_operations.h: + check dispatch in group of two first, then in group of three: this + has difference from algo point of view; + + * vtime.h, vtime.cc, test/vt_object.cc: hide implementation details. + +2007-07-26 Petr Ovtchenkov <ye...@ya...> + + * vtime.h, vtime.cc: store VT stamp for sended events per-object, + not per-group (to allow individual repeats, restore and gossip + in the future); + +2007-07-25 Petr Ovtchenkov <pt...@is...> + + * test/unit_test.cc: more information checked within unit test; + + * vtime.h, vtime.cc: evolution of VTDispatch; VTDispatcher development. + +2007-07-24 Petr Ovtchenkov <pt...@is...> + + * test/unit_test.cc: test for delivery VT message established; + +2007-07-24 Petr Ovtchenkov <ye...@ya...> + + * vtime.h, vtime.cc: throw exception, if message has no chance + to be delivered. + +2007-07-20 Petr Ovtchenkov <pt...@is...> + + * test/Makefile, test/unit_test.cc: unit test based on exam; + +2007-07-20 Petr Ovtchenkov <ye...@ya...> + + * vtime.h, vtime.cc: fix VTmess copy constructor; add operation >=. + +2007-06-06 Petr Ovtchenkov <pt...@is...> + + * Repository: first working. + +2007-05-16 Petr Ovtchenkov <ye...@ya...> + + * Repository: start of Virtual Time (Virtual Synchrony) exploration, + on base of infrastructure and tools of 'complement' project. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 07:29:57
|
Revision: 1685 http://complement.svn.sourceforge.net/complement/?rev=1685&view=rev Author: complement Date: 2007-08-17 00:29:48 -0700 (Fri, 17 Aug 2007) Log Message: ----------- typo Modified Paths: -------------- trunk/complement/explore/lib/mt/ChangeLog Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2007-08-17 06:47:44 UTC (rev 1684) +++ trunk/complement/explore/lib/mt/ChangeLog 2007-08-17 07:29:48 UTC (rev 1685) @@ -374,7 +374,7 @@ 2003-01-07 Petr Ovtchenkov <pt...@Is...> * xmt.h, xmt.cc: add delay function (sleep for interval - of time); fix wrong time conversion for Win in sleep. + of time); fix wrong time conversion for Win in sleep. 2002-09-25 Petr Ovtchenkov <pt...@Is...> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-17 06:47:46
|
Revision: 1684 http://complement.svn.sourceforge.net/complement/?rev=1684&view=rev Author: complement Date: 2007-08-16 23:47:44 -0700 (Thu, 16 Aug 2007) Log Message: ----------- namespace vt -> janus; VTDispatcher -> Janus; VTmess -> VSmess Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_object.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vtime.cc Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:05:47 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:38:35 ptr> #ifndef __vtime_h #define __vtime_h @@ -19,25 +19,25 @@ #include <mt/time.h> -namespace vt { +namespace janus { // typedef stem::addr_type oid_type; typedef stem::gaddr_type oid_type; -} // namespace vt +} // namespace janus namespace std { template <> -struct hash<vt::oid_type> +struct hash<janus::oid_type> { - size_t operator()(const vt::oid_type& __x) const + size_t operator()(const janus::oid_type& __x) const { return __x.addr; } }; } // namespace std -namespace vt { +namespace janus { typedef uint32_t vtime_unit_type; typedef stem::addr_type group_type; // required, used in VTSend @@ -188,7 +188,7 @@ gvtime gvt; }; -struct VTmess : +struct VSmess : public VSsync { void pack( std::ostream& s ) const; @@ -196,11 +196,11 @@ void unpack( std::istream& s ); void net_unpack( std::istream& s ); - VTmess() : + VSmess() : code(0), src() { } - VTmess( const VTmess& _gvt ) : + VSmess( const VSmess& _gvt ) : VSsync( _gvt ), code( _gvt.code ), src( _gvt.src ) @@ -229,9 +229,9 @@ stem::addr_type stem_addr() const { return addr; } - bool deliver( const VTmess& ev ); - bool deliver_delayed( const VTmess& ev ); - std::ostream& trace_deliver( const VTmess& m, std::ostream& o ); + bool deliver( const VSmess& ev ); + bool deliver_delayed( const VSmess& ev ); + std::ostream& trace_deliver( const VSmess& m, std::ostream& o ); void next( const oid_type& from, group_type grp ) { ++vt.gvt[grp][from]; /* increment my VT counter */ } void delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ); @@ -260,19 +260,19 @@ public: // delay pool should be here - typedef std::pair<xmt::timespec,stem::Event_base<VTmess>*> delay_item_t; + typedef std::pair<xmt::timespec,stem::Event_base<VSmess>*> delay_item_t; typedef std::list<delay_item_t> dpool_t; dpool_t dpool; private: - bool order_correct( const VTmess& ); - bool order_correct_delayed( const VTmess& ); + bool order_correct( const VSmess& ); + bool order_correct_delayed( const VSmess& ); }; } // namespace detail -class VTDispatcher : +class Janus : public stem::EventHandler { public: @@ -285,32 +285,32 @@ tracegroup = 0x10 }; - VTDispatcher() : + Janus() : _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( const char *info ) : + Janus( const char *info ) : stem::EventHandler( info ), _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( stem::addr_type id ) : + Janus( stem::addr_type id ) : stem::EventHandler( id ), _trflags( notrace ), _trs( 0 ) { } - VTDispatcher( stem::addr_type id, const char *info ) : + Janus( stem::addr_type id, const char *info ) : stem::EventHandler( id, info ), _trflags( notrace ), _trs( 0 ) { } - void VTDispatch( const stem::Event_base<VTmess>& ); + void JaDispatch( const stem::Event_base<VSmess>& ); - void VTSend( const stem::Event& e, group_type ); + void JaSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); void Unsubscribe( oid_type, group_type ); void Unsubscribe( oid_type ); @@ -328,7 +328,7 @@ typedef std::hash_map<oid_type, detail::vtime_obj_rec> vt_map_type; typedef std::hash_multimap<group_type, oid_type> gid_map_type; - void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); + void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VSmess>& ); void check_and_send_delayed( detail::vtime_obj_rec& ); vt_map_type vtmap; @@ -338,7 +338,7 @@ unsigned _trflags; std::ostream *_trs; - DECLARE_RESPONSE_TABLE( VTDispatcher, stem::EventHandler ); + DECLARE_RESPONSE_TABLE( Janus, stem::EventHandler ); }; class VTHandler : @@ -363,7 +363,7 @@ explicit VTHandler( stem::addr_type id, const char *info = 0 ); virtual ~VTHandler(); - void VTSend( const stem::Event& e ); + void JaSend( const stem::Event& e ); void JoinGroup( group_type grp ) { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); @@ -371,11 +371,11 @@ virtual void VSsync_time( const stem::Event_base<VSsync>& ); - template <class D> - void VTSend( const stem::Event_base<D>& e ) - { VTHandler::VTSend( stem::Event_convert<D>()( e ) ); } + // template <class D> + // void JaSend( const stem::Event_base<D>& e ) + // { VTHandler::JaSend( stem::Event_convert<D>()( e ) ); } - static VTDispatcher *vtdispatcher() + static Janus *vtdispatcher() { return _vtdsp; } protected: @@ -385,7 +385,7 @@ { _vtdsp->get_gvtime( g, self_id(), gvt ); } private: - static class VTDispatcher *_vtdsp; + static class Janus *_vtdsp; DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); }; @@ -395,18 +395,18 @@ #define VS_OUT_MEMBER 0x302 #define VS_SYNC_TIME 0x303 -} // namespace vt +} // namespace janus namespace std { -ostream& operator <<( ostream&, const vt::vtime_type::value_type& ); -ostream& operator <<( ostream&, const vt::vtime_type& ); -ostream& operator <<( ostream&, const vt::vtime& ); -ostream& operator <<( ostream&, const vt::gvtime_type::value_type& ); -ostream& operator <<( ostream&, const vt::gvtime_type& ); -ostream& operator <<( ostream&, const vt::gvtime& ); -ostream& operator <<( ostream& o, const vt::VSsync& ); -ostream& operator <<( ostream& o, const vt::VTmess& ); +ostream& operator <<( ostream&, const janus::vtime_type::value_type& ); +ostream& operator <<( ostream&, const janus::vtime_type& ); +ostream& operator <<( ostream&, const janus::vtime& ); +ostream& operator <<( ostream&, const janus::gvtime_type::value_type& ); +ostream& operator <<( ostream&, const janus::gvtime_type& ); +ostream& operator <<( ostream&, const janus::gvtime& ); +ostream& operator <<( ostream& o, const janus::VSsync& ); +ostream& operator <<( ostream& o, const janus::VSmess& ); } // namespace std Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,11 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/25 22:06:40 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:20:54 ptr> #include "vt_operations.h" #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; class VTM_handler : @@ -17,8 +17,8 @@ VTM_handler( stem::addr_type id, const char *info ); ~VTM_handler(); - void handlerE( const stem::Event_base<VTmess>& ); - void handlerV( const VTmess& ); + void handlerE( const stem::Event_base<VSmess>& ); + void handlerV( const VSmess& ); void wait(); @@ -59,7 +59,7 @@ // cnd.wait(); } -void VTM_handler::handlerE( const stem::Event_base<VTmess>& ev ) +void VTM_handler::handlerE( const stem::Event_base<VSmess>& ev ) { code = ev.value().code; src = ev.value().src; @@ -71,7 +71,7 @@ cnd.set( true ); } -void VTM_handler::handlerV( const VTmess& m ) +void VTM_handler::handlerV( const VSmess& m ) { code = m.code; src = m.src; @@ -91,8 +91,8 @@ } DEFINE_RESPONSE_TABLE( VTM_handler ) - EV_Event_base_T_( ST_NULL, VT_MESS, handlerE, VTmess ) - EV_T_( 1, VT_MESS, handlerV, VTmess ) + EV_Event_base_T_( ST_NULL, VT_MESS, handlerE, VSmess ) + EV_T_( 1, VT_MESS, handlerV, VSmess ) END_RESPONSE_TABLE int EXAM_IMPL(vtime_operations::VTMess_core) @@ -103,7 +103,7 @@ VTM_handler h; - stem::Event_base<VTmess> ev( VT_MESS ); + stem::Event_base<VSmess> ev( VT_MESS ); ev.dest( h.self_id() ); ev.value().code = 2; Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:39:45 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; class Dummy : @@ -75,7 +73,7 @@ int EXAM_IMPL(vtime_operations::VTDispatch1) { - vt::VTDispatcher dsp; + janus::Janus dsp; Dummy dummy1; Dummy dummy2; const oid_type t1(1); @@ -89,7 +87,7 @@ ev.value() = "hello"; - dsp.VTSend( ev, 0 ); + dsp.JaSend( ev, 0 ); dummy2.wait(); @@ -101,7 +99,7 @@ int EXAM_IMPL(vtime_operations::VTDispatch2) { - vt::VTDispatcher dsp; + janus::Janus dsp; Dummy dummy1; Dummy dummy2; Dummy dummy3; @@ -118,7 +116,7 @@ ev.value() = "hello"; - dsp.VTSend( ev, 0 ); + dsp.JaSend( ev, 0 ); dummy2.wait(); dummy3.wait(); Modified: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,19 +1,17 @@ -// -*- C++ -*- Time-stamp: <07/08/11 23:21:59 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:41:22 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> #include <stem/EvManager.h> -using namespace vt; +using namespace janus; using namespace std; class VTDummy : - public vt::VTHandler + public janus::VTHandler { public: VTDummy(); @@ -42,7 +40,7 @@ xmt::condition cnd; xmt::condition gr; - DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); + DECLARE_RESPONSE_TABLE( VTDummy, janus::VTHandler ); }; #define VS_DUMMY_MESS 0x1203 @@ -138,7 +136,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); @@ -158,7 +156,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -172,7 +170,7 @@ ev.dest( 100 ); // not this group member try { - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); EXAM_ERROR( "exception expected" ); } catch ( std::domain_error& ) { @@ -190,7 +188,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -199,7 +197,7 @@ VTDummy dummy3; ev.value() = "hi"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); // dummy3.wait(); @@ -211,7 +209,7 @@ } ev.value() = "yet more"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "yet more" ); @@ -240,7 +238,7 @@ dummy3.wait_greeting(); ev.value() = "hi"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy3.wait(); @@ -260,7 +258,7 @@ ev.dest( 0 ); // group ev.value() = "hello"; - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -280,7 +278,7 @@ ev.value() = "hi"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -306,7 +304,7 @@ ev.value() = "hello"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); EXAM_CHECK( dummy2.msg == "hello" ); @@ -320,7 +318,7 @@ ev.value() = "hi"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy3.wait(); @@ -337,7 +335,7 @@ ev.value() = "more"; ev.dest( 0 ); // group - dummy1.VTSend( ev ); + dummy1.JaSend( ev ); dummy2.wait(); dummy3.wait(); @@ -346,7 +344,7 @@ EXAM_CHECK( dummy3.msg == "more" ); EXAM_CHECK( dummy1.msg == "" ); - dummy2.VTSend( ev ); + dummy2.JaSend( ev ); dummy1.wait(); } Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/25 22:09:32 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:21:34 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; int EXAM_IMPL(vtime_operations::vt_object) @@ -29,8 +27,8 @@ // gvtime gvt; // gvt[gr0][obj1] = 1; - VTmess mess; - VTmess mess_bad; + VSmess mess; + VSmess mess_bad; mess_bad.code = mess.code = 1; mess_bad.src = mess.src = obj1; @@ -90,7 +88,7 @@ // ---- - VTmess mess2; + VSmess mess2; mess2.code = 1; mess2.src = obj2; @@ -158,7 +156,7 @@ // cerr << ob.vt[gr0] << endl; // cerr << "===========\n"; - VTmess mess3; + VSmess mess3; mess3.code = 1; mess3.src = obj2; Modified: trunk/complement/explore/lib/janus/ut/vt_operations.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,13 +1,11 @@ -// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:06:23 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> -using namespace vt; +using namespace janus; using namespace std; int EXAM_IMPL(vtime_operations::vt_compare) @@ -180,7 +178,7 @@ vt1[t2] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -188,7 +186,7 @@ vt2[t1] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -196,7 +194,7 @@ vt2[t2] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); EXAM_CHECK( vt3 <= vt1 ); EXAM_CHECK( vt1 <= vt3 ); @@ -204,7 +202,7 @@ vt2[t3] = 1; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t1] = 1; vt4[t2] = 1; @@ -221,7 +219,7 @@ vt4.clear(); vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t1] = 1; vt4[t2] = 2; @@ -232,7 +230,7 @@ vt2[t3] = 4; vt3 = vt1; - vt::sup( vt3, vt2 ); + janus::sup( vt3, vt2 ); vt4[t3] = 4; Modified: trunk/complement/explore/lib/janus/ut/vt_remote.cc =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,9 +1,7 @@ -// -*- C++ -*- Time-stamp: <07/08/16 10:45:48 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:07:52 ptr> #include "vt_operations.h" -// #include <boost/lexical_cast.hpp> - #include <iostream> #include <janus/vtime.h> @@ -18,10 +16,10 @@ using namespace std; using namespace stem; using namespace xmt; -using namespace vt; +using namespace janus; class YaRemote : - public vt::VTHandler + public janus::VTHandler { public: YaRemote(); @@ -50,7 +48,7 @@ xmt::condition cnd; xmt::condition gr; - DECLARE_RESPONSE_TABLE( YaRemote, vt::VTHandler ); + DECLARE_RESPONSE_TABLE( YaRemote, janus::VTHandler ); }; #define VS_DUMMY_MESS 0x1203 Modified: trunk/complement/explore/lib/janus/vtime.cc =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc 2007-08-16 19:20:06 UTC (rev 1683) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-17 06:47:44 UTC (rev 1684) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:10:59 ptr> +// -*- C++ -*- Time-stamp: <07/08/17 10:39:02 ptr> #include <janus/vtime.h> @@ -6,7 +6,7 @@ #include <stdint.h> #include <stem/EvManager.h> -namespace vt { +namespace janus { using namespace std; using namespace xmt; @@ -152,28 +152,28 @@ VSsync_rq::net_unpack( s ); } -void VTmess::pack( std::ostream& s ) const +void VSmess::pack( std::ostream& s ) const { __pack( s, code ); src.pack( s ); // __pack( s, src ); VSsync::pack( s ); } -void VTmess::net_pack( std::ostream& s ) const +void VSmess::net_pack( std::ostream& s ) const { __net_pack( s, code ); src.net_pack( s ); // __net_pack( s, src ); VSsync::net_pack( s ); } -void VTmess::unpack( std::istream& s ) +void VSmess::unpack( std::istream& s ) { __unpack( s, code ); src.unpack( s ); // __unpack( s, src ); VSsync::unpack( s ); } -void VTmess::net_unpack( std::istream& s ) +void VSmess::net_unpack( std::istream& s ) { __net_unpack( s, code ); src.net_unpack( s ); // __net_unpack( s, src ); @@ -349,7 +349,7 @@ namespace detail { -bool vtime_obj_rec::deliver( const VTmess& m ) +bool vtime_obj_rec::deliver( const VSmess& m ) { if ( order_correct( m ) ) { lvt[m.src] += m.gvt.gvt; @@ -361,7 +361,7 @@ return false; } -bool vtime_obj_rec::deliver_delayed( const VTmess& m ) +bool vtime_obj_rec::deliver_delayed( const VSmess& m ) { if ( order_correct_delayed( m ) ) { lvt[m.src] += m.gvt.gvt; @@ -373,17 +373,17 @@ return false; } -bool vtime_obj_rec::order_correct( const VTmess& m ) +bool vtime_obj_rec::order_correct( const VSmess& m ) { if ( groups.find( m.grp ) == groups.end() ) { - throw domain_error( "VT object not member of group" ); + throw domain_error( "virtual synchrony object not member of group" ); } gvtime gvt( m.gvt ); if ( (vt.gvt[m.grp][m.src] + 1) != gvt[m.grp][m.src] ) { if ( (vt.gvt[m.grp][m.src] + 1) > gvt[m.grp][m.src] ) { - throw out_of_range( "duplicate or wrong VT message" ); + throw out_of_range( "duplicate or wrong virtual synchrony message" ); } return false; } @@ -405,10 +405,10 @@ return true; } -ostream& vtime_obj_rec::trace_deliver( const VTmess& m, ostream& o ) +ostream& vtime_obj_rec::trace_deliver( const VSmess& m, ostream& o ) { if ( groups.find( m.grp ) == groups.end() ) { - return o << "VT object not member of group"; + return o << "virtual synchrony object not member of group"; } gvtime gvt( m.gvt ); @@ -437,7 +437,7 @@ return o << "should be delivered"; } -bool vtime_obj_rec::order_correct_delayed( const VTmess& m ) +bool vtime_obj_rec::order_correct_delayed( const VSmess& m ) { gvtime gvt( m.gvt ); @@ -473,7 +473,7 @@ // strike out group g from my groups list groups_container_type::iterator i = groups.find( g ); if ( i == groups.end() ) { - throw domain_error( "VT object not member of group" ); + throw domain_error( "virtual synchrony object not member of group" ); } groups.erase( i ); @@ -543,44 +543,44 @@ } // namespace detail -void VTDispatcher::settrf( unsigned f ) +void Janus::settrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags |= f; } -void VTDispatcher::unsettrf( unsigned f ) +void Janus::unsettrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags &= (0xffffffff & ~f); } -void VTDispatcher::resettrf( unsigned f ) +void Janus::resettrf( unsigned f ) { scoped_lock _x1( _lock_tr ); _trflags = f; } -void VTDispatcher::cleantrf() +void Janus::cleantrf() { scoped_lock _x1( _lock_tr ); _trflags = 0; } -unsigned VTDispatcher::trflags() const +unsigned Janus::trflags() const { scoped_lock _x1( _lock_tr ); return _trflags; } -void VTDispatcher::settrs( std::ostream *s ) +void Janus::settrs( std::ostream *s ) { scoped_lock _x1( _lock_tr ); _trs = s; } -void VTDispatcher::VTDispatch( const stem::Event_base<VTmess>& m ) +void Janus::JaDispatch( const stem::Event_base<VSmess>& m ) { pair<gid_map_type::const_iterator,gid_map_type::const_iterator> range = grmap.equal_range( m.value().grp ); @@ -621,7 +621,7 @@ } } -void VTDispatcher::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VTmess>& m ) +void Janus::check_and_send( detail::vtime_obj_rec& vt, const stem::Event_base<VSmess>& m ) { if ( vt.deliver( m.value() ) ) { stem::Event ev( m.value().code ); @@ -651,11 +651,11 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VTmess>(m) ) ); // 0 should be timestamp + vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VSmess>(m) ) ); // 0 should be timestamp } } -void VTDispatcher::check_and_send_delayed( detail::vtime_obj_rec& vt ) +void Janus::check_and_send_delayed( detail::vtime_obj_rec& vt ) { typedef detail::vtime_obj_rec::dpool_t dpool_t; bool more; @@ -700,7 +700,7 @@ } while ( more ); } -void VTDispatcher::VTSend( const stem::Event& e, group_type grp ) +void Janus::JaSend( 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: @@ -714,7 +714,7 @@ if ( i != vtmap.end() && i->second.stem_addr() == e.src() ) { // for self detail::vtime_obj_rec& vt = i->second; const oid_type& from = o->second; - stem::Event_base<VTmess> m( VS_MESS ); + stem::Event_base<VSmess> m( VS_MESS ); m.value().src = from; // oid m.value().code = e.code(); m.value().mess = e.value(); @@ -787,7 +787,7 @@ throw domain_error( "VT object not member of group" ); // Error: not group member } -void VTDispatcher::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) +void Janus::Subscribe( stem::addr_type addr, oid_type oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -820,7 +820,7 @@ grmap.insert( make_pair(grp,oid) ); } -void VTDispatcher::Unsubscribe( oid_type oid, group_type grp ) +void Janus::Unsubscribe( oid_type oid, group_type grp ) { // See comment on top of VTSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); @@ -863,9 +863,9 @@ } } -void VTDispatcher::Unsubscribe( oid_type oid ) +void Janus::Unsubscribe( oid_type oid ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); vt_map_type::iterator i = vtmap.find( oid ); @@ -909,9 +909,9 @@ } } -void VTDispatcher::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) +void Janus::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); pair<gid_map_type::iterator,gid_map_type::iterator> range = @@ -927,18 +927,18 @@ try { scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; } } catch ( ... ) { } - throw domain_error( "VT object not member of group" ); // Error: not group member + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member } -void VTDispatcher::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) +void Janus::set_gvtime( group_type grp, stem::addr_type addr, const gvtime_type& gvt ) { - // See comment on top of VTSend above + // See comment on top of JaSend above xmt::recursive_scoped_lock lk( this->_theHistory_lock ); pair<gid_map_type::iterator,gid_map_type::iterator> range = @@ -966,21 +966,21 @@ try { scoped_lock lk(_lock_tr); if ( _trs != 0 && _trs->good() && (_trflags & tracefault) ) { - *_trs << "VT object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; + *_trs << "virtual synchrony object not member of group" << " " << __FILE__ << ":" << __LINE__ << endl; } } catch ( ... ) { } - throw domain_error( "VT object not member of group" ); // Error: not group member + throw domain_error( "virtual synchrony object not member of group" ); // Error: not group member } -DEFINE_RESPONSE_TABLE( VTDispatcher ) - EV_Event_base_T_( ST_NULL, VS_MESS, VTDispatch, VTmess ) +DEFINE_RESPONSE_TABLE( Janus ) + EV_Event_base_T_( ST_NULL, VS_MESS, JaDispatch, VSmess ) END_RESPONSE_TABLE char *Init_buf[128]; -VTDispatcher *VTHandler::_vtdsp = 0; +Janus *VTHandler::_vtdsp = 0; static int *_rcount = 0; void VTHandler::Init::__at_fork_prepare() @@ -1013,7 +1013,7 @@ _rcount = &_count; pthread_atfork( __at_fork_prepare, __at_fork_parent, __at_fork_child ); #endif - VTHandler::_vtdsp = new VTDispatcher( 2, "vtd" ); + VTHandler::_vtdsp = new Janus( 2, "vtd" ); } } else { --_count; @@ -1030,10 +1030,10 @@ VTHandler::Init::~Init() { _guard( 0 ); } -void VTHandler::VTSend( const stem::Event& ev ) +void VTHandler::JaSend( const stem::Event& ev ) { ev.src( self_id() ); - _vtdsp->VTSend( ev, ev.dest() ); // throw domain_error, if not group member + _vtdsp->JaSend( ev, ev.dest() ); // throw domain_error, if not group member } VTHandler::VTHandler() : @@ -1112,14 +1112,14 @@ namespace std { -ostream& operator <<( ostream& o, const vt::vtime_type::value_type& v ) +ostream& operator <<( ostream& o, const janus::vtime_type::value_type& v ) { return o << "(" << v.first << "," << v.second << ")"; } -ostream& operator <<( ostream& o, const vt::vtime_type& v ) +ostream& operator <<( ostream& o, const janus::vtime_type& v ) { - for ( vt::vtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { + for ( janus::vtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { if ( i != v.begin() ) { o << ", "; } @@ -1128,29 +1128,29 @@ return o; } -ostream& operator <<( ostream& o, const vt::vtime& v ) +ostream& operator <<( ostream& o, const janus::vtime& v ) { return o << v.vt; } -ostream& operator <<( ostream& o, const vt::gvtime_type::value_type& v ) +ostream& operator <<( ostream& o, const janus::gvtime_type::value_type& v ) { o << v.first << ": " << v.second.vt; } -ostream& operator <<( ostream& o, const vt::gvtime_type& v ) +ostream& operator <<( ostream& o, const janus::gvtime_type& v ) { o << "{\n"; - for ( vt::gvtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { + for ( janus::gvtime_type::const_iterator i = v.begin(); i != v.end(); ++i ) { o << "\t" << *i << "\n"; } return o << "}\n"; } -ostream& operator <<( ostream& o, const vt::gvtime& v ) +ostream& operator <<( ostream& o, const janus::gvtime& v ) { return o << v.gvt; } -ostream& operator <<( ostream& o, const vt::VSsync& m ) +ostream& operator <<( ostream& o, const janus::VSsync& m ) { // ios_base::fmtflags f = o.flags( ios_base::hex ); o << "G" << m.grp << " " << m.gvt; @@ -1158,13 +1158,13 @@ return o; } -ostream& operator <<( ostream& o, const vt::VTmess& m ) +ostream& operator <<( ostream& o, const janus::VSmess& m ) { ios_base::fmtflags f = o.flags( ios_base::hex | ios_base::showbase ); - o << "C" << m.code << dec << " " << m.src << " " << static_cast<const vt::VSsync&>(m); + o << "C" << m.code << dec << " " << m.src << " " << static_cast<const janus::VSsync&>(m); o.flags( f ); return o; } -} // namespace std +} // namespace janus This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-16 19:20:12
|
Revision: 1683 http://complement.svn.sourceforge.net/complement/?rev=1683&view=rev Author: complement Date: 2007-08-16 12:20:06 -0700 (Thu, 16 Aug 2007) Log Message: ----------- experiments with virtual synchrony ready for library (janus subproject) Removed Paths: ------------- trunk/complement/explore/test/virtual_time/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-16 19:18:54
|
Revision: 1682 http://complement.svn.sourceforge.net/complement/?rev=1682&view=rev Author: complement Date: 2007-08-16 12:18:49 -0700 (Thu, 16 Aug 2007) Log Message: ----------- experiments with virtual synchrony ready for library (janus subproject) Modified Paths: -------------- trunk/complement/explore/lib/janus/ut/VTmess_core.cc trunk/complement/explore/lib/janus/ut/vt_dispatch.cc trunk/complement/explore/lib/janus/ut/vt_object.cc Added Paths: ----------- trunk/complement/explore/include/janus/ trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/lib/janus/ trunk/complement/explore/lib/janus/Makefile trunk/complement/explore/lib/janus/Makefile.inc trunk/complement/explore/lib/janus/ut/ trunk/complement/explore/lib/janus/ut/Makefile trunk/complement/explore/lib/janus/ut/Makefile.inc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_operations.h trunk/complement/explore/lib/janus/ut/vt_remote.cc trunk/complement/explore/lib/janus/vtime.cc Removed Paths: ------------- trunk/complement/explore/lib/janus/ut/Makefile trunk/complement/explore/lib/janus/ut/Makefile.inc trunk/complement/explore/lib/janus/ut/unit_test.cc trunk/complement/explore/lib/janus/ut/vt_handler.cc trunk/complement/explore/lib/janus/ut/vt_operations.cc trunk/complement/explore/lib/janus/ut/vt_operations.h trunk/complement/explore/test/virtual_time/Makefile trunk/complement/explore/test/virtual_time/Makefile.inc trunk/complement/explore/test/virtual_time/test/Makefile trunk/complement/explore/test/virtual_time/test/Makefile.inc trunk/complement/explore/test/virtual_time/test/VTmess_core.cc trunk/complement/explore/test/virtual_time/test/unit_test.cc trunk/complement/explore/test/virtual_time/test/vt_dispatch.cc trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/test/vt_object.cc trunk/complement/explore/test/virtual_time/test/vt_operations.cc trunk/complement/explore/test/virtual_time/test/vt_operations.h trunk/complement/explore/test/virtual_time/test/vt_remote.cc trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Copied: trunk/complement/explore/include/janus/vtime.h (from rev 1680, trunk/complement/explore/test/virtual_time/vtime.h) =================================================================== --- trunk/complement/explore/include/janus/vtime.h (rev 0) +++ trunk/complement/explore/include/janus/vtime.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,413 @@ +// -*- C++ -*- Time-stamp: <07/08/11 01:05:47 ptr> + +#ifndef __vtime_h +#define __vtime_h + +#include <algorithm> +#include <list> +#include <vector> +#include <hash_map> +#include <hash_set> +#include <iterator> + +#include <istream> +#include <ostream> +#include <stdexcept> + +#include <stem/Event.h> +#include <stem/EventHandler.h> + +#include <mt/time.h> + +namespace vt { + +// typedef stem::addr_type oid_type; +typedef stem::gaddr_type oid_type; + +} // namespace vt + +namespace std { + +template <> +struct hash<vt::oid_type> +{ + size_t operator()(const vt::oid_type& __x) const + { return __x.addr; } +}; + +} // namespace std + +namespace vt { + +typedef uint32_t vtime_unit_type; +typedef stem::addr_type group_type; // required, used in VTSend +typedef std::hash_map<oid_type, vtime_unit_type> vtime_type; + +bool operator <=( const vtime_type& l, const vtime_type& r ); +inline bool operator >=( const vtime_type& l, const vtime_type& r ) + { return r <= l; } +vtime_type operator -( const vtime_type& l, const vtime_type& r ); +vtime_type operator +( const vtime_type& l, const vtime_type& r ); +vtime_type& operator +=( vtime_type& l, const vtime_type& r ); + +// vt::vtime_type max( const vt::vtime_type& l, const vt::vtime_type& r ); +vtime_type& sup( vtime_type& l, const vtime_type& r ); + +struct vtime : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + vtime() + { } + vtime( const vtime& _vt ) : + vt( _vt.vt.begin(), _vt.vt.end() ) + { } + vtime( const vtime_type& _vt ) : + vt( _vt.begin(), _vt.end() ) + { } + + vtime& operator =( const vtime& _vt ) + { vt = _vt.vt; } + + // bool operator ==( const vtime& r ) const + // { return vt == r.vt; } + + bool operator <=( const vtime& r ) const + { return vt <= r.vt; } + bool operator >=( const vtime& r ) const + { return vt >= r.vt; } + + vtime operator -( const vtime& r ) const + { return vtime( vt - r.vt ); } + + vtime operator +( const vtime& r ) const + { return vtime( vt + r.vt ); } + + vtime& operator +=( const vtime_type& t ) + { + vt += t; + return *this; + } + vtime& operator +=( const vtime& t ) + { + vt += t.vt; + return *this; + } + + vtime& operator +=( const vtime_type::value_type& ); + + vtime_type::data_type& operator[]( const vtime_type::key_type& k ) + { return vt[k]; } + const vtime_type::data_type& operator[]( const vtime_type::key_type& k ) const + { return vt[k]; } + + + mutable vtime_type vt; +}; + + +// vtime max( const vtime& l, const vtime& r ); +vtime& sup( vtime& l, const vtime& r ); + +// typedef std::pair<group_type, vtime> vtime_group_type; +// typedef std::list<vtime_group_type> gvtime_type; +typedef std::hash_map<group_type, vtime> gvtime_type; + +gvtime_type& operator +=( gvtime_type&, const gvtime_type::value_type& ); +gvtime_type& operator +=( gvtime_type&, const gvtime_type& ); +gvtime_type operator -( const gvtime_type& l, const gvtime_type& r ); + +struct gvtime : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + gvtime() + { } + gvtime( const gvtime& _gvt ) : + gvt( _gvt.gvt.begin(), _gvt.gvt.end() ) + { } + + gvtime& operator =( const gvtime& _gvt ) + { gvt = _gvt.gvt; } + + gvtime& operator +=( const gvtime_type::value_type& ); + gvtime& operator +=( const gvtime& ); + + gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) + { return gvt[k]; } + const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const + { return gvt[k]; } + + mutable gvtime_type gvt; +}; + +struct VSsync_rq : + public stem::__pack_base +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VSsync_rq() : + grp(0), + mess() + { } + VSsync_rq( const VSsync_rq& _gvt ) : + grp( _gvt.grp ), + mess( _gvt.mess ) + { } + + group_type grp; + std::string mess; +}; + +struct VSsync : + public VSsync_rq +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VSsync() + { } + VSsync( const VSsync& _gvt ) : + VSsync_rq( _gvt ), + gvt( _gvt.gvt ) + { } + + gvtime gvt; +}; + +struct VTmess : + public VSsync +{ + void pack( std::ostream& s ) const; + void net_pack( std::ostream& s ) const; + void unpack( std::istream& s ); + void net_unpack( std::istream& s ); + + VTmess() : + code(0), + src() + { } + VTmess( const VTmess& _gvt ) : + VSsync( _gvt ), + code( _gvt.code ), + src( _gvt.src ) + { } + + stem::code_type code; + oid_type src; +}; + +namespace detail { + +class vtime_obj_rec +{ + public: + void add_group( group_type g ) + { groups.insert(g); } + void add( stem::addr_type a, group_type g ) + { addr = a; groups.insert(g); } + bool rm_group( group_type ); + void rm_member( const oid_type& ); + + template <typename BackInsertIterator> + void groups_list( BackInsertIterator bi ) const + { std::copy( groups.begin(), groups.end(), bi ); } + + stem::addr_type stem_addr() const + { return addr; } + + bool deliver( const VTmess& ev ); + bool deliver_delayed( const VTmess& ev ); + std::ostream& trace_deliver( const VTmess& m, std::ostream& o ); + void next( const oid_type& from, group_type grp ) + { ++vt.gvt[grp][from]; /* increment my VT counter */ } + void delta( gvtime& vtstamp, const oid_type& from, const oid_type& to, group_type grp ); + void base_advance( const oid_type& to ) + { svt[to] = vt.gvt; /* store last sent VT to obj */ } + void get_gvt( gvtime_type& gvt ) const + { gvt = vt.gvt; } + void sync( group_type, const oid_type&, const gvtime_type& ); + +#ifdef __FIT_EXAM + const gvtime_type::data_type& operator[]( const gvtime_type::key_type k ) const + { return vt[k]; } +#endif + + private: + typedef std::hash_set<group_type> groups_container_type; + typedef std::hash_map<oid_type, gvtime_type> delta_vtime_type; + typedef std::hash_map<oid_type, gvtime_type> snd_delta_vtime_t; + + stem::addr_type addr; // stem address of object + delta_vtime_type lvt; // last recieve VT from neighbours + snd_delta_vtime_t svt; // last send VT to neighbours + gvtime vt; // VT of object + + groups_container_type groups; // member of groups + + public: + // delay pool should be here + typedef std::pair<xmt::timespec,stem::Event_base<VTmess>*> delay_item_t; + typedef std::list<delay_item_t> dpool_t; + + dpool_t dpool; + + private: + bool order_correct( const VTmess& ); + bool order_correct_delayed( const VTmess& ); +}; + +} // namespace detail + +class VTDispatcher : + public stem::EventHandler +{ + public: + enum traceflags { + notrace = 0, + tracenet = 1, + tracedispatch = 2, + tracefault = 4, + tracedelayed = 8, + tracegroup = 0x10 + }; + + VTDispatcher() : + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( const char *info ) : + stem::EventHandler( info ), + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( stem::addr_type id ) : + stem::EventHandler( id ), + _trflags( notrace ), + _trs( 0 ) + { } + + VTDispatcher( stem::addr_type id, const char *info ) : + stem::EventHandler( id, info ), + _trflags( notrace ), + _trs( 0 ) + { } + + void VTDispatch( const stem::Event_base<VTmess>& ); + + void VTSend( const stem::Event& e, group_type ); + void Subscribe( stem::addr_type, oid_type, group_type ); + void Unsubscribe( oid_type, group_type ); + void Unsubscribe( oid_type ); + void get_gvtime( group_type, stem::addr_type, gvtime_type& ); + void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); + + void settrf( unsigned f ); + void unsettrf( unsigned f ); + void resettrf( unsigned f ); + void cleantrf(); + unsigned trflags() const; + void settrs( std::ostream * ); + + 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; + + void check_and_send( detail::vtime_obj_rec&, const stem::Event_base<VTmess>& ); + void check_and_send_delayed( detail::vtime_obj_rec& ); + + vt_map_type vtmap; + gid_map_type grmap; + + xmt::mutex _lock_tr; + unsigned _trflags; + std::ostream *_trs; + + DECLARE_RESPONSE_TABLE( VTDispatcher, stem::EventHandler ); +}; + +class VTHandler : + public stem::EventHandler +{ + private: + class Init + { + public: + Init(); + ~Init(); + private: + static void _guard( int ); + static void __at_fork_prepare(); + static void __at_fork_child(); + static void __at_fork_parent(); + }; + + public: + VTHandler(); + explicit VTHandler( const char *info ); + explicit VTHandler( stem::addr_type id, const char *info = 0 ); + virtual ~VTHandler(); + + void VTSend( const stem::Event& e ); + void JoinGroup( group_type grp ) + { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } + virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); + virtual void VSsync_time( const stem::Event_base<VSsync>& ); + + + template <class D> + void VTSend( const stem::Event_base<D>& e ) + { VTHandler::VTSend( stem::Event_convert<D>()( e ) ); } + + static VTDispatcher *vtdispatcher() + { return _vtdsp; } + + protected: + void VSNewMember_data( const stem::Event_base<VSsync_rq>&, const std::string& data ); + + void get_gvtime( group_type g, gvtime_type& gvt ) + { _vtdsp->get_gvtime( g, self_id(), gvt ); } + + private: + static class VTDispatcher *_vtdsp; + + DECLARE_RESPONSE_TABLE( VTHandler, stem::EventHandler ); +}; + +#define VS_MESS 0x300 +#define VS_NEW_MEMBER 0x301 +#define VS_OUT_MEMBER 0x302 +#define VS_SYNC_TIME 0x303 + +} // namespace vt + +namespace std { + +ostream& operator <<( ostream&, const vt::vtime_type::value_type& ); +ostream& operator <<( ostream&, const vt::vtime_type& ); +ostream& operator <<( ostream&, const vt::vtime& ); +ostream& operator <<( ostream&, const vt::gvtime_type::value_type& ); +ostream& operator <<( ostream&, const vt::gvtime_type& ); +ostream& operator <<( ostream&, const vt::gvtime& ); +ostream& operator <<( ostream& o, const vt::VSsync& ); +ostream& operator <<( ostream& o, const vt::VTmess& ); + +} // namespace std + +#endif // __vtime_h Property changes on: trunk/complement/explore/lib/janus ___________________________________________________________________ Name: svn:ignore + obj Copied: trunk/complement/explore/lib/janus/Makefile (from rev 1672, trunk/complement/explore/test/virtual_time/Makefile) =================================================================== --- trunk/complement/explore/lib/janus/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,49 @@ +# -*- Makefile -*- Time-stamp: <07/02/07 12:28:46 ptr> + +SRCROOT := ../.. +COMPILER_NAME := gcc + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +INCLUDES += -I$(SRCROOT)/include + +LIBMT_DIR = ${CoMT_DIR}/lib/mt +LIBSOCK_DIR = ${CoMT_DIR}/lib/sockios +LIBSTEM_DIR = ${CoMT_DIR}/lib/stem + +LDSEARCH += -L${CoMT_LIB_DIR} -Wl,--rpath=${CoMT_LIB_DIR} + +release-shared : LDLIBS = -lxmt -lsockios -lstem +ifndef WITHOUT_STLPORT +stldbg-shared : LDLIBS = -lxmtstlg -lsockiosstlg -lstemstlg +endif +dbg-shared : LDLIBS = -lxmtg -lsockiosg -lstemg + +check: all-shared + $(MAKE) -C test + (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 + (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 +ifndef WITHOUT_STLPORT + (cd test; ${OUTPUT_DIR_STLDBG}/ut_vt) || exit 1 +endif + +check-release-shared: release-shared + $(MAKE) -C test release-shared + (cd test; ${OUTPUT_DIR}/ut_vtime) || exit 1 + +check-dbg-shared: dbg-shared + $(MAKE) -C test dbg-shared + (cd test; ${OUTPUT_DIR_DBG}/ut_vtime) || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg-shared: stldbg-shared + $(MAKE) -C test stldbg-shared + (cd test; ${OUTPUT_DIR_STLDBG}/ut_vtime) || exit 1 +endif + +depend:: + $(MAKE) -C test depend + +# dbg-shared: DEFS += -DDEBUG + Copied: trunk/complement/explore/lib/janus/Makefile.inc (from rev 1672, trunk/complement/explore/test/virtual_time/Makefile.inc) =================================================================== --- trunk/complement/explore/lib/janus/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,7 @@ +# -*- makefile -*- Time-stamp: <06/10/10 15:22:33 ptr> + +LIBNAME = janus +MAJOR = 0 +MINOR = 2 +PATCH = 0 +SRC_CC = vtime.cc Copied: trunk/complement/explore/lib/janus/ut (from rev 1672, trunk/complement/explore/test/virtual_time/test) Deleted: trunk/complement/explore/lib/janus/ut/Makefile =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,39 +0,0 @@ -# -*- Makefile -*- Time-stamp: <07/02/21 15:30:59 ptr> - -SRCROOT := ../../.. -COMPILER_NAME := gcc -# ALL_TAGS := install-release-shared install-dbg-shared -# CoMT_DIR := ../../external/complement/explore - -include Makefile.inc -include ${SRCROOT}/Makefiles/gmake/top.mak - -# DEFS += -DUNIT_TEST -INCLUDES += -I${CoMT_INCLUDE_DIR} -I${BOOST_INCLUDE_DIR} -I.. -DEFS += -D__FIT_EXAM - -LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} - -release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam -dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg -stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg - -LDLIBS = ${PROJECT_LIBS} - -check: all-shared - ${OUTPUT_DIR}/${PRGNAME} || exit 1 - ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 -ifndef WITHOUT_STLPORT - ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1; -endif - -check-release-shared: release-shared - ${OUTPUT_DIR}/${PRGNAME} || exit 1 - -check-dbg-shared: dbg-shared - ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 - -ifndef WITHOUT_STLPORT -check-stldbg-shared: stldbg-shared - ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1 -endif Copied: trunk/complement/explore/lib/janus/ut/Makefile (from rev 1678, trunk/complement/explore/test/virtual_time/test/Makefile) =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/ut/Makefile 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,46 @@ +# -*- Makefile -*- Time-stamp: <07/08/08 22:18:48 ptr> + +SRCROOT := ../../.. +COMPILER_NAME := gcc +# ALL_TAGS := install-release-shared install-dbg-shared +# CoMT_DIR := ../../external/complement/explore + +include Makefile.inc +include ${SRCROOT}/Makefiles/gmake/top.mak + +# DEFS += -DUNIT_TEST +INCLUDES += -I${CoMT_INCLUDE_DIR} -I${BOOST_INCLUDE_DIR} -I.. +DEFS += -D__FIT_EXAM + +LDFLAGS += -L${INSTALL_LIB_DIR} -Wl,-rpath=${INSTALL_LIB_DIR}:${STLPORT_LIB_DIR} + +release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -lexam +dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -lexamg +ifndef WITHOUT_STLPORT +stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -lexamstlg +endif + +dbg-shared: DEFS += -D__FIT_VS_TRACE +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + +LDLIBS = ${PROJECT_LIBS} + +check: all-shared + ${OUTPUT_DIR}/${PRGNAME} || exit 1 + ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 +ifndef WITHOUT_STLPORT + ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1; +endif + +check-release-shared: release-shared + ${OUTPUT_DIR}/${PRGNAME} || exit 1 + +check-dbg-shared: dbg-shared + ${OUTPUT_DIR_DBG}/${PRGNAME} || exit 1 + +ifndef WITHOUT_STLPORT +check-stldbg-shared: stldbg-shared + ${OUTPUT_DIR_STLDBG}/${PRGNAME} || exit 1 +endif Deleted: trunk/complement/explore/lib/janus/ut/Makefile.inc =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,11 +0,0 @@ -# -*- Makefile -*- - -PRGNAME = ut_vtime - -SRC_CC = ../vtime.cc \ - unit_test.cc \ - vt_operations.cc \ - VTmess_core.cc \ - vt_object.cc \ - vt_dispatch.cc \ - vt_handler.cc Copied: trunk/complement/explore/lib/janus/ut/Makefile.inc (from rev 1680, trunk/complement/explore/test/virtual_time/test/Makefile.inc) =================================================================== --- trunk/complement/explore/lib/janus/ut/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/ut/Makefile.inc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,12 @@ +# -*- Makefile -*- + +PRGNAME = ut_vtime + +SRC_CC = ../vtime.cc \ + unit_test.cc \ + vt_operations.cc \ + VTmess_core.cc \ + vt_object.cc \ + vt_dispatch.cc \ + vt_handler.cc \ + vt_remote Modified: trunk/complement/explore/lib/janus/ut/VTmess_core.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/VTmess_core.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/VTmess_core.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -3,7 +3,7 @@ #include "vt_operations.h" #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/unit_test.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,37 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:41:24 ptr> - -#include "vt_operations.h" - -int EXAM_DECL(vtime_test_suite); - -int EXAM_IMPL(vtime_test_suite) -{ - exam::test_suite::test_case_type tc[3]; - - exam::test_suite t( "virtual time operations" ); - - vtime_operations vt_oper; - - t.add( &vtime_operations::vt_max, vt_oper, "Max", - tc[1] = t.add( &vtime_operations::vt_add, vt_oper, "Additions", - tc[0] = t.add( &vtime_operations::vt_compare, vt_oper, "Compare" ) ) ); - t.add( &vtime_operations::vt_diff, vt_oper, "Differences", tc[0] ); - - t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", - tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - - t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ); - - return t.girdle(); -} - -int main( int, char ** ) -{ - - return vtime_test_suite(0); -} Copied: trunk/complement/explore/lib/janus/ut/unit_test.cc (from rev 1680, trunk/complement/explore/test/virtual_time/test/unit_test.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/unit_test.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/unit_test.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,41 @@ +// -*- C++ -*- Time-stamp: <07/08/16 09:04:40 ptr> + +#include "vt_operations.h" + +int EXAM_DECL(vtime_test_suite); + +int EXAM_IMPL(vtime_test_suite) +{ + exam::test_suite::test_case_type tc[3]; + + exam::test_suite t( "virtual time operations" ); + + vtime_operations vt_oper; + + t.add( &vtime_operations::vt_max, vt_oper, "Max", + tc[1] = t.add( &vtime_operations::vt_add, vt_oper, "Additions", + tc[0] = t.add( &vtime_operations::vt_compare, vt_oper, "Compare" ) ) ); + t.add( &vtime_operations::vt_diff, vt_oper, "Differences", tc[0] ); + + t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", + tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); + + t.add( &vtime_operations::remote, vt_oper, "remote", + t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", + t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", + t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))); + + return t.girdle(); +} + +int main( int, char ** ) +{ + + return vtime_test_suite(0); +} Modified: trunk/complement/explore/lib/janus/ut/vt_dispatch.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_dispatch.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_dispatch.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -5,7 +5,7 @@ // #include <boost/lexical_cast.hpp> #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,191 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:53:24 ptr> - -#include "vt_operations.h" - -// #include <boost/lexical_cast.hpp> - -#include <iostream> -#include <vtime.h> - -using namespace vt; -using namespace std; - -class VTDummy : - public vt::VTHandler -{ - public: - VTDummy(); - VTDummy( stem::addr_type id ); - VTDummy( stem::addr_type id, const char *info ); - ~VTDummy(); - - void handler( const stem::Event& ); - void VTNewMember( const stem::Event& ); - void VTOutMember( const stem::Event& ); - - void wait(); - std::string msg; - int count; - int ocount; - - private: - xmt::condition cnd; - - DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); -}; - -#define VT_MESS3 0x1203 - -VTDummy::VTDummy() : - VTHandler(), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::VTDummy( stem::addr_type id ) : - VTHandler( id ), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::VTDummy( stem::addr_type id, const char *info ) : - VTHandler( id, info ), - count(0), - ocount(0) -{ - cnd.set( false ); -} - -VTDummy::~VTDummy() -{ - // cnd.wait(); -} - -void VTDummy::handler( const stem::Event& ev ) -{ - msg = ev.value(); - - cnd.set( true ); -} - -void VTDummy::VTNewMember( const stem::Event& ev ) -{ - // cerr << "Hello" << endl; - ++count; -} - -void VTDummy::VTOutMember( const stem::Event& ev ) -{ - // cerr << "Hello" << endl; - ++ocount; -} - -void VTDummy::wait() -{ - cnd.try_wait(); - - cnd.set( false ); -} - -DEFINE_RESPONSE_TABLE( VTDummy ) - EV_EDS( ST_NULL, VT_MESS3, handler ) -END_RESPONSE_TABLE - -int EXAM_IMPL(vtime_operations::VTHandler1) -{ - VTDummy dummy1; - VTDummy dummy2; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - - EXAM_CHECK( dummy2.msg == "hello" ); - EXAM_CHECK( dummy1.msg == "" ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::VTHandler2) -{ - VTDummy dummy1; - VTDummy dummy2; - VTDummy dummy3; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - dummy3.wait(); - - EXAM_CHECK( dummy3.count == 0 ); - EXAM_CHECK( dummy3.msg == "hello" ); - EXAM_CHECK( dummy2.count == 1 ); - EXAM_CHECK( dummy2.msg == "hello" ); - EXAM_CHECK( dummy1.count == 2 ); - EXAM_CHECK( dummy1.msg == "" ); - - ev.dest( 100 ); // not this group member - try { - dummy1.VTSend( ev ); - EXAM_ERROR( "exception expected" ); - } - catch ( std::domain_error& ) { - } - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::VTSubscription) -{ - VTDummy dummy1; - VTDummy dummy2; - - stem::Event ev( VT_MESS3 ); - ev.dest( 0 ); // group - ev.value() = "hello"; - - dummy1.VTSend( ev ); - - dummy2.wait(); - EXAM_CHECK( dummy2.msg == "hello" ); - - { - VTDummy dummy3; - - ev.value() = "hi"; - dummy1.VTSend( ev ); - - dummy2.wait(); - // dummy3.wait(); - - // EXAM_CHECK( dummy3.msg == "hi" ); - EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS - EXAM_CHECK( dummy2.msg == "hi" ); - EXAM_CHECK( dummy1.msg == "" ); - } - - ev.value() = "yet more"; - dummy1.VTSend( ev ); - - dummy2.wait(); - EXAM_CHECK( dummy2.msg == "yet more" ); - EXAM_CHECK( dummy1.msg == "" ); - - EXAM_CHECK( dummy1.ocount == 1 ); - EXAM_CHECK( dummy2.ocount == 1 ); - - return EXAM_RESULT; -} - Copied: trunk/complement/explore/lib/janus/ut/vt_handler.cc (from rev 1679, trunk/complement/explore/test/virtual_time/test/vt_handler.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_handler.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_handler.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,357 @@ +// -*- C++ -*- Time-stamp: <07/08/11 23:21:59 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +#include <stem/EvManager.h> + +using namespace vt; +using namespace std; + +class VTDummy : + public vt::VTHandler +{ + public: + VTDummy(); + VTDummy( stem::addr_type id ); + VTDummy( stem::addr_type id, const char *info ); + ~VTDummy(); + + void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + void greeting(); + + void wait(); + std::string msg; + int count; + int ocount; + + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + + private: + xmt::condition cnd; + xmt::condition gr; + + DECLARE_RESPONSE_TABLE( VTDummy, vt::VTHandler ); +}; + +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + +VTDummy::VTDummy() : + VTHandler(), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::VTDummy( stem::addr_type id ) : + VTHandler( id ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::VTDummy( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +VTDummy::~VTDummy() +{ + // cnd.wait(); +} + +void VTDummy::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void VTDummy::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello " << ev.src() << endl; + ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); +} + +void VTDummy::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + +void VTDummy::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +void VTDummy::greeting() +{ + gr.set( true ); +} + +DEFINE_RESPONSE_TABLE( VTDummy ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::VTHandler1) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTHandler2) +{ + VTDummy dummy1; + VTDummy dummy2; + VTDummy dummy3; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy3.count == 0 ); + EXAM_CHECK( dummy3.msg == "hello" ); + EXAM_CHECK( dummy2.count == 1 ); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.count == 2 ); + EXAM_CHECK( dummy1.msg == "" ); + + ev.dest( 100 ); // not this group member + try { + dummy1.VTSend( ev ); + EXAM_ERROR( "exception expected" ); + } + catch ( std::domain_error& ) { + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTSubscription) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + VTDummy dummy3; + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy2.wait(); + // dummy3.wait(); + + // EXAM_CHECK( dummy3.msg == "hi" ); + // EXAM_CHECK( dummy3.msg == "" ); // dummy3 don't see, due to VTS + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + ev.value() = "yet more"; + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "yet more" ); + EXAM_CHECK( dummy1.msg == "" ); + + EXAM_CHECK( dummy1.ocount == 1 ); + EXAM_CHECK( dummy2.ocount == 1 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + { + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch ); + // dummy1.manager()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup2) +{ + VTDummy dummy1; + VTDummy dummy2; + + stem::Event ev( VS_DUMMY_MESS ); + ev.dest( 0 ); // group + ev.value() = "hello"; + + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + + { + // cerr << (void *)&dummy1 << " dummy1\n" + // << (void *)&dummy2 << " dummy2\n"; + // dummy1.manager()->settrf( /* stem::EvManager::tracenet | */ stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + // dummy1.manager()->settrs( &std::cerr ); + + // dummy1.vtdispatcher()->settrf( VTDispatcher::tracedispatch | VTDispatcher::tracefault | VTDispatcher::tracedelayed | VTDispatcher::tracegroup ); + // dummy1.vtdispatcher()->settrs( &std::cerr ); + + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "hi" ); + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::VTEntryIntoGroup3) +{ + VTDummy dummy1; + + stem::Event ev( VS_DUMMY_MESS ); + + { + VTDummy dummy2; + + dummy2.wait_greeting(); + + ev.value() = "hello"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + EXAM_CHECK( dummy2.msg == "hello" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy3; + + dummy3.wait_greeting(); + + ev.value() = "hi"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy3.wait(); + + EXAM_CHECK( dummy3.msg == "hi" ); + EXAM_CHECK( dummy1.msg == "" ); + } + + { + VTDummy dummy2; + VTDummy dummy3; + + dummy2.wait_greeting(); + dummy3.wait_greeting(); + + ev.value() = "more"; + ev.dest( 0 ); // group + dummy1.VTSend( ev ); + + dummy2.wait(); + dummy3.wait(); + + EXAM_CHECK( dummy2.msg == "more" ); + EXAM_CHECK( dummy3.msg == "more" ); + EXAM_CHECK( dummy1.msg == "" ); + + dummy2.VTSend( ev ); + + dummy1.wait(); + } + + EXAM_CHECK( dummy1.msg == "more" ); + + return EXAM_RESULT; +} Modified: trunk/complement/explore/lib/janus/ut/vt_object.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_object.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_object.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -5,7 +5,7 @@ // #include <boost/lexical_cast.hpp> #include <iostream> -#include <vtime.h> +#include <janus/vtime.h> using namespace vt; using namespace std; Deleted: trunk/complement/explore/lib/janus/ut/vt_operations.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.cc 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,321 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> - -#include "vt_operations.h" - -// #include <boost/lexical_cast.hpp> - -#include <iostream> -#include <vtime.h> - -using namespace vt; -using namespace std; - -int EXAM_IMPL(vtime_operations::vt_compare) -{ - const oid_type t0(0); - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( vt2 <= vt1 ); - EXAM_CHECK( vt1 >= vt2 ); - EXAM_CHECK( vt2 >= vt1 ); - - vt2[t3] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( !(vt2 <= vt1) ); - EXAM_CHECK( vt2 >= vt1 ); - - vt1.clear(); - vt2.clear(); - - vt1[t1] = 1; - - vt2[t1] = 1; - vt2[t3] = 1; - - EXAM_CHECK( vt1 <= vt2 ); - EXAM_CHECK( !(vt2 <= vt1) ); - - vt1[t2] = 1; - - EXAM_CHECK( !(vt1 <= vt2) ); - EXAM_CHECK( !(vt2 <= vt1) ); -} - -int EXAM_IMPL(vtime_operations::vt_add) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1 + vt2; - - EXAM_CHECK( vt1 <= vt3 ); - EXAM_CHECK( vt3 <= vt1 ); - - vt2[t2] = 1; - - vt3 = vt1 + vt2; - - vt4[t1] = 1; - vt4[t2] = 2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt4.clear(); - - vt2[t3] = 1; - - vt3 = vt1 + vt2; - - vt4[t1] = 1; - vt4[t2] = 2; - vt4[t3] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::vt_diff) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1 - vt2; - - EXAM_CHECK( vt1 <= vt3 ); - EXAM_CHECK( vt3 <= vt1 ); - - vt2[t1] = 1; - - vt3 = vt1 - vt2; - - vt4[t2] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2[t2] = 1; - - vt4.clear(); - - vt3 = vt1 - vt2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2.clear(); - - vt2[t3] = 1; - - try { - vt3 = vt1 - vt2; - EXAM_ERROR( "Virtual Times are incomparable" ); - } - catch ( const std::range_error& err ) { - EXAM_CHECK( true ); - } - - vt2.clear(); - - vt2[t2] = 2; - - try { - vt3 = vt1 - vt2; - EXAM_ERROR( "Virtual Times are incomparable" ); - } - catch ( const std::range_error& err ) { - EXAM_CHECK( true ); - } - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::vt_max) -{ - const oid_type t1(1); - const oid_type t2(2); - const oid_type t3(3); - - vtime_type vt1; - vtime_type vt2; - vtime_type vt3; - vtime_type vt4; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t1] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t2] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - EXAM_CHECK( vt3 <= vt1 ); - EXAM_CHECK( vt1 <= vt3 ); - - vt2[t3] = 1; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t1] = 1; - vt4[t2] = 1; - vt4[t3] = 1; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2.clear(); - - vt2[t1] = 1; - vt2[t2] = 2; - - vt4.clear(); - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t1] = 1; - vt4[t2] = 2; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - vt2[t3] = 4; - - vt3 = vt1; - vt::sup( vt3, vt2 ); - - vt4[t3] = 4; - - EXAM_CHECK( vt3 <= vt4 ); - EXAM_CHECK( vt4 <= vt3 ); - - return EXAM_RESULT; -} - -int EXAM_IMPL(vtime_operations::gvt_add) -{ - const oid_type t0(0); - const oid_type t1(1); - const oid_type t2(2); - - { - gvtime_type gvt1; - gvtime_type gvt2; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - gvt2[0] = vt2; - - gvt1 += gvt2; - - EXAM_CHECK( gvt1[0][t1] == 2 ); - EXAM_CHECK( gvt1[0][t2] == 2 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 0 ); - EXAM_CHECK( gvt1[1][t2] == 0 ); - } - { - gvtime_type gvt1; - gvtime_type gvt2; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - gvt2[1] = vt2; - - gvt1 += gvt2; - - EXAM_CHECK( gvt1[0][t1] == 1 ); - EXAM_CHECK( gvt1[0][t2] == 1 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 1 ); - EXAM_CHECK( gvt1[1][t2] == 1 ); - } - { - gvtime_type gvt1; - - vtime_type vt1; - vtime_type vt2; - - vt1[t1] = 1; - vt1[t2] = 1; - - vt2[t1] = 1; - vt2[t2] = 1; - - gvt1[0] = vt1; - - gvt1 += make_pair( 1, vt2 ); - - EXAM_CHECK( gvt1[0][t1] == 1 ); - EXAM_CHECK( gvt1[0][t2] == 1 ); - EXAM_CHECK( gvt1[0][t0] == 0 ); - EXAM_CHECK( gvt1[1][t1] == 1 ); - EXAM_CHECK( gvt1[1][t2] == 1 ); - } - - return EXAM_RESULT; -} Copied: trunk/complement/explore/lib/janus/ut/vt_operations.cc (from rev 1678, trunk/complement/explore/test/virtual_time/test/vt_operations.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_operations.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,323 @@ +// -*- C++ -*- Time-stamp: <07/07/27 10:42:55 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +using namespace vt; +using namespace std; + +int EXAM_IMPL(vtime_operations::vt_compare) +{ + const oid_type t0(0); + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( vt2 <= vt1 ); + EXAM_CHECK( vt1 >= vt2 ); + EXAM_CHECK( vt2 >= vt1 ); + + vt2[t3] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( !(vt2 <= vt1) ); + EXAM_CHECK( vt2 >= vt1 ); + + vt1.clear(); + vt2.clear(); + + vt1[t1] = 1; + + vt2[t1] = 1; + vt2[t3] = 1; + + EXAM_CHECK( vt1 <= vt2 ); + EXAM_CHECK( !(vt2 <= vt1) ); + + vt1[t2] = 1; + + EXAM_CHECK( !(vt1 <= vt2) ); + EXAM_CHECK( !(vt2 <= vt1) ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_add) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1 + vt2; + + EXAM_CHECK( vt1 <= vt3 ); + EXAM_CHECK( vt3 <= vt1 ); + + vt2[t2] = 1; + + vt3 = vt1 + vt2; + + vt4[t1] = 1; + vt4[t2] = 2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt4.clear(); + + vt2[t3] = 1; + + vt3 = vt1 + vt2; + + vt4[t1] = 1; + vt4[t2] = 2; + vt4[t3] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_diff) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1 - vt2; + + EXAM_CHECK( vt1 <= vt3 ); + EXAM_CHECK( vt3 <= vt1 ); + + vt2[t1] = 1; + + vt3 = vt1 - vt2; + + vt4[t2] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2[t2] = 1; + + vt4.clear(); + + vt3 = vt1 - vt2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2.clear(); + + vt2[t3] = 1; + + try { + vt3 = vt1 - vt2; + EXAM_ERROR( "Virtual Times are incomparable" ); + } + catch ( const std::range_error& err ) { + EXAM_CHECK( true ); + } + + vt2.clear(); + + vt2[t2] = 2; + + try { + vt3 = vt1 - vt2; + EXAM_ERROR( "Virtual Times are incomparable" ); + } + catch ( const std::range_error& err ) { + EXAM_CHECK( true ); + } + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::vt_max) +{ + const oid_type t1(1); + const oid_type t2(2); + const oid_type t3(3); + + vtime_type vt1; + vtime_type vt2; + vtime_type vt3; + vtime_type vt4; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t1] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t2] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + EXAM_CHECK( vt3 <= vt1 ); + EXAM_CHECK( vt1 <= vt3 ); + + vt2[t3] = 1; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t1] = 1; + vt4[t2] = 1; + vt4[t3] = 1; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2.clear(); + + vt2[t1] = 1; + vt2[t2] = 2; + + vt4.clear(); + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t1] = 1; + vt4[t2] = 2; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + vt2[t3] = 4; + + vt3 = vt1; + vt::sup( vt3, vt2 ); + + vt4[t3] = 4; + + EXAM_CHECK( vt3 <= vt4 ); + EXAM_CHECK( vt4 <= vt3 ); + + return EXAM_RESULT; +} + +int EXAM_IMPL(vtime_operations::gvt_add) +{ + const oid_type t0(0); + const oid_type t1(1); + const oid_type t2(2); + + { + gvtime_type gvt1; + gvtime_type gvt2; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + gvt2[0] = vt2; + + gvt1 += gvt2; + + EXAM_CHECK( gvt1[0][t1] == 2 ); + EXAM_CHECK( gvt1[0][t2] == 2 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 0 ); + EXAM_CHECK( gvt1[1][t2] == 0 ); + } + { + gvtime_type gvt1; + gvtime_type gvt2; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + gvt2[1] = vt2; + + gvt1 += gvt2; + + EXAM_CHECK( gvt1[0][t1] == 1 ); + EXAM_CHECK( gvt1[0][t2] == 1 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 1 ); + EXAM_CHECK( gvt1[1][t2] == 1 ); + } + { + gvtime_type gvt1; + + vtime_type vt1; + vtime_type vt2; + + vt1[t1] = 1; + vt1[t2] = 1; + + vt2[t1] = 1; + vt2[t2] = 1; + + gvt1[0] = vt1; + + gvt1 += make_pair( 1, vt2 ); + + EXAM_CHECK( gvt1[0][t1] == 1 ); + EXAM_CHECK( gvt1[0][t2] == 1 ); + EXAM_CHECK( gvt1[0][t0] == 0 ); + EXAM_CHECK( gvt1[1][t1] == 1 ); + EXAM_CHECK( gvt1[1][t2] == 1 ); + } + + return EXAM_RESULT; +} Deleted: trunk/complement/explore/lib/janus/ut/vt_operations.h =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-03 20:13:53 UTC (rev 1672) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -1,30 +0,0 @@ -// -*- C++ -*- Time-stamp: <07/07/26 09:40:39 ptr> - -#ifndef __vt_operations_h -#define __vt_operations_h - -#include <exam/suite.h> - -struct vtime_operations -{ - int EXAM_DECL(vt_compare); - int EXAM_DECL(vt_add); - int EXAM_DECL(vt_diff); - int EXAM_DECL(vt_max); - - int EXAM_DECL(gvt_add); - - int EXAM_DECL(VTMess_core); - - int EXAM_DECL(vt_object); - - int EXAM_DECL(VTDispatch1); - int EXAM_DECL(VTDispatch2); - - int EXAM_DECL(VTHandler1); - int EXAM_DECL(VTHandler2); - - int EXAM_DECL(VTSubscription); -}; - -#endif // __vt_operations_h Copied: trunk/complement/explore/lib/janus/ut/vt_operations.h (from rev 1680, trunk/complement/explore/test/virtual_time/test/vt_operations.h) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_operations.h (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_operations.h 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,35 @@ +// -*- C++ -*- Time-stamp: <07/08/16 09:02:08 ptr> + +#ifndef __vt_operations_h +#define __vt_operations_h + +#include <exam/suite.h> + +struct vtime_operations +{ + int EXAM_DECL(vt_compare); + int EXAM_DECL(vt_add); + int EXAM_DECL(vt_diff); + int EXAM_DECL(vt_max); + + int EXAM_DECL(gvt_add); + + int EXAM_DECL(VTMess_core); + + int EXAM_DECL(vt_object); + + int EXAM_DECL(VTDispatch1); + int EXAM_DECL(VTDispatch2); + + int EXAM_DECL(VTHandler1); + int EXAM_DECL(VTHandler2); + + int EXAM_DECL(VTSubscription); + int EXAM_DECL(VTEntryIntoGroup); + int EXAM_DECL(VTEntryIntoGroup2); + int EXAM_DECL(VTEntryIntoGroup3); + + int EXAM_DECL(remote); +}; + +#endif // __vt_operations_h Copied: trunk/complement/explore/lib/janus/ut/vt_remote.cc (from rev 1680, trunk/complement/explore/test/virtual_time/test/vt_remote.cc) =================================================================== --- trunk/complement/explore/lib/janus/ut/vt_remote.cc (rev 0) +++ trunk/complement/explore/lib/janus/ut/vt_remote.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,194 @@ +// -*- C++ -*- Time-stamp: <07/08/16 10:45:48 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <janus/vtime.h> + +#include <stem/EvManager.h> +#include <stem/NetTransport.h> +#include <sockios/sockmgr.h> +#include <sys/wait.h> + +#include <mt/xmt.h> +#include <mt/shm.h> + +using namespace std; +using namespace stem; +using namespace xmt; +using namespace vt; + +class YaRemote : + public vt::VTHandler +{ + public: + YaRemote(); + YaRemote( stem::addr_type id ); + YaRemote( stem::addr_type id, const char *info ); + ~YaRemote(); + + void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + void greeting(); + + void wait(); + std::string msg; + int count; + int ocount; + + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + + private: + xmt::condition cnd; + xmt::condition gr; + + DECLARE_RESPONSE_TABLE( YaRemote, vt::VTHandler ); +}; + +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + +YaRemote::YaRemote() : + VTHandler(), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id ) : + VTHandler( id ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::~YaRemote() +{ + // cnd.wait(); +} + +void YaRemote::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello " << ev.src() << endl; + ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); +} + +void YaRemote::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + +void YaRemote::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +void YaRemote::greeting() +{ + gr.set( true ); +} + +DEFINE_RESPONSE_TABLE( YaRemote ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::remote) +{ + const char fname[] = "/tmp/yanus_test.shm"; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; + + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); + + try { + xmt::fork(); + + b.wait(); + + NetTransportMgr mgr; + + addr_type zero = mgr.open( "localhost", 6980 ); + + EXAM_CHECK_ASYNC( mgr.good() ); + + YaRemote obj2; + + exit(0); + } + catch ( xmt::fork_in_parent& child ) { + sockmgr_stream_MP<NetTransport> srv( 6980 ); + + EXAM_REQUIRE( srv.good() ); + + b.wait(); + + YaRemote obj1; + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + srv.close(); + srv.wait(); + } + + (&b)->~__barrier<true>(); + shm_b.deallocate( &b, 1 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + EXAM_ERROR( err.what() ); + } + + seg.deallocate(); + unlink( fname ); + + return EXAM_RESULT; +} + Copied: trunk/complement/explore/lib/janus/vtime.cc (from rev 1680, trunk/complement/explore/test/virtual_time/vtime.cc) =================================================================== --- trunk/complement/explore/lib/janus/vtime.cc (rev 0) +++ trunk/complement/explore/lib/janus/vtime.cc 2007-08-16 19:18:49 UTC (rev 1682) @@ -0,0 +1,1170 @@ +// -*- C++ -*- Time-stamp: <07/08/11 01:10:59 ptr> + +#include <janus/vtime.h> + +#include <iostream> +#include <stdint.h> +#include <stem/EvManager.h> + +namespace vt { + +using namespace std; +using namespace xmt; +using namespace stem; + +void vtime::pack( std::ostream& s ) const +{ + __pack( s, static_cast<uint8_t>(vt.size()) ); + for ( vtime_type::const_iterator i = vt.begin(); i != vt.end(); ++i ) { + i->first.pack( s ); // __pack( s, i->first ); + __pack( s, i->second ); + } +} + +void vtime::net_pack( std::ostream& s ) const +{ + __net_pack( s, static_cast<uint8_t>(vt.size()) ); + for ( vtime_type::const_iterator i = vt.begin(); i != vt.end(); ++i ) { + i->first.net_pack( s ); // __net_pack( s, i->first ); + __net_pack( s, i->second ); + } +} + +void vtime::unpack( std::istream& s ) +{ + vt.clear(); + uint8_t n; + __unpack( s, n ); + while ( n-- > 0 ) { + oid_type oid; + vtime_unit_type v; + + oid.unpack( s ); // __unpack( s, oid ); + __unpack( s, v ); + + vt[oid] = v; + } +} + +void vtime::net_unpack( std::istream& s ) +{ + vt.clear(); + uint8_t n; + __net_unpack( s, n ); + while ( n-- > 0 ) { + oid_type oid; + vtime_unit_type v; + + oid.net_unpack( s ); // __net_unpack( s, oid ); + __net_unpack( s, v ); + + vt[oid] = v; + } +} + +void gvtime::pack( std::ostream& s ) const +{ + __pack( s, static_cast<uint8_t>(gvt.size()) ); + for ( gvtime_type::const_iterator i = gvt.begin(); i != gvt.end(); ++i ) { + __pack( s, i->first ); + i->second.pack( s ); + } +} + +void gvtime::net_pack( std::ostream& s ) const +{ + __net_pack( s, static_cast<uint8_t>(gvt.size()) ); + for ( gvtime_type::const_iterator i = gvt.begin(); i != gvt.end(); ++i ) { + __net_pack( s, i->first ); + i->second.net_pack( s ); + } +} + +void gvtime::unpack( std::istream& s ) +{ + gvt.clear(); + uint8_t n; + __unpack( s, n ); + while ( n-- > 0 ) { + group_type gid; + __unpack( s, gid ); + gvt[gid].unpack( s ); + } +} + +void gvtime::net_unpack( std::istream& s ) +{ + gvt.clear(); + uint8_t n; + __net_unpack( s, n ); + while ( n-- > 0 ) { + group_type gid; + __net_unpack( s, gid ); + gvt[gid].net_unpack( s ); + } +} + +void VSsync_rq::pack( std::ostream& s ) const +{ + __pack( s, grp ); + __pack( s, mess ); +} + +void VSsync_rq::net_pack( std::ostream& s ) const +{ + __net_pack( s, grp ); + __net_pack( s, mess ); +} + +void VSsync_rq::unpack( std::istream& s ) +{ + __unpack( s, grp ); + __unpack( s, mess ); +} + +void VSsync_rq::net_unpack( std::istream& s ) +{ + __net_unpack( s, grp ); + __net_unpack( s, mess ); +} + +void VSsync::pack( std::ostream& s ) const +{ + gvt.pack( s ); + VSsync_rq::pack( s ); +} + +void VSsync::net_pack( std::ostream& s ) const +{ + gvt.net_pack( s ); + VSsync_rq::net_pack( s ); +} + +void VSsync::unpack( std::istream& s ) +{ + gvt.unpack( s ); + VSsync_rq::unpack( s ); +} + +void VSsync::net_unpack( std::istream& s ) +{ + gvt.net_unpack( s ); + VSsync_rq::net_unpack( s ); +} + +void VTmess::pack( std::ostream& s ) const +{ + __pack( s, code ); + src.pack( s ); // __pack( s, src ); + VSsync::pack( s ); +} + +void VTmess::net_pack( std::ostream& s ) const +{ + __net_pack( s, code ); + src.net_pack( s ); // __net_pack( s, src ); + VSsync::net_pack( s ); +} + +void VTmess::unpack( std::istream& s ) +{ + __unpack( s, code ); + src.unpack( s ); // __unpack( s, src ); + VSsync::unpack( s ); +} + +void VTmess::net_unpack( std::istream& s ) +{ + __net_unpack( s, code ); + src.net_unpack( s ); // __net_unpack( s, src ); + VSsync::net_unpack( s ); +} + +bool operator <=( const vtime_type& l, const vtime_type& r ) +{ + if ( l.empty() ) { + return true; + } + + for ( vtime_type::const_iterator i = l.begin(); i != l.end(); ++i ) { + if ( i->second > 0 ) { + vtime_type::const_iterator j = r.find( i->first ); + if ( j == r.end() || i->second > j->second ) { + return false; + } + } + } + + return true; +} + +vtime_type operator -( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( r.begin(), r.end() ); + + for ( vtime_type::iterator i = tmp.begin(); i != tmp.end(); ++i ) { + if ( i->second > 0 ) { + vtime_type::const_iterator p = l.find(i->first); + if ( p == l.end() || p->second < i->second ) { + throw range_error( "vtime different: right value grater then left" ); + } + i->second = p->second - i->second; + } + } + + for ( vtime_type::const_iterator i = l.begin(); i != l.end(); ++i ) { + vtime_type::iterator p = tmp.find(i->first); + if ( p == tmp.end() ) { + tmp[i->first] = i->second; + } + } + + return tmp; +} + +vtime_type operator +( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( l.begin(), l.end() ); + + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + tmp[i->first] += i->second; + } + + return tmp; +} + +vtime_type& operator +=( vtime_type& l, const vtime_type& r ) +{ + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + l[i->first] += i->second; + } + + return l; +} + +#if 0 +// template <> +vtime_type max( const vtime_type& l, const vtime_type& r ) +{ + vtime_type tmp( l.begin(), l.end() ); + + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + tmp[i->first] = std::max( tmp[i->first], i->second ); + } + return tmp; +} +#endif + +vtime_type& sup( vtime_type& l, const vtime_type& r ) +{ + for ( vtime_type::const_iterator i = r.begin(); i != r.end(); ++i ) { + l[i->first] = std::max( l[i->first], i->second ); + } + return l; +} + + +#if 0 +// template <> +vtime max( const vtime& l, const vtime& r ) +{ + vtime tmp( l ); + + for ( vtime_type::const_iterator i = r.vt.begin(); i != r.vt.end(); ++i ) { + tmp[i->first] = std::max( tmp[i->first], i->second ); + } + return tmp; +} +#endif + +vtime& sup( vtime& l, const vtime& r ) +{ + for ( vtime_type::const_iterator i = r.vt.begin(); i != r.vt.end(); ++i ) { + l[i->first] = std::max( l[i->first], i->second ); + } + return l; +} + +vtime& vtime::operator +=( const vtime_type::value_type& t ) +{ + vt[t.first] += t.second; + + return *this; +} + +gvtime_type& operator +=( gvtime_type& gvt, const gvtime_type::value_type& t ) +{ + gvt[t.first] += t.seco... [truncated message content] |
From: <com...@us...> - 2007-08-16 19:11:02
|
Revision: 1681 http://complement.svn.sourceforge.net/complement/?rev=1681&view=rev Author: complement Date: 2007-08-16 12:11:00 -0700 (Thu, 16 Aug 2007) Log Message: ----------- add constructor with predefined stamps Modified Paths: -------------- trunk/complement/explore/include/mt/time.h Modified: trunk/complement/explore/include/mt/time.h =================================================================== --- trunk/complement/explore/include/mt/time.h 2007-08-16 18:44:28 UTC (rev 1680) +++ trunk/complement/explore/include/mt/time.h 2007-08-16 19:11:00 UTC (rev 1681) @@ -1,7 +1,7 @@ // -*- C++ -*- Time-stamp: <07/02/01 18:35:14 ptr> /* - * Copyright (c) 2002, 2006 + * Copyright (c) 2002, 2006, 2007 * Petr Ovtchenkov * * Licensed under the Academic Free License version 3.0 @@ -81,9 +81,32 @@ namespace xmt { +// delay execution at least on time interval t +__FIT_DECLSPEC void delay( const ::timespec& interval, ::timespec& remain ); +__FIT_DECLSPEC void delay( const ::timespec& interval ); +inline void delay( const ::timespec *interval, ::timespec *remain ) +{ delay( *interval, *remain ); } +inline void delay( const ::timespec *interval ) +{ delay( *interval ); } +// sleep at least up to time t +__FIT_DECLSPEC void sleep( const ::timespec& abstime, ::timespec& real_time ); +__FIT_DECLSPEC void sleep( const ::timespec& abstime ); +inline void sleep( const ::timespec *abstime, ::timespec *real_time ) +{ sleep( *abstime, *real_time ); } +inline void sleep( const ::timespec *abstime ) +{ sleep( *abstime ); } +// get precise time +__FIT_DECLSPEC void gettime( ::timespec& t ); +inline void gettime( ::timespec *t ) +{ gettime( *t ); } + struct timespec : public ::timespec { + enum timeref { + now + }; + timespec() { tv_sec = 0; tv_nsec = 0; } @@ -99,6 +122,15 @@ timespec( const ::timespec& t ) { tv_sec = t.tv_sec; tv_nsec = t.tv_nsec; } + timespec( timeref r ) + { + switch ( r ) { + case now: + gettime( *this ); + break; + } + } + timespec& operator =( const timespec& t ) { tv_sec = t.tv_sec; tv_nsec = t.tv_nsec; return *this; } @@ -124,25 +156,6 @@ { return tv_nsec == 0 ? static_cast<double>(tv_sec) : tv_sec + 1.0e-9 * tv_nsec; } }; -// delay execution at least on time interval t -__FIT_DECLSPEC void delay( const ::timespec& interval, ::timespec& remain ); -__FIT_DECLSPEC void delay( const ::timespec& interval ); -inline void delay( const ::timespec *interval, ::timespec *remain ) -{ delay( *interval, *remain ); } -inline void delay( const ::timespec *interval ) -{ delay( *interval ); } -// sleep at least up to time t -__FIT_DECLSPEC void sleep( const ::timespec& abstime, ::timespec& real_time ); -__FIT_DECLSPEC void sleep( const ::timespec& abstime ); -inline void sleep( const ::timespec *abstime, ::timespec *real_time ) -{ sleep( *abstime, *real_time ); } -inline void sleep( const ::timespec *abstime ) -{ sleep( *abstime ); } -// get precise time -__FIT_DECLSPEC void gettime( ::timespec& t ); -inline void gettime( ::timespec *t ) -{ gettime( *t ); } - } // namespace xmt #endif // __mt_time_h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-16 18:44:30
|
Revision: 1680 http://complement.svn.sourceforge.net/complement/?rev=1680&view=rev Author: complement Date: 2007-08-16 11:44:28 -0700 (Thu, 16 Aug 2007) Log Message: ----------- road to interprocess virtual synchrony Modified Paths: -------------- trunk/complement/explore/test/virtual_time/test/Makefile.inc trunk/complement/explore/test/virtual_time/test/unit_test.cc trunk/complement/explore/test/virtual_time/test/vt_operations.h trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Added Paths: ----------- trunk/complement/explore/test/virtual_time/test/vt_remote.cc Modified: trunk/complement/explore/test/virtual_time/test/Makefile.inc =================================================================== --- trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-13 15:52:01 UTC (rev 1679) +++ trunk/complement/explore/test/virtual_time/test/Makefile.inc 2007-08-16 18:44:28 UTC (rev 1680) @@ -8,4 +8,5 @@ VTmess_core.cc \ vt_object.cc \ vt_dispatch.cc \ - vt_handler.cc + vt_handler.cc \ + vt_remote Modified: trunk/complement/explore/test/virtual_time/test/unit_test.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-13 15:52:01 UTC (rev 1679) +++ trunk/complement/explore/test/virtual_time/test/unit_test.cc 2007-08-16 18:44:28 UTC (rev 1680) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:19:11 ptr> +// -*- C++ -*- Time-stamp: <07/08/16 09:04:40 ptr> #include "vt_operations.h" @@ -20,15 +20,16 @@ t.add( &vtime_operations::VTMess_core, vt_oper, "VTmess core transfer", tc[2] = t.add( &vtime_operations::gvt_add, vt_oper, "Group VT add", tc[1] ) ); - t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", - t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", - t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", - t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", - t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", - t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", - t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] ) ) ) ) ) ) ) ) ); + t.add( &vtime_operations::remote, vt_oper, "remote", + t.add( &vtime_operations::VTEntryIntoGroup3, vt_oper, "VTEntryIntoGroup3", + t.add( &vtime_operations::VTEntryIntoGroup2, vt_oper, "VTEntryIntoGroup2", + t.add( &vtime_operations::VTEntryIntoGroup, vt_oper, "VTEntryIntoGroup", + t.add( &vtime_operations::VTSubscription, vt_oper, "VTSubscription", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler2", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTHandler1", + t.add( &vtime_operations::VTDispatch2, vt_oper, "VTDispatch2", + t.add( &vtime_operations::VTDispatch1, vt_oper, "VTDispatch1", + t.add( &vtime_operations::vt_object, vt_oper, "VT order", tc[2] )))))))))); return t.girdle(); } Modified: trunk/complement/explore/test/virtual_time/test/vt_operations.h =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-13 15:52:01 UTC (rev 1679) +++ trunk/complement/explore/test/virtual_time/test/vt_operations.h 2007-08-16 18:44:28 UTC (rev 1680) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/11 01:18:35 ptr> +// -*- C++ -*- Time-stamp: <07/08/16 09:02:08 ptr> #ifndef __vt_operations_h #define __vt_operations_h @@ -28,6 +28,8 @@ int EXAM_DECL(VTEntryIntoGroup); int EXAM_DECL(VTEntryIntoGroup2); int EXAM_DECL(VTEntryIntoGroup3); + + int EXAM_DECL(remote); }; #endif // __vt_operations_h Added: trunk/complement/explore/test/virtual_time/test/vt_remote.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_remote.cc (rev 0) +++ trunk/complement/explore/test/virtual_time/test/vt_remote.cc 2007-08-16 18:44:28 UTC (rev 1680) @@ -0,0 +1,194 @@ +// -*- C++ -*- Time-stamp: <07/08/16 10:45:48 ptr> + +#include "vt_operations.h" + +// #include <boost/lexical_cast.hpp> + +#include <iostream> +#include <vtime.h> + +#include <stem/EvManager.h> +#include <stem/NetTransport.h> +#include <sockios/sockmgr.h> +#include <sys/wait.h> + +#include <mt/xmt.h> +#include <mt/shm.h> + +using namespace std; +using namespace stem; +using namespace xmt; +using namespace vt; + +class YaRemote : + public vt::VTHandler +{ + public: + YaRemote(); + YaRemote( stem::addr_type id ); + YaRemote( stem::addr_type id, const char *info ); + ~YaRemote(); + + void handler( const stem::Event& ); + void VSNewMember( const stem::Event_base<VSsync_rq>& ); + void VSOutMember( const stem::Event_base<VSsync_rq>& ); + + void greeting(); + + void wait(); + std::string msg; + int count; + int ocount; + + void wait_greeting() + { + gr.try_wait(); + gr.set( false ); + } + + private: + xmt::condition cnd; + xmt::condition gr; + + DECLARE_RESPONSE_TABLE( YaRemote, vt::VTHandler ); +}; + +#define VS_DUMMY_MESS 0x1203 +#define VS_DUMMY_GREETING 0x1204 + +YaRemote::YaRemote() : + VTHandler(), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id ) : + VTHandler( id ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::YaRemote( stem::addr_type id, const char *info ) : + VTHandler( id, info ), + count(0), + ocount(0) +{ + cnd.set( false ); + gr.set( false ); + + JoinGroup( 0 ); +} + +YaRemote::~YaRemote() +{ + // cnd.wait(); +} + +void YaRemote::handler( const stem::Event& ev ) +{ + msg = ev.value(); + + cnd.set( true ); +} + +void YaRemote::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello " << ev.src() << endl; + ++count; + + // VTNewMember_data( ev, "" ); + VTHandler::VSNewMember( ev ); + + stem::EventVoid gr_ev( VS_DUMMY_GREETING ); + gr_ev.dest( ev.src() ); + Send( gr_ev ); +} + +void YaRemote::VSOutMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // cerr << "Hello" << endl; + ++ocount; +} + +void YaRemote::wait() +{ + cnd.try_wait(); + + cnd.set( false ); +} + +void YaRemote::greeting() +{ + gr.set( true ); +} + +DEFINE_RESPONSE_TABLE( YaRemote ) + EV_EDS( ST_NULL, VS_DUMMY_MESS, handler ) + EV_VOID( ST_NULL, VS_DUMMY_GREETING, greeting ) +END_RESPONSE_TABLE + +int EXAM_IMPL(vtime_operations::remote) +{ + const char fname[] = "/tmp/yanus_test.shm"; + xmt::shm_alloc<0> seg; + xmt::allocator_shm<xmt::__condition<true>,0> shm_cnd; + xmt::allocator_shm<xmt::__barrier<true>,0> shm_b; + + try { + seg.allocate( fname, 4*4096, xmt::shm_base::create | xmt::shm_base::exclusive, 0600 ); + xmt::__barrier<true>& b = *new ( shm_b.allocate( 1 ) ) xmt::__barrier<true>(); + + try { + xmt::fork(); + + b.wait(); + + NetTransportMgr mgr; + + addr_type zero = mgr.open( "localhost", 6980 ); + + EXAM_ASYNC_CHECK( mgr.good() ); + + YaRemote obj2; + + exit(0); + } + catch ( xmt::fork_in_parent& child ) { + sockmgr_stream_MP<NetTransport> srv( 6980 ); + + EXAM_REQUIRE( srv.good() ); + + b.wait(); + + YaRemote obj1; + + int stat; + EXAM_CHECK( waitpid( child.pid(), &stat, 0 ) == child.pid() ); + + srv.close(); + srv.wait(); + } + + (&b)->~__barrier<true>(); + shm_b.deallocate( &b, 1 ); + } + catch ( const xmt::shm_bad_alloc& err ) { + EXAM_ERROR( err.what() ); + } + + seg.deallocate(); + unlink( fname ); + + return EXAM_RESULT; +} + Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-13 15:52:01 UTC (rev 1679) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-16 18:44:28 UTC (rev 1680) @@ -4,6 +4,7 @@ #include <iostream> #include <stdint.h> +#include <stem/EvManager.h> namespace vt { @@ -650,7 +651,7 @@ catch ( ... ) { } #endif // __FIT_VS_TRACE - vt.dpool.push_back( make_pair( 0, new Event_base<VTmess>(m) ) ); // 0 should be timestamp + vt.dpool.push_back( make_pair( xmt::timespec(xmt::timespec::now), new Event_base<VTmess>(m) ) ); // 0 should be timestamp } } @@ -736,9 +737,24 @@ // check local or remote? i->second.addr // if remote, forward it to foreign VTDispatcher? - check_and_send( k->second, m ); - - vt.base_advance(g->second); // store last send VT to obj + try { + /* const transport tr = */ manager()->transport( k->second.stem_addr() ); + gaddr_type ga = manager()->reflect( k->second.stem_addr() ); + if ( ga != gaddr_type() ) { + ga.addr = 2; // vtd + addr_type a = manager()->reflect( ga ); + if ( a == badaddr ) { + a = manager()->SubscribeRemote( ga, "vtd" ); + } + m.dest( a ); + Forward( m ); + vt.base_advance(g->second); // store last send VT to obj + } + } + catch ( const range_error& ) { + check_and_send( k->second, m ); + vt.base_advance(g->second); // store last send VT to obj + } } catch ( const out_of_range& err ) { try { Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-13 15:52:01 UTC (rev 1679) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-16 18:44:28 UTC (rev 1680) @@ -17,6 +17,8 @@ #include <stem/Event.h> #include <stem/EventHandler.h> +#include <mt/time.h> + namespace vt { // typedef stem::addr_type oid_type; @@ -258,7 +260,7 @@ public: // delay pool should be here - typedef std::pair<int,stem::Event_base<VTmess>*> delay_item_t; + typedef std::pair<xmt::timespec,stem::Event_base<VTmess>*> delay_item_t; typedef std::list<delay_item_t> dpool_t; dpool_t dpool; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <com...@us...> - 2007-08-13 15:52:07
|
Revision: 1679 http://complement.svn.sourceforge.net/complement/?rev=1679&view=rev Author: complement Date: 2007-08-13 08:52:01 -0700 (Mon, 13 Aug 2007) Log Message: ----------- more real group number pass Modified Paths: -------------- trunk/complement/explore/test/virtual_time/test/vt_handler.cc trunk/complement/explore/test/virtual_time/vtime.cc trunk/complement/explore/test/virtual_time/vtime.h Modified: trunk/complement/explore/test/virtual_time/test/vt_handler.cc =================================================================== --- trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-13 07:02:36 UTC (rev 1678) +++ trunk/complement/explore/test/virtual_time/test/vt_handler.cc 2007-08-13 15:52:01 UTC (rev 1679) @@ -55,6 +55,8 @@ { cnd.set( false ); gr.set( false ); + + JoinGroup( 0 ); } VTDummy::VTDummy( stem::addr_type id ) : @@ -64,6 +66,8 @@ { cnd.set( false ); gr.set( false ); + + JoinGroup( 0 ); } VTDummy::VTDummy( stem::addr_type id, const char *info ) : @@ -73,6 +77,8 @@ { cnd.set( false ); gr.set( false ); + + JoinGroup( 0 ); } VTDummy::~VTDummy() Modified: trunk/complement/explore/test/virtual_time/vtime.cc =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-13 07:02:36 UTC (rev 1678) +++ trunk/complement/explore/test/virtual_time/vtime.cc 2007-08-13 15:52:01 UTC (rev 1679) @@ -847,6 +847,52 @@ } } +void VTDispatcher::Unsubscribe( oid_type oid ) +{ + // See comment on top of VTSend above + xmt::recursive_scoped_lock lk( this->_theHistory_lock ); + + vt_map_type::iterator i = vtmap.find( oid ); + if ( i != vtmap.end() ) { + list<group_type> grp_list; + i->second.groups_list( back_inserter( grp_list ) ); + for ( list<group_type>::const_iterator grp = grp_list.begin(); grp != grp_list.end(); ++grp ) { + + pair<gid_map_type::iterator,gid_map_type::iterator> range = + grmap.equal_range( *grp ); + + while ( range.first != range.second ) { + if ( range.first->second == oid ) { + grmap.erase( range.first++ ); + } else { + vt_map_type::iterator j = vtmap.find( range.first->second ); + if ( j != vtmap.end() ) { + stem::Event_base<VSsync_rq> ev( VS_OUT_MEMBER ); + ev.dest( j->second.stem_addr() ); + ev.src( i != vtmap.end() ? i->second.stem_addr() : self_id() ); + ev.value().grp = *grp; +#ifdef __FIT_VS_TRACE + try { + scoped_lock lk(_lock_tr); + if ( _trs != 0 && _trs->good() && (_trflags & tracegroup) ) { + *_trs << "VS_OUT_MEMBER " << ev.src() << " -> " << ev.dest() << endl; + } + } + catch ( ... ) { + } +#endif // __FIT_VS_TRACE + + Forward( ev ); + } + ++range.first; + } + } + i->second.rm_group( *grp ); + } + vtmap.erase( i ); + } +} + void VTDispatcher::get_gvtime( group_type grp, stem::addr_type addr, gvtime_type& gvt ) { // See comment on top of VTSend above @@ -979,7 +1025,7 @@ { new( Init_buf ) Init(); - _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); + // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( const char *info ) : @@ -987,7 +1033,7 @@ { new( Init_buf ) Init(); - _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); + // _vtdsp->Subscribe( self_id(), oid_type( self_id() ), /* grp */ 0 ); } VTHandler::VTHandler( stem::addr_type id, const char *info ) : @@ -995,12 +1041,12 @@ { new( Init_buf ) Init(); - _vtdsp->Subscribe( id, oid_type( id ), /* grp */ 0 ); + // _vtdsp->Subscribe( id, oid_type( id ), /* grp */ 0 ); } VTHandler::~VTHandler() { - _vtdsp->Unsubscribe( oid_type( self_id() ), /* grp */ 0 ); + _vtdsp->Unsubscribe( oid_type( self_id() ) ); ((Init *)Init_buf)->~Init(); } Modified: trunk/complement/explore/test/virtual_time/vtime.h =================================================================== --- trunk/complement/explore/test/virtual_time/vtime.h 2007-08-13 07:02:36 UTC (rev 1678) +++ trunk/complement/explore/test/virtual_time/vtime.h 2007-08-13 15:52:01 UTC (rev 1679) @@ -220,6 +220,10 @@ bool rm_group( group_type ); void rm_member( const oid_type& ); + template <typename BackInsertIterator> + void groups_list( BackInsertIterator bi ) const + { std::copy( groups.begin(), groups.end(), bi ); } + stem::addr_type stem_addr() const { return addr; } @@ -307,6 +311,7 @@ void VTSend( const stem::Event& e, group_type ); void Subscribe( stem::addr_type, oid_type, group_type ); void Unsubscribe( oid_type, group_type ); + void Unsubscribe( oid_type ); void get_gvtime( group_type, stem::addr_type, gvtime_type& ); void set_gvtime( group_type, stem::addr_type, const gvtime_type& ); @@ -357,6 +362,8 @@ virtual ~VTHandler(); void VTSend( const stem::Event& e ); + void JoinGroup( group_type grp ) + { _vtdsp->Subscribe( self_id(), oid_type( self_id() ), grp ); } virtual void VSNewMember( const stem::Event_base<VSsync_rq>& e ); virtual void VSOutMember( const stem::Event_base<VSsync_rq>& e ); virtual void VSsync_time( const stem::Event_base<VSsync>& ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |