[complement-svn] SF.net SVN: complement: [1775] trunk/complement/explore/lib/janus/samples
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-10-24 16:54:38
|
Revision: 1775 http://complement.svn.sourceforge.net/complement/?rev=1775&view=rev Author: complement Date: 2007-10-24 09:54:36 -0700 (Wed, 24 Oct 2007) Log Message: ----------- what price of VS, in terms of memory? Added Paths: ----------- trunk/complement/explore/lib/janus/samples/sz/ trunk/complement/explore/lib/janus/samples/sz/Makefile trunk/complement/explore/lib/janus/samples/sz/Makefile.inc trunk/complement/explore/lib/janus/samples/sz/sz.cc Property changes on: trunk/complement/explore/lib/janus/samples/sz ___________________________________________________________________ Name: svn:ignore + obj Added: trunk/complement/explore/lib/janus/samples/sz/Makefile =================================================================== --- trunk/complement/explore/lib/janus/samples/sz/Makefile (rev 0) +++ trunk/complement/explore/lib/janus/samples/sz/Makefile 2007-10-24 16:54:36 UTC (rev 1775) @@ -0,0 +1,26 @@ +# -*- 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} + +release-shared: PROJECT_LIBS = -lxmt -lsockios -lstem -ljanus +dbg-shared: PROJECT_LIBS = -lxmtg -lsockiosg -lstemg -ljanusg +ifndef WITHOUT_STLPORT +stldbg-shared: PROJECT_LIBS = -lxmtstlg -lsockiosstlg -lstemstlg -ljanusstlg +endif + +dbg-shared: DEFS += -D__FIT_VS_TRACE +ifndef WITHOUT_STLPORT +stldbg-shared: DEFS += -D__FIT_VS_TRACE +endif + +LDLIBS = -L${CoMT_LIB_DIR} -Wl,-rpath=${CoMT_LIB_DIR}:${STLPORT_LIB_DIR} ${PROJECT_LIBS} + Added: trunk/complement/explore/lib/janus/samples/sz/Makefile.inc =================================================================== --- trunk/complement/explore/lib/janus/samples/sz/Makefile.inc (rev 0) +++ trunk/complement/explore/lib/janus/samples/sz/Makefile.inc 2007-10-24 16:54:36 UTC (rev 1775) @@ -0,0 +1,5 @@ +# -*- Makefile -*- + +PRGNAME = sz + +SRC_CC = sz.cc Added: trunk/complement/explore/lib/janus/samples/sz/sz.cc =================================================================== --- trunk/complement/explore/lib/janus/samples/sz/sz.cc (rev 0) +++ trunk/complement/explore/lib/janus/samples/sz/sz.cc 2007-10-24 16:54:36 UTC (rev 1775) @@ -0,0 +1,135 @@ +// -*- C++ -*- Time-stamp: <07/08/26 12:54:05 ptr> + +#include <janus/vtime.h> +#include <janus/janus.h> +#include <janus/vshostmgr.h> + +#include <stem/EvManager.h> + +#include <mt/xmt.h> + +#include <iostream> +#include <string> + +using namespace janus; +using namespace std; +using namespace xmt; +using namespace stem; + +#define VS_LINE 0x1300 + +class YaSample : + public janus::VTHandler +{ + public: + YaSample(); + YaSample( stem::addr_type id, const char *info = 0 ); + YaSample( const char *info ); + ~YaSample(); + + private: + void vs_line( const stem::Event& ); + + virtual void VSNewMember( const stem::Event_base<VSsync_rq>& ); + virtual void VSOutMember( const stem::Event_base<VSsync_rq>& ); + virtual void VSsync_time( const stem::Event_base<VSsync>& ); + + + DECLARE_RESPONSE_TABLE( YaSample, janus::VTHandler ); +}; + +YaSample::YaSample() : + janus::VTHandler() +{ +} + +YaSample::YaSample( stem::addr_type id, const char *info ) : + janus::VTHandler( id, info ) +{ +} + +YaSample::YaSample( const char *info ) : + janus::VTHandler( info ) +{ +} + +YaSample::~YaSample() +{ +} + +void YaSample::VSNewMember( const stem::Event_base<VSsync_rq>& ev ) +{ + // VTNewMember_data( ev, "" ); + // cerr << "new member" << endl; + VTHandler::VSNewMember( ev ); +} + +void YaSample::VSOutMember( const stem::Event_base<VSsync_rq>& ) +{ + // cerr << "member out" << endl; +} + +void YaSample::VSsync_time( const stem::Event_base<VSsync>& ev ) +{ + // cout << "VSsync_time" << endl; + VTHandler::VSsync_time( ev ); +} + +void YaSample::vs_line( const stem::Event& ev ) +{ + // cerr << "Line here: '" << ev.value() << "'" << endl; +} + +DEFINE_RESPONSE_TABLE( YaSample ) + EV_EDS( ST_NULL, VS_LINE, vs_line ) +END_RESPONSE_TABLE + +int main() +{ + VSHostMgr::add_srvport( 6700 ); + VSHostMgr::add_wellknown( "island.corbina.net:6700" ); + + YaSample sample; + + // sample.manager()->settrf( stem::EvManager::tracenet | stem::EvManager::tracedispatch | stem::EvManager::tracefault ); + // sample.manager()->settrs( &std::cerr ); + + // sample.vtdispatcher()->settrf( janus::Janus::tracenet | janus::Janus::tracedispatch | janus::Janus::tracefault | janus::Janus::tracedelayed | janus::Janus::tracegroup ); + // sample.vtdispatcher()->settrs( &std::cerr ); + + sample.JoinGroup( janus::vs_base::first_user_group ); + + for ( int i = 0; i < 50000; ++i ) { + YaSample *s = new YaSample; + s->JoinGroup( janus::vs_base::first_user_group + i + 1 ); + } + + cout << "ready" << endl; + + Event ev( VS_LINE ); + ev.dest( janus::vs_base::first_user_group ); + + string line; + + while ( cin.good() ) { + getline( cin, line ); + if ( !cin.fail() ) { + cerr << "local: " << line << endl; + ev.value() = line; + try { + sample.JaSend( ev ); + } + catch ( std::domain_error& err ) { + cerr << err.what() << endl; + } + } + } + + // condition cnd; + + // cnd.set( false ); + + // cnd.wait(); + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |