#include <EventLoop.h>

Inheritance diagram for EventLoop:
Collaboration diagram for EventLoop:

Public Member Functions

 EventLoop ()
 
void registerEngine (AsyncEngine *engine)
 
void run ()
 
bool runOnce ()
 
void setPrimaryEngine (AsyncEngine *engine)
 
void setTimeService (TimeEngine *engine)
 
void stop ()
 

Public Attributes

int errcount
 

Static Public Attributes

static EventLoopRunning = NULL
 

Private Types

typedef std::vector
< AsyncEngine * > 
engine_vector
 

Private Member Functions

void prepareToRun ()
 
void checkEngine (AsyncEngine *engine, bool const primary)
 
bool dispatchCalls ()
 

Private Attributes

bool last_loop
 
engine_vector engines
 
TimeEnginetimeService
 
AsyncEngineprimaryEngine
 
int loop_delay
 
bool error
 
bool runOnceResult
 

Detailed Description

An event loop. An event loop is the core inner loop of squid. The event loop can be run until exit, or once. After it finishes control returns to the caller. If desired it can be run again.

The event loop cannot be run once it is running until it has finished.

Definition at line 25 of file EventLoop.h.

Member Typedef Documentation

Definition at line 85 of file EventLoop.h.

Constructor & Destructor Documentation

EventLoop::EventLoop ( )

Definition at line 21 of file EventLoop.cc.

Member Function Documentation

void EventLoop::checkEngine ( AsyncEngine engine,
bool const  primary 
)
private

check an individual engine

Definition at line 29 of file EventLoop.cc.

References AsyncEngine::checkEvents(), debugs, error, AsyncEngine::EVENT_ERROR, AsyncEngine::EVENT_IDLE, fatal_dump(), loop_delay, and runOnceResult.

Referenced by runOnce().

bool EventLoop::dispatchCalls ( )
private

dispatch calls and events scheduled during checkEngine()

Definition at line 142 of file EventLoop.cc.

References AsyncCallQueue::fire(), and AsyncCallQueue::Instance().

Referenced by runOnce().

void EventLoop::prepareToRun ( )
private

setup state variables prior to running

Definition at line 63 of file EventLoop.cc.

References errcount, and last_loop.

Referenced by run().

void EventLoop::registerEngine ( AsyncEngine engine)

register an async engine which will be given the opportunity to perform in-main-thread tasks each event loop.

Definition at line 70 of file EventLoop.cc.

References engines.

Referenced by Adaptation::Ecap::ServiceRep::makeXactLauncher(), SquidMain(), StockEventLoop::StockEventLoop(), and testEventLoop::testSetPrimaryEngine().

void EventLoop::run ( )

start the event loop running. The loop will run until it is stopped by calling stop(), or when the loop is completely idle - nothing dispatched in a loop, and all engines idle.

Definition at line 76 of file EventLoop.cc.

References assert, NULL, prepareToRun(), Running, and runOnce().

Referenced by SquidMain(), testRock::storeInit(), and testRock::testRockSwapOut().

bool EventLoop::runOnce ( )

run the loop once. This may not complete all events! It should therefor be used with care. TODO: signal in runOnce whether or not the loop is over - IDLE vs OK vs TIMEOUT?

Definition at line 89 of file EventLoop.cc.

References checkEngine(), DBG_CRITICAL, debugs, dispatchCalls(), engines, errcount, error, EVENT_LOOP_TIMEOUT, i, last_loop, loop_delay, NULL, primaryEngine, runOnceResult, TimeEngine::tick(), and timeService.

Referenced by run(), testEventLoop::testSetPrimaryEngine(), testEventLoop::testSetTimeService(), and testUfs::testUfsSearch().

void EventLoop::setPrimaryEngine ( AsyncEngine engine)

set the primary async engine. The primary async engine recieves the lowest requested timeout gathered from the other engines each loop. (There is a default of 10ms if all engines are idle or request higher delays). If no primary has been nominated, the last async engine added is implicitly the default.

Definition at line 149 of file EventLoop.cc.

References engines, fatal(), i, and primaryEngine.

Referenced by SquidMain(), and testEventLoop::testSetPrimaryEngine().

void EventLoop::setTimeService ( TimeEngine engine)

set the time service. There can be only one time service set at any time. The time service is invoked on each loop

Definition at line 162 of file EventLoop.cc.

References timeService.

Referenced by SquidMain(), StockEventLoop::StockEventLoop(), and testEventLoop::testSetTimeService().

void EventLoop::stop ( )

stop the event loop - it will finish the current loop and then return to the caller of run().

Definition at line 168 of file EventLoop.cc.

References last_loop.

Referenced by SignalEngine::StopEventLoop().

Member Data Documentation

engine_vector EventLoop::engines
private

Definition at line 86 of file EventLoop.h.

Referenced by registerEngine(), runOnce(), and setPrimaryEngine().

int EventLoop::errcount

Definition at line 68 of file EventLoop.h.

Referenced by prepareToRun(), runOnce(), and SquidMain().

bool EventLoop::error
private

has an error occured in this loop

Definition at line 90 of file EventLoop.h.

Referenced by checkEngine(), and runOnce().

bool EventLoop::last_loop
private

Definition at line 84 of file EventLoop.h.

Referenced by prepareToRun(), runOnce(), and stop().

int EventLoop::loop_delay
private

the delay to be given to the primary engine

Definition at line 89 of file EventLoop.h.

Referenced by checkEngine(), and runOnce().

AsyncEngine* EventLoop::primaryEngine
private

Definition at line 88 of file EventLoop.h.

Referenced by runOnce(), and setPrimaryEngine().

EventLoop * EventLoop::Running = NULL
static

the [main program] loop running now; may be nil for simplicity, we assume there are no concurrent loops

Definition at line 72 of file EventLoop.h.

Referenced by Adaptation::Ecap::ServiceRep::makeXactLauncher(), run(), and SignalEngine::StopEventLoop().

bool EventLoop::runOnceResult
private

the result from runOnce

Definition at line 91 of file EventLoop.h.

Referenced by checkEngine(), and runOnce().

TimeEngine* EventLoop::timeService
private

Definition at line 87 of file EventLoop.h.

Referenced by runOnce(), and setTimeService().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors