My Project
|
a task pool is a collection of requests of which only a specified limited number of worker threads are allowed to process. More...
#include <NPLNetClient.h>
Classes | |
class | CUrlWorkerState |
url worker state. More... | |
Public Member Functions | |
bool | AppendURLRequest (CURLRequestTask *pUrlTask) |
Append URL request to a pool. More... | |
int | DoProcess () |
process queued tasks and if any has result, call the callback procedure. More... | |
void | SetMaxTaskSlotsCount (int nCount) |
set maximum number of concurrent task being processed. More... | |
Protected Member Functions | |
CUrlWorkerState * | GetFreeWorkerSlot () |
get the next free worker thread. More... | |
int | CURL_MultiPerform () |
do the multi interface. More... | |
a task pool is a collection of requests of which only a specified limited number of worker threads are allowed to process.
for example, we can create a task pool for each type of URL requests, and assign the max number of processors allowed.
Implementation Details:
The main game (scripting) thread pushes any number of URL request to a pool of CURLRequestTask and returns immediately.
On each frame move
bool ParaEngine::CRequestTaskPool::AppendURLRequest | ( | CURLRequestTask * | pUrlTask | ) |
Append URL request to a pool.
pUrlTask | must be new CURLRequestTask(), the ownership of the task is transfered to the manager. so the caller should never delete the pointer. |
|
protected |
do the multi interface.
This function should be called regularly to process the result using the multi interface.
int ParaEngine::CRequestTaskPool::DoProcess | ( | ) |
process queued tasks and if any has result, call the callback procedure.
return the number of processed result.
|
protected |
get the next free worker thread.
Pass a long. It should contain the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to disable connection timeout (it will then only timeout on the system's internal timeouts). See also the CURLOPT_TIMEOUT option
void ParaEngine::CRequestTaskPool::SetMaxTaskSlotsCount | ( | int | nCount | ) |
set maximum number of concurrent task being processed.
default is 1.