コード例 #1
0
        void run( const po::variables_map &params )
        {

            typedef std::vector<std::string> string_vector;
            typedef string_vector::const_iterator vec_citer;

            string_vector ser = params["server"].as<string_vector>( );

            if( params.count( "key" ) ) {
                app_.key_ = params["key"].as<std::string>( );
            }

            dumb_proto_ = !!params.count( "dumb" );

            bool use_only_pool = !!params.count( "only-pool" );
            bool tcp_nodelay   = !!params.count( "tcp-nodelay" );

            rpc::session_options opts( options( params ) );

            unsigned retry_to = (params.count( "accept-retry" ) != 0)
                    ? params["accept-retry"].as<unsigned>( )
                    : 1000;

            if( params.count( "max-clients" ) ) {
                max_clients_ = params["max-clients"].as<unsigned>( );
            }

            for( vec_citer b(ser.begin( )), e(ser.end( )); b != e; ++b ) {

                std::cout << "Starting listener at '" <<  *b << "'...";
                attach_start_listener( retry_to,
                    create_from_string( *b, app_, opts, tcp_nodelay) );
                std::cout << "Ok\n";

            }

            start_counter_timer( 0 );
            if( use_only_pool ) {
                pp_.get_io_pool( ).attach( );
            } else {
                pp_.get_rpc_pool( ).attach( );
            }
            counter_timer_.cancel( );
            pp_.join_all( );
        }
コード例 #2
0
 impl( unsigned io_threads, unsigned rpc_threads )
     :pp_(io_threads, rpc_threads)
     ,app_(pp_)
     ,counter_(0)
     ,retry_timer_(pp_.get_io_service( ))
     ,accept_errors_(0)
     ,max_clients_(1000)
     ,next_id_(0)
     ,timer_pool_(1)
     ,dumb_proto_(false)
     ,counter_timer_(timer_pool_.get_io_service( ))
 { }
コード例 #3
0
        void stop( )
        {
            std::cout << "Stopping server ...";

            timer_pool_.stop( );
            timer_pool_.join_all( );

            typedef std::vector<server::listener_sptr>::const_iterator citer;
            for( citer b(listeners_.begin( )), e(listeners_.end( )); b!=e; ++b){
                (*b)->stop( );
            }
            retry_timer_.cancel( );
            pp_.stop_all( );
            std::cout << "Ok\n";
        }
コード例 #4
0
ファイル: vtrc-application.cpp プロジェクト: malchemist/vtrc
    application::application(common::pool_pair &pools)
     :impl_(new impl(&pools.get_io_service( ), &pools.get_rpc_service( )))
    {

    }