예제 #1
0
int main() {
    IOLoop loop;
    shared_ptr<HttpClient> client = make_shared<HttpClient>(&loop);
    client->request("http://127.0.0.1:11192/", bind(&onResponse, &loop, _1));
    loop.start();
    printf("exit\n");
    return 0;
}
예제 #2
0
int main()
{
    IOLoop loop;
    WsClientPtr_t client = std::make_shared<WsClient>(&loop);
    
    client->connect("ws://127.0.0.1:11181/push/ws", std::bind(&onWsConnEvent, _1, _2, _3));
    
    loop.start();
    
    return 0;    
}
예제 #3
0
int main(int argc, char* args[])
{
    Log::rootLog().setLevel(Log::ERROR);
  
    if(argc < 2)
    {
        cout << "args: num [eth0]" << endl;
    }

    int num = num = atoi(args[1]);

    vector<HttpClientPtr_t> clients;

    IOLoop loop;
    
    if(argc == 2)
    {
        clients.push_back(std::make_shared<HttpClient>(&loop));
    }
    else
    {
        for(int i = 0; i < argc - 2; ++i)
        {
            HttpClientPtr_t client = std::make_shared<HttpClient>(&loop);
            client->bindDevice(args[i + 2]);
            clients.push_back(client);
        }
    }

    cout << "request num:" << num << endl;


    TimingWheelPtr_t wheel = std::make_shared<TimingWheel>(1000, 3600);

    int c = 60 * clients.size();
    for(int i = 0; i < c; ++i)
    {
        int reqNum = num / c;
        for(auto it = clients.begin(); it != clients.end(); ++it)
        {
            wheel->add(std::bind(&request, _1, *it, reqNum), i * 1000);
        }
    }

    wheel->start(&loop);

    loop.start();

    return 0;
}
예제 #4
0
int main()
{

    IOLoop loop;

    run(&loop);

    cout << "start" << endl;

    loop.start();

    cout << "end" << endl;

    return 0;
    
}
예제 #5
0
int main()
{
    IOLoop loop;

    TimingWheelPtr_t t = std::make_shared<TimingWheel>(1000, 20);

    t->add(std::bind(&onWheel, _1, 1), 1000);
    t->add(std::bind(&onWheel, _1, 2), 2000);

    t->start(&loop);

    cout << "start" << endl;
    loop.start();

    t->stop();

    cout << "end" << endl;

    return 0;
}