Sirikata
|
IOService provides queuing, processing, and dispatch for asynchronous IO, including timers, sockets, resolvers, and simple tasks. More...
#include <IOService.hpp>
Public Member Functions | |
IOService (const String &name) | |
~IOService () | |
const String & | name () const |
Get the name of this IOService. | |
InternalIOService & | asioService () |
Get the underlying IOService. | |
const InternalIOService & | asioService () const |
Get the underlying IOService. | |
IOStrand * | createStrand (const String &name) |
Creates a new IOStrand. | |
uint32 | pollOne () |
Run at most one handler in the event queue. | |
uint32 | poll () |
Run as many handlers as can be executed without blocking. | |
uint32 | runOne () |
Run at most one handler, blocking if appropriate. | |
uint32 | run () |
Run as many handlers as are available, blocking as appropriate. | |
void | runNoReturn () |
Run as many handlers as are available, blocking as appropriate. | |
void | stop () |
Stop event processing, cancelling events as necessary. | |
void | reset () |
Reset the event processing, discarding events as necessary and preparing it for additional run/runOne/poll/pollOne calls. | |
void | dispatch (const IOCallback &handler, const char *tag=NULL, const char *tagStat=NULL) |
Request that the given handler be invoked, possibly before returning. | |
void | post (const IOCallback &handler, const char *tag=NULL, const char *tagStat=NULL) |
Request that the given handler be appended to the event queue and invoked later. | |
void | post (const Duration &waitFor, const IOCallback &handler, const char *tag=NULL, const char *tagStat=NULL) |
Request that the given handler be appended to the event queue and invoked later. | |
void | commandReportStats (const Command::Command &cmd, Command::Commander *cmdr, Command::CommandID cmdid) |
Static Public Member Functions | |
static void | commandReportAllStats (const Command::Command &cmd, Command::Commander *cmdr, Command::CommandID cmdid) |
Private Member Functions | |
IOService (const IOService &) | |
Private Attributes | |
InternalIOService * | mImpl |
const String | mName |
Friends | |
class | IOServiceFactory |
class | IOStrand |
class | InternalIOStrand |
class | InternalIOWork |
class | TCPSocket |
class | TCPListener |
class | TCPResolver |
class | UDPSocket |
class | UDPResolver |
class | DeadlineTimer |
class | IOTimer |
IOService provides queuing, processing, and dispatch for asynchronous IO, including timers, sockets, resolvers, and simple tasks.
Note that currently you cannot add your own services to this. Therefore, the only way to extend the abilities of the IOService is via the existing mechanisms -- the default implementations for sockets and timers or via periodic tasks.
Sirikata::Network::IOService::IOService | ( | const IOService & | ) | [private] |
Sirikata::Network::IOService::IOService | ( | const String & | name | ) |
References mImpl.
Sirikata::Network::IOService::~IOService | ( | ) |
References mImpl.
InternalIOService& Sirikata::Network::IOService::asioService | ( | ) | [inline] |
Get the underlying IOService.
Only made available to allow for efficient implementation of ASIO provided functionality such as tcp/udp sockets and deadline timers.
Referenced by Sirikata::RedisObjectSegmentation::connect().
const InternalIOService& Sirikata::Network::IOService::asioService | ( | ) | const [inline] |
Get the underlying IOService.
Only made available to allow for efficient implementation of ASIO provided functionality such as tcp/udp sockets and deadline timers.
void Sirikata::Network::IOService::commandReportAllStats | ( | const Command::Command & | cmd, |
Command::Commander * | cmdr, | ||
Command::CommandID | cmdid | ||
) | [static] |
References Sirikata::Command::EmptyResult(), and Sirikata::Command::Commander::result().
Referenced by Sirikata::Context::setCommander().
void Sirikata::Network::IOService::commandReportStats | ( | const Command::Command & | cmd, |
Command::Commander * | cmdr, | ||
Command::CommandID | cmdid | ||
) |
References Sirikata::Command::EmptyResult(), and Sirikata::Command::Commander::result().
Referenced by Sirikata::Context::setCommander().
IOStrand * Sirikata::Network::IOService::createStrand | ( | const String & | name | ) |
void Sirikata::Network::IOService::dispatch | ( | const IOCallback & | handler, |
const char * | tag = NULL , |
||
const char * | tagStat = NULL |
||
) |
Request that the given handler be invoked, possibly before returning.
handler | the handler callback to be called |
tag | a string descriptor of the handler for debugging |
References mImpl.
const String& Sirikata::Network::IOService::name | ( | ) | const [inline] |
Get the name of this IOService.
Referenced by Sirikata::Network::IOServicePool::run().
uint32 Sirikata::Network::IOService::poll | ( | ) |
Run as many handlers as can be executed without blocking.
References mImpl.
Referenced by Sirikata::CoordinateSegmentationClient::service(), and Sirikata::AsyncCraq::tick().
uint32 Sirikata::Network::IOService::pollOne | ( | ) |
Run at most one handler in the event queue.
References mImpl.
void Sirikata::Network::IOService::post | ( | const IOCallback & | handler, |
const char * | tag = NULL , |
||
const char * | tagStat = NULL |
||
) |
Request that the given handler be appended to the event queue and invoked later.
The handler will not be invoked during this method call.
handler | the handler callback to be called |
tag | a string descriptor of the handler for debugging |
References mImpl.
Referenced by Sirikata::OH::CassandraStorage::commitTransaction(), Sirikata::OH::SQLiteStorage::count(), Sirikata::OH::CassandraStorage::count(), Sirikata::HttpServerIDMap::finishLookup(), Sirikata::Context::handleSignal(), Sirikata::TabularServerIDMap::lookupExternal(), Sirikata::LocalServerIDMap::lookupExternal(), Sirikata::TabularServerIDMap::lookupInternal(), Sirikata::LocalServerIDMap::lookupInternal(), Sirikata::TabularServerIDMap::lookupRandomExternal(), Sirikata::LocalServerIDMap::lookupRandomExternal(), Sirikata::JS::JSObjectScriptManager::meshDownloaded(), Sirikata::Graphics::OgreRenderer::parseMesh(), Sirikata::Network::IOStrand::post(), Sirikata::Transfer::HttpManager::postCallback(), Sirikata::OH::SQLiteStorage::postProcessTransactions(), Sirikata::OH::SQLiteStorage::releaseBucket(), Sirikata::OH::CassandraStorage::releaseBucket(), Sirikata::OH::SQLitePersistedObjectSet::requestPersistedObject(), Sirikata::OH::CassandraPersistedObjectSet::requestPersistedObject(), Sirikata::HttpServerIDMap::retryOrFail(), Sirikata::OH::SQLiteStorage::start(), Sirikata::OH::SQLitePersistedObjectSet::start(), Sirikata::OH::CassandraStorage::start(), and Sirikata::OH::CassandraPersistedObjectSet::start().
void Sirikata::Network::IOService::post | ( | const Duration & | waitFor, |
const IOCallback & | handler, | ||
const char * | tag = NULL , |
||
const char * | tagStat = NULL |
||
) |
Request that the given handler be appended to the event queue and invoked later.
Regardless of the wait duration requested, the handler will never be invoked during this method call.
waitFor | the length of time to wait before invoking the handler |
handler | the handler callback to be called |
tag | a string descriptor of the handler for debugging |
References Sirikata::Logging::error, mImpl, Sirikata::Timer::now(), and SILOG.
void Sirikata::Network::IOService::reset | ( | ) |
Reset the event processing, discarding events as necessary and preparing it for additional run/runOne/poll/pollOne calls.
References mImpl.
Referenced by Sirikata::Network::IOServicePool::reset(), and Sirikata::AsyncCraq::tick().
uint32 Sirikata::Network::IOService::run | ( | ) |
Run as many handlers as are available, blocking as appropriate.
This will not return unless no more work is available.
References mImpl.
Referenced by Sirikata::AggregateManager::aggregationThreadMain(), Sirikata::Context::run(), Sirikata::AggregateManager::uploadThreadMain(), and Sirikata::Context::workerThread().
void Sirikata::Network::IOService::runNoReturn | ( | ) |
Run as many handlers as are available, blocking as appropriate.
This will not return unless no more work is available. Don't return a value. Useful with std::tr1::bind where the return value is discared.
References mImpl.
Referenced by Sirikata::Graphics::OgreRenderer::initialize(), Sirikata::JS::JSObjectScriptManager::JSObjectScriptManager(), Sirikata::OH::SQLiteStorage::start(), Sirikata::OH::SQLitePersistedObjectSet::start(), Sirikata::OH::CassandraStorage::start(), Sirikata::OH::CassandraPersistedObjectSet::start(), and Sirikata::Context::startForceQuitTimer().
uint32 Sirikata::Network::IOService::runOne | ( | ) |
Run at most one handler, blocking if appropriate.
References mImpl.
void Sirikata::Network::IOService::stop | ( | ) |
Stop event processing, cancelling events as necessary.
References mImpl.
Referenced by Sirikata::Context::cleanup(), and Sirikata::AggregateManager::~AggregateManager().
friend class DeadlineTimer [friend] |
friend class InternalIOStrand [friend] |
friend class InternalIOWork [friend] |
friend class IOServiceFactory [friend] |
friend class IOStrand [friend] |
Referenced by createStrand().
friend class IOTimer [friend] |
friend class TCPListener [friend] |
friend class TCPResolver [friend] |
friend class TCPSocket [friend] |
friend class UDPResolver [friend] |
friend class UDPSocket [friend] |
Referenced by dispatch(), IOService(), poll(), pollOne(), post(), reset(), run(), runNoReturn(), runOne(), stop(), and ~IOService().
const String Sirikata::Network::IOService::mName [private] |