My Project
Classes | Public Member Functions | Protected Member Functions | List of all members
ParaEngine::CRequestTaskPool Class Reference

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

CUrlWorkerStateGetFreeWorkerSlot ()
 get the next free worker thread. More...
 
int CURL_MultiPerform ()
 do the multi interface. More...
 

Detailed Description

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

Member Function Documentation

§ AppendURLRequest()

bool ParaEngine::CRequestTaskPool::AppendURLRequest ( CURLRequestTask pUrlTask)

Append URL request to a pool.

Parameters
pUrlTaskmust be new CURLRequestTask(), the ownership of the task is transfered to the manager. so the caller should never delete the pointer.

§ CURL_MultiPerform()

int ParaEngine::CRequestTaskPool::CURL_MultiPerform ( )
protected

do the multi interface.

This function should be called regularly to process the result using the multi interface.

Returns
:the number of slots finished during this perform.

§ DoProcess()

int ParaEngine::CRequestTaskPool::DoProcess ( )

process queued tasks and if any has result, call the callback procedure.

return the number of processed result.

§ GetFreeWorkerSlot()

ParaEngine::CRequestTaskPool::CUrlWorkerState * ParaEngine::CRequestTaskPool::GetFreeWorkerSlot ( )
protected

get the next free worker thread.

Parameters

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

§ SetMaxTaskSlotsCount()

void ParaEngine::CRequestTaskPool::SetMaxTaskSlotsCount ( int  nCount)

set maximum number of concurrent task being processed.

default is 1.


The documentation for this class was generated from the following files: