Condividi tramite


CNonStatelessWorker Class

Receives requests from a thread pool and passes them on to a worker object that is created and destroyed on each request.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template < 
class Worker 
> 
class CNonStatelessWorker

Parameters

Members

Public Typedefs

Name

Description

CNonStatelessWorker::RequestType

Implementation of WorkerArchetype::RequestType.

Public Methods

Name

Description

CNonStatelessWorker::Execute

Implementation of WorkerArchetype::Execute.

CNonStatelessWorker::Initialize

Implementation of WorkerArchetype::Initialize.

CNonStatelessWorker::Terminate

Implementation of WorkerArchetype::Terminate.

Remarks

This class is a simple worker thread for use with CThreadPool. This class doesn't provide any request-handling capabilities of its own. Instead, it instantiates one instance of Worker per request and delegates the implementation of its methods to that instance.

The benefit of this class is that it provides a convenient way to change the state model for existing worker thread classes. CThreadPool will create a single worker for the lifetime of the thread, so if the worker class holds state, it will hold it across multiple requests. By simply wrapping that class in the CNonStatelessWorker template before using it with CThreadPool, the lifetime of the worker and the state it holds is limited to a single request.

Requirements

Header: atlutil.h

See Also

Reference

CThreadPool Class

Worker Archetype

Other Resources

ATL Classes