Sirikata
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
Sirikata::Network::IOService Class Reference

IOService provides queuing, processing, and dispatch for asynchronous IO, including timers, sockets, resolvers, and simple tasks. More...

#include <IOService.hpp>

Inheritance diagram for Sirikata::Network::IOService:
Collaboration diagram for Sirikata::Network::IOService:

List of all members.

Public Member Functions

 IOService (const String &name)
 ~IOService ()
const String & name () const
 Get the name of this IOService.
InternalIOServiceasioService ()
 Get the underlying IOService.
const InternalIOServiceasioService () const
 Get the underlying IOService.
IOStrandcreateStrand (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

InternalIOServicemImpl
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

Detailed Description

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.


Constructor & Destructor Documentation

Sirikata::Network::IOService::IOService ( const IOService ) [private]
Sirikata::Network::IOService::IOService ( const String &  name)

References mImpl.

Sirikata::Network::IOService::~IOService ( )

References mImpl.


Member Function Documentation

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]
void Sirikata::Network::IOService::commandReportStats ( const Command::Command cmd,
Command::Commander cmdr,
Command::CommandID  cmdid 
)
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.

Parameters:
handlerthe handler callback to be called
taga 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.

Returns:
the number of handlers executed

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.

Returns:
the number of handlers executed

References mImpl.

void Sirikata::Network::IOService::post ( const IOCallback handler,
const char *  tag = NULL,
const char *  tagStat = NULL 
)
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.

Parameters:
waitForthe length of time to wait before invoking the handler
handlerthe handler callback to be called
taga 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.

Returns:
the number of handlers executed

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.

Returns:
the number of handlers executed

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().


Friends And Related Function Documentation

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]

Member Data Documentation

const String Sirikata::Network::IOService::mName [private]

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