Skip to content

Commit

Permalink
sample5增加设置网络线程数接口
Browse files Browse the repository at this point in the history
  • Loading branch information
yyzybb537 committed Jan 15, 2019
1 parent 0f5ccf6 commit cf31088
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tutorial/sample5_asio.cpp
Expand Up @@ -11,6 +11,11 @@
#include "coroutine.h"
#include "win_exit.h"

// 设置网络线程数 (仅支持linux & mac)
#if defined(LIBGO_SYS_Unix)
#include "netio/unix/reactor.h"
#endif

static const uint16_t port = 43332;
using namespace boost::asio;
using namespace boost::asio::ip;
Expand Down Expand Up @@ -79,6 +84,11 @@ void client(tcp::endpoint const& addr)

int main()
{
// 设置网络线程数 (仅支持linux & mac)
#if defined(LIBGO_SYS_Unix)
co::Reactor::InitializeReactorCount(2);
#endif

for (int i = 0; i < 5; ++i) {
tcp::endpoint addr(address::from_string("127.0.0.1"), port + i);
go [addr]{ echo_server(addr); };
Expand Down

0 comments on commit cf31088

Please sign in to comment.