Public Member Functions | Data Fields

Event Class Reference

A type of Action returned by the EventProcessor. More...

#include <I_Event.h>

Inherits Action.

Inherited by UDPIOEvent.

Collaboration diagram for Event:
Collaboration graph
[legend]

Public Member Functions

void schedule_imm (int callback_event=EVENT_IMMEDIATE)
 Reschedules this event immediately.
void schedule_at (ink_hrtime atimeout_at, int callback_event=EVENT_INTERVAL)
 Reschedules this event to callback at time 'atimeout_at'.
void schedule_in (ink_hrtime atimeout_in, int callback_event=EVENT_INTERVAL)
 Reschedules this event to callback at time 'atimeout_at'.
void schedule_every (ink_hrtime aperiod, int callback_event=EVENT_INTERVAL)
 Reschedules this event to callback every 'aperiod'.
void free ()
 Event ()
Eventinit (Continuation *c, ink_hrtime atimeout_at=0, ink_hrtime aperiod=0)
 LINK (Event, link)

Data Fields

EThreadethread
unsigned int in_the_prot_queue:1
unsigned int in_the_priority_queue:1
unsigned int immediate:1
unsigned int globally_allocated:1
unsigned int in_heap:4
int callback_event
ink_hrtime timeout_at
ink_hrtime period
void * cookie
 This field can be set when an event is created.

Detailed Description

A type of Action returned by the EventProcessor.

The Event class is the type of Action returned by the EventProcessor as a result of scheduling an operation. Unlike asynchronous operations represented by actions, events never call reentrantly.

Besides being able to cancel an event (because it is an action), you can also reschedule it once received.

Remarks

When reschedulling an event through any of the Event class schedulling fuctions, state machines must not make these calls in other thread other than the one that called them back. They also must have acquired the continuation's lock before calling any of the schedulling functions.

The rules for cancelling an event are the same as those for actions:

The canceller of an event must be the state machine that will be called back by the task and that state machine's lock must be held while calling cancel. Any reference to that event object (ie. pointer) held by the state machine must not be used after the cancellation.

Event Codes:

At the completion of an event, state machines use the event code passed in through the Continuation's handler function to distinguish the type of event and handle the data parameter accordingly. State machine implementers should be careful when defining the event codes since they can impact on other state machines presents. For this reason, this numbers are usually allocated from a common pool.

Time values:

The schedulling functions use a time parameter typed as ink_hrtime for specifying the timeouts or periods. This is a nanosecond value supported by libts and you should use the time functions and macros defined in ink_hrtime.h.

The difference between the timeout specified for schedule_at and schedule_in is that in the former it is an absolute value of time that is expected to be in the future where in the latter it is an amount of time to add to the current time (obtained with ink_get_hrtime).

Definition at line 153 of file I_Event.h.


Constructor & Destructor Documentation

TS_INLINE Event::Event (  ) 

Definition at line 46 of file P_UnixEvent.h.


Member Function Documentation

TS_INLINE void Event::free (  ) 

Reimplemented in UDPIOEvent.

Definition at line 39 of file P_UnixEvent.h.

References eventAllocator, and Action::mutex.

TS_INLINE Event * Event::init ( Continuation c,
ink_hrtime  atimeout_at = 0,
ink_hrtime  aperiod = 0 
)
Event::LINK ( Event  ,
link   
)
void Event::schedule_at ( ink_hrtime  atimeout_at,
int  callback_event = EVENT_INTERVAL 
)

Reschedules this event to callback at time 'atimeout_at'.

Instructs the event object to reschedule itself at the time specified in atimeout_at on the EventProcessor.

Parameters:
atimeout_at Time at which to callcallback. See the Remarks section.
callback_event Event code to return at the completion of this event. See the Remarks section.

Definition at line 50 of file UnixEvent.cc.

References callback_event, Action::continuation, ProtectedQueue::enqueue_local(), ethread, EThread::EventQueue, EThread::EventQueueExternal, immediate, in_the_priority_queue, in_the_prot_queue, ink_assert, Continuation::mutex, Action::mutex, period, PriorityEventQueue::remove(), this_ethread(), and timeout_at.

void Event::schedule_every ( ink_hrtime  aperiod,
int  callback_event = EVENT_INTERVAL 
)

Reschedules this event to callback every 'aperiod'.

Instructs the event object to reschedule itself to callback every 'aperiod' from now.

Parameters:
aperiod Time period at which to callcallback. See the Remarks section.
callback_event Event code to return at the completion of this event. See the Remarks section.

Definition at line 81 of file UnixEvent.cc.

References callback_event, Action::continuation, ProtectedQueue::enqueue_local(), ethread, EThread::EventQueue, EThread::EventQueueExternal, immediate, in_the_priority_queue, in_the_prot_queue, ink_assert, ink_get_based_hrtime(), Continuation::mutex, Action::mutex, period, PriorityEventQueue::remove(), this_ethread(), and timeout_at.

Referenced by SnapCont::mainEvent(), RecProcess_set_config_update_interval_ms(), RecProcess_set_raw_stat_sync_interval_ms(), RecProcess_set_remote_sync_interval_ms(), DNSHandler::startEvent_sdns(), UDPNetHandler::startNetEvent(), and NetHandler::startNetEvent().

void Event::schedule_imm ( int  callback_event = EVENT_IMMEDIATE  ) 

Reschedules this event immediately.

Instructs the event object to reschedule itself as soon as possible in the EventProcessor.

Parameters:
callback_event Event code to return at the completion of this event. See the Remarks section.

Definition at line 35 of file UnixEvent.cc.

References callback_event, Action::continuation, ProtectedQueue::enqueue_local(), ethread, EThread::EventQueue, EThread::EventQueueExternal, immediate, in_the_priority_queue, in_the_prot_queue, ink_assert, Continuation::mutex, Action::mutex, period, PriorityEventQueue::remove(), this_ethread(), and timeout_at.

Referenced by MultiCacheSync::heapEvent(), MultiCacheSync::pauseEvent(), and RemapPlugins::run_remap().

void Event::schedule_in ( ink_hrtime  atimeout_in,
int  callback_event = EVENT_INTERVAL 
)

Reschedules this event to callback at time 'atimeout_at'.

Instructs the event object to reschedule itself at the time specified in atimeout_at on the EventProcessor.

Parameters:
atimeout_in Time at which to callcallback. See the Remarks section.
callback_event Event code to return at the completion of this event. See the Remarks section.

Definition at line 66 of file UnixEvent.cc.

References callback_event, Action::continuation, ProtectedQueue::enqueue_local(), ethread, EThread::EventQueue, EThread::EventQueueExternal, immediate, in_the_priority_queue, in_the_prot_queue, ink_assert, ink_get_based_hrtime(), Continuation::mutex, Action::mutex, period, PriorityEventQueue::remove(), this_ethread(), and timeout_at.

Referenced by UnixNetVConnection::acceptEvent(), HostDBContinuation::clusterEvent(), HostDBContinuation::clusterResponseEvent(), DNSEntry::delayEvent(), ICPPeriodicCont::DoReconfigAction(), ClusterVConnectionCacheEvent::eventHandler(), CongestionDBCont::get_congest_entry(), CongestionDBCont::get_congest_list(), CacheContinuation::handleReplyEvent(), retryDisposeOfDataBuffer::handleRetryEvent(), CacheContinuation::localVCsetupEvent(), PluginVC::main_handler(), UnixNetVConnection::mainEvent(), MultiCacheSync::mcEvent(), ClusterHandler::protoZombieEvent(), CacheContinuation::remoteOpEvent(), CacheContinuation::remove_and_delete(), HostDBContinuation::removeEvent(), ClusterVConnectionBase::set_active_timeout(), ClusterVConnectionBase::set_inactivity_timeout(), UnixNetVConnection::startEvent(), MultiCacheHeapGC::startEvent(), and ConfigurationContinuation::zombieEvent().


Field Documentation

Definition at line 214 of file I_Event.h.

Referenced by EThread::schedule_local().

unsigned int Event::immediate

Definition at line 213 of file I_Event.h.

Referenced by init(), schedule_at(), schedule_every(), schedule_imm(), and schedule_in().

unsigned int Event::in_heap

Definition at line 215 of file I_Event.h.

Referenced by PriorityEventQueue::check_ready(), and PriorityEventQueue::enqueue().


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