Share Thread Pool that has same host module in a server.

Usually server-side host module works in one process such as CLanServer, CLanClient, CNetServer. This server-side host module owned Thread pool that composed at least 1 thread.

However, you may want to share specific thread pool rather than those thread pool owned by each modules. This explain how you can do that.

thread_pool_sharing.png
Example of sharing same Thread Pool with other host module in a server.

Please write applicaion to excute 'Share Thread Pool with host modules in a server'

  • First, creates thread pool object clearly with Proud::CThreadPool::Create(). User creates thread pool manually.
  • If you want, connect event callback that occur from thread pool with Proud::CThreadPool::SetEventSink.
  • Then, activate thread pool with Proud::CThreadPool::Start
  • Then, send thread pool object with parameter of Proud::CNetServer::Start, Proud::CLanServer::Start, Proud::CLanClient::Connect
  • Do not user destruct created thread pool object before you destruct all server-side host modules. Otherwise it will occurs throw exception.

Example

tp->SetEventSink(...);
tp->Start();
Proud::CNetServer* server = Proud::ProudNet::CreateServer();
...
server->Start(p);

Note:

  • sever-side host modules have user worker thread pool and networker thread pool. Normally it is refered to user created thread pool by user worker thread pool. However, networker thread pool can use user created thread pool to improve performance. For this case, methods that callback from user created thread pool have to finish processing as quick as possible. Otherwise, you will get wrong internal ping measurment or client will disconnect from server.