eq::base::RequestHandler Class Reference

A request handler. More...

#include <requestHandler.h>

Inheritance diagram for eq::base::RequestHandler:
Inheritance graph
[legend]
Collaboration diagram for eq::base::RequestHandler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RequestHandler (const bool threadSafe=false)
 Construct a new request handler.
 ~RequestHandler ()
 Destruct the request handler.
uint32_t registerRequest (void *data=0)
 Register a new request.
void unregisterRequest (const uint32_t requestID)
 Unregister a request.
bool waitRequest (const uint32_t requestID, void *&result, const uint32_t timeout=EQ_TIMEOUT_INDEFINITE)
 Wait a given time for the completion of a request.
bool waitRequest (const uint32_t requestID, uint32_t &result, const uint32_t timeout=EQ_TIMEOUT_INDEFINITE)
 Wait for a request with a uint32_t result.
bool waitRequest (const uint32_t requestID, bool &result, const uint32_t timeout=EQ_TIMEOUT_INDEFINITE)
 Wait for a request with a bool result.
bool waitRequest (const uint32_t requestID)
 Wait for a request without a result.
bool isServed (const uint32_t requestID) const
 Poll for the completion of a request.
void * getRequestData (const uint32_t requestID)
 Retrieve the user-specific data for a request.
void serveRequest (const uint32_t requestID, void *result=0)
 Serve a request with a void* result.
void serveRequest (const uint32_t requestID, uint32_t result)
 Serve a request with a uint32_t result.
void serveRequest (const uint32_t requestID, bool result)
 Serve a request with a bool result.
bool isThreadSafe () const
bool isEmpty () const

Detailed Description

A request handler.

Different execution threads can synchronize using a request handler. One thread registers a request, and later waits for the request to be served. Another thread can serve the request, providing a result value.

A note on thread-safety: Unless threadSafe is set in the constructor, the functions registerRequest(), unregisterRequest() and waitRequest() are supposed to be called from one 'waiting' thread, and the functions serveRequest() and deleteRequest() are supposed to be called only from one 'serving' thread.

Definition at line 47 of file requestHandler.h.


Constructor & Destructor Documentation

eq::base::RequestHandler::RequestHandler ( const bool  threadSafe = false  ) 

Construct a new request handler.

Parameters:
threadSafe if true, all public functions are thread-safe and can be called from multiple threads.
Version:
1.0

Definition at line 32 of file requestHandler.cpp.

eq::base::RequestHandler::~RequestHandler (  ) 

Destruct the request handler.

Definition at line 37 of file requestHandler.cpp.


Member Function Documentation

uint32_t eq::base::RequestHandler::registerRequest ( void *  data = 0  ) 
void eq::base::RequestHandler::unregisterRequest ( const uint32_t  requestID  ) 

Unregister a request.

Note that waitRequest automatically unregisters the request when it was successful. This method is only used when a waitRequest has timed out and the request will no longer be used.

Parameters:
requestID the request identifier.
Version:
1.0

Definition at line 72 of file requestHandler.cpp.

References eq::base::Lock::unset().

Referenced by eq::net::Node::syncConnect().

Here is the call graph for this function:

Here is the caller graph for this function:

bool eq::base::RequestHandler::waitRequest ( const uint32_t  requestID,
void *&  result,
const uint32_t  timeout = EQ_TIMEOUT_INDEFINITE 
)

Wait a given time for the completion of a request.

The request is unregistered upon successful completion, i.e, the when the method returns true.

Parameters:
requestID the request identifier.
result the result code of the operation.
timeout the timeout in milliseconds to wait for the request, or EQ_TIMEOUT_INDEFINITE to wait indefinitely.
Returns:
true if the request was served, false if not.
Version:
1.0

Definition at line 90 of file requestHandler.cpp.

Referenced by eq::net::Node::_connect(), eq::net::Session::attachObject(), eq::Server::chooseConfig(), eq::net::Node::close(), eq::net::UnbufferedMasterCM::commitSync(), eq::net::FullMasterCM::commitSync(), eq::net::Session::detachObject(), eq::Config::exit(), eq::net::Session::genIDs(), eq::net::Session::getIDMaster(), eq::Config::init(), eq::net::Session::mapObjectSync(), eq::net::Node::mapSession(), eq::net::Node::registerSession(), eq::Server::releaseConfig(), eq::Server::shutdown(), eq::net::Node::syncConnect(), eq::server::Config::unmap(), eq::net::Session::unmapObject(), eq::net::Node::unmapSession(), and eq::Server::useConfig().

Here is the caller graph for this function:

bool eq::base::RequestHandler::waitRequest ( const uint32_t  requestID,
uint32_t &  result,
const uint32_t  timeout = EQ_TIMEOUT_INDEFINITE 
)

Wait for a request with a uint32_t result.

Version:
1.0

Definition at line 100 of file requestHandler.cpp.

bool eq::base::RequestHandler::waitRequest ( const uint32_t  requestID,
bool &  result,
const uint32_t  timeout = EQ_TIMEOUT_INDEFINITE 
)

Wait for a request with a bool result.

Version:
1.0

Definition at line 110 of file requestHandler.cpp.

bool eq::base::RequestHandler::waitRequest ( const uint32_t  requestID  ) 

Wait for a request without a result.

Version:
1.0

Definition at line 120 of file requestHandler.cpp.

References EQ_TIMEOUT_INDEFINITE.

bool eq::base::RequestHandler::isServed ( const uint32_t  requestID  )  const

Poll for the completion of a request.

Does not unregister the request.

Parameters:
requestID the request identifier.
Returns:
true if the request has been served, false if it is pending.
Version:
1.0

Definition at line 205 of file requestHandler.cpp.

Referenced by eq::Server::chooseConfig(), eq::Config::exit(), eq::Config::init(), eq::Server::releaseConfig(), eq::Server::shutdown(), and eq::Server::useConfig().

Here is the caller graph for this function:

void * eq::base::RequestHandler::getRequestData ( const uint32_t  requestID  ) 

Retrieve the user-specific data for a request.

Parameters:
requestID the request identifier.
Returns:
the user-specific data for the request.
Version:
1.0

Definition at line 155 of file requestHandler.cpp.

Referenced by eq::net::Session::mapObjectSync().

Here is the caller graph for this function:

void eq::base::RequestHandler::serveRequest ( const uint32_t  requestID,
void *  result = 0 
)

Serve a request with a void* result.

Parameters:
requestID the request identifier.
result the result of the request.
Version:
1.0

Definition at line 165 of file requestHandler.cpp.

References eq::base::Lock::set(), and eq::base::Lock::unset().

Here is the call graph for this function:

void eq::base::RequestHandler::serveRequest ( const uint32_t  requestID,
uint32_t  result 
)

Serve a request with a uint32_t result.

Version:
1.0

Definition at line 178 of file requestHandler.cpp.

References eq::base::Lock::set(), and eq::base::Lock::unset().

Here is the call graph for this function:

void eq::base::RequestHandler::serveRequest ( const uint32_t  requestID,
bool  result 
)

Serve a request with a bool result.

Version:
1.0

Definition at line 191 of file requestHandler.cpp.

References eq::base::Lock::set(), and eq::base::Lock::unset().

Here is the call graph for this function:

bool eq::base::RequestHandler::isThreadSafe (  )  const [inline]
Returns:
true if this request handler was created thread-safe.
Version:
1.0

Definition at line 148 of file requestHandler.h.

bool eq::base::RequestHandler::isEmpty (  )  const [inline]
Returns:
true if this request handler has no pending requests.
Version:
1.0

Definition at line 154 of file requestHandler.h.

Referenced by eq::net::Node::close(), and eq::net::Node::~Node().

Here is the caller graph for this function:


The documentation for this class was generated from the following files:
Generated on Sat Feb 6 13:08:23 2010 for Equalizer 0.9.1 by  doxygen 1.6.1