Event System specific type of thread. More...
#include <I_EThread.h>
Inherits Thread.
Inherited by INKThreadInternal.
Public Member Functions | |
Event * | schedule_imm (Continuation *c, int callback_event=EVENT_IMMEDIATE, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event as soon as possible. | |
Event * | schedule_imm_signal (Continuation *c, int callback_event=EVENT_IMMEDIATE, void *cookie=NULL) |
Event * | schedule_at (Continuation *c, ink_hrtime atimeout_at, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event at the given timeout. | |
Event * | schedule_in (Continuation *c, ink_hrtime atimeout_in, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event after the timeout elapses. | |
Event * | schedule_every (Continuation *c, ink_hrtime aperiod, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event periodically. | |
Event * | schedule_imm_local (Continuation *c, int callback_event=EVENT_IMMEDIATE, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event as soon as possible. | |
Event * | schedule_at_local (Continuation *c, ink_hrtime atimeout_at, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event at the given timeout. | |
Event * | schedule_in_local (Continuation *c, ink_hrtime atimeout_in, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event after the timeout elapses. | |
Event * | schedule_every_local (Continuation *c, ink_hrtime aperiod, int callback_event=EVENT_INTERVAL, void *cookie=NULL) |
Schedules the continuation on this EThread to receive an event periodically. | |
Event * | schedule_local (Event *e) |
EThread () | |
EThread (ThreadType att, int anid) | |
EThread (ThreadType att, Event *e) | |
virtual | ~EThread () |
Event * | schedule_spawn (Continuation *cont) |
Event * | schedule (Event *e, bool fast_signal=false) |
Que (Continuation, link) aio_ops | |
Private Data for AIO. | |
bool | is_event_type (EventType et) |
void | set_event_type (EventType et) |
void | execute () |
void | process_event (Event *e, int calling_code) |
void | free_event (Event *e) |
Data Fields | |
InkRand | generator |
char | thread_private [PER_THREAD_DATA] |
Block of memory to allocate thread specific data e.g. | |
DiskHandler * | diskHandler |
Private Data for the Disk Processor. | |
ProtectedQueue | EventQueueExternal |
PriorityEventQueue | EventQueue |
EThread ** | ethreads_to_be_signalled |
int | n_ethreads_to_be_signalled |
Event * | accept_event [MAX_ACCEPT_EVENTS] |
int | main_accept_index |
int | id |
unsigned int | event_types |
void(* | signal_hook )(EThread *) |
int | evpipe [2] |
EventIO * | ep |
ThreadType | tt |
Event * | oneevent |
ServerSessionPool * | server_session_pool |
Event System specific type of thread.
The EThread class is the type of thread created and managed by the Event System. It is one of the available interfaces for schedulling events in the event system (another two are the Event and EventProcessor classes).
In order to handle events, each EThread object has two event queues, one external and one internal. The external queue is provided for users of the EThread (clients) to append events to that particular thread. Since it can be accessed by other threads at the same time, operations using it must proceed in an atomic fashion.
The internal queue, in the other hand, is used exclusively by the EThread to process timed events within a certain time frame. These events are queued internally and they may come from the external queue as well.
Scheduling Interface:
There are eight schedulling functions provided by EThread and they are a wrapper around their counterparts in EventProcessor.
Definition at line 87 of file I_EThread.h.
EThread::EThread | ( | ) |
Definition at line 42 of file UnixEThread.cc.
References PER_THREAD_DATA, and thread_private.
EThread::EThread | ( | ThreadType | att, | |
int | anid | |||
) |
Definition at line 54 of file UnixEThread.cc.
References ats_malloc(), ethreads_to_be_signalled, evpipe, Fatal, FD_CLOEXEC, ink_release_assert, MAX_EVENT_THREADS, PER_THREAD_DATA, and thread_private.
EThread::EThread | ( | ThreadType | att, | |
Event * | e | |||
) |
Definition at line 93 of file UnixEThread.cc.
References DEDICATED, ink_assert, PER_THREAD_DATA, and thread_private.
EThread::~EThread | ( | ) | [virtual] |
Definition at line 109 of file UnixEThread.cc.
References ats_free(), ethreads_to_be_signalled, flush_signals(), and n_ethreads_to_be_signalled.
void EThread::execute | ( | ) | [virtual] |
Reimplemented from Thread.
Definition at line 177 of file UnixEThread.cc.
References a, ProtectedQueue::al, Event::callback_event, Action::cancelled, PriorityEventQueue::check_ready(), Action::continuation, Thread::cur_time, DEDICATED, ProtectedQueue::dequeue_local(), PriorityEventQueue::dequeue_ready(), ProtectedQueue::dequeue_timed(), PriorityEventQueue::earliest_timeout(), PriorityEventQueue::enqueue(), EVENT_IMMEDIATE, EVENT_POLL, EventQueue, EventQueueExternal, flush_signals(), free_event(), Continuation::handleEvent(), HRTIME_MSECOND, ink_assert, INK_ATOMICLIST_EMPTY, ink_get_based_hrtime_internal(), Action::mutex, MUTEX_TAKE_LOCK_FOR, MUTEX_UNTAKE_LOCK, n_ethreads_to_be_signalled, oneevent, Event::period, process_event(), Que(), REGULAR, THREAD_MAX_HEARTBEAT_MSECONDS, Event::timeout_at, and tt.
TS_INLINE void EThread::free_event | ( | Event * | e | ) |
Definition at line 166 of file P_UnixEThread.h.
References EVENT_FREE, Thread::eventAllocator, Event::in_the_priority_queue, Event::in_the_prot_queue, ink_assert, and Action::mutex.
Referenced by execute(), and process_event().
bool EThread::is_event_type | ( | EventType | et | ) |
Definition at line 119 of file UnixEThread.cc.
References event_types.
Referenced by UnixNetProcessor::connect_re_internal(), and net_accept().
void EThread::process_event | ( | Event * | e, | |
int | calling_code | |||
) |
Definition at line 131 of file UnixEThread.cc.
References Action::cancelled, Action::continuation, Thread::cur_time, DELAY_FOR_RETRY, ProtectedQueue::enqueue_local(), EventQueueExternal, free_event(), Continuation::handleEvent(), Event::in_the_priority_queue, Event::in_the_prot_queue, ink_assert, ink_get_based_hrtime(), Ptr< T >::m_ptr, Action::mutex, MUTEX_RELEASE, MUTEX_TRY_LOCK_FOR, Event::period, and Event::timeout_at.
Referenced by execute().
EThread::Que | ( | Continuation | , | |
link | ||||
) |
Private Data for AIO.
Referenced by execute().
Definition at line 92 of file P_UnixEThread.h.
References Action::continuation, ProtectedQueue::enqueue(), Event::ethread, EventQueueExternal, ink_assert, Ptr< T >::m_ptr, Thread::mutex, Action::mutex, Continuation::mutex, REGULAR, and tt.
Referenced by schedule_at(), schedule_every(), schedule_imm(), schedule_imm_signal(), schedule_in(), and schedule_spawn().
TS_INLINE Event * EThread::schedule_at | ( | Continuation * | c, | |
ink_hrtime | atimeout_at, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event at the given timeout.
Forwards the request to the EventProcessor to schedule the callback to the continuation 'c' at the time specified in 'atimeout_at'. The event is assigned to this EThread.
c | Continuation to be called back at the time specified in 'atimeout_at'. | |
atimeout_at | Time value at which to callback. | |
callback_event | Event code to be passed back to the continuation's handler. See the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 65 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, Thread::eventAllocator, Event::init(), and schedule().
TS_INLINE Event * EThread::schedule_at_local | ( | Continuation * | c, | |
ink_hrtime | atimeout_at, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event at the given timeout.
Schedules the callback to the continuation 'c' at the time specified in 'atimeout_at'. The event is assigned to this EThread.
c | Continuation to be called back at the time specified in 'atimeout_at'. | |
atimeout_at | Time value at which to callback. | |
callback_event | Event code to be passed back to the continuation's handler. See the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 115 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, EVENT_ALLOC, Thread::eventAllocator, Event::init(), and schedule_local().
TS_INLINE Event * EThread::schedule_every | ( | Continuation * | c, | |
ink_hrtime | aperiod, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event periodically.
Schedules the callback to the continuation 'c' in the EventProcessor to occur every time 'aperiod' elapses. It is scheduled on this EThread.
c | Continuation to call back everytime 'aperiod' elapses. | |
aperiod | Duration of the time period between callbacks. | |
callback_event | Event code to be passed back to the continuation's handler. See the Remarks section in the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 83 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, Thread::eventAllocator, Event::init(), ink_get_based_hrtime(), and schedule().
Referenced by NetAccept::init_accept(), NetAccept::init_accept_per_thread(), SSLNetAccept::init_accept_per_thread(), UDPReadContinuation::init_read(), initialize_thread_for_net(), initialize_thread_for_udp_net(), ClusterHandler::startClusterEvent(), and DNSHandler::startEvent().
TS_INLINE Event * EThread::schedule_every_local | ( | Continuation * | c, | |
ink_hrtime | aperiod, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event periodically.
Schedules the callback to the continuation 'c' to occur every time 'aperiod' elapses. It is scheduled on this EThread.
c | Continuation to call back everytime 'aperiod' elapses. | |
aperiod | Duration of the time period between callbacks. | |
callback_event | Event code to be passed back to the continuation's handler. See the Remarks section in the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 133 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, EVENT_ALLOC, Thread::eventAllocator, Event::init(), ink_get_based_hrtime(), and schedule_local().
TS_INLINE Event * EThread::schedule_imm | ( | Continuation * | c, | |
int | callback_event = EVENT_IMMEDIATE , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event as soon as possible.
Forwards to the EventProcessor the schedule of the callback to the continuation 'c' as soon as possible. The event is assigned to EThread.
c | Continuation to be called back as soon as possible. | |
callback_event | Event code to be passed back to the continuation's handler. See the the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 47 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, Thread::eventAllocator, Event::init(), and schedule().
Referenced by PrefetchUrlBlaster::free(), get_hostinfo_ClusterFunction(), DNSProcessor::getby(), HostDBProcessor::getSRVbyname_imm(), PrefetchBlaster::init(), initialize_thread_for_net(), initialize_thread_for_udp_net(), DNSProcessor::open(), put_hostinfo_ClusterFunction(), register_ShowHostDB(), ShowNet::showConnections(), ShowNet::showConnectionsOnThread(), ShowNet::showSingleThread(), ShowNet::showThreads(), and CacheProcessor::start_internal().
TS_INLINE Event * EThread::schedule_imm_local | ( | Continuation * | c, | |
int | callback_event = EVENT_IMMEDIATE , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event as soon as possible.
Schedules the callback to the continuation 'c' as soon as possible. The event is assigned to this EThread.
c | Continuation to be called back as soon as possible. | |
callback_event | Event code to be passed back to the continuation's handler. See the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 106 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, EVENT_ALLOC, Thread::eventAllocator, Event::init(), and schedule_local().
Referenced by PrefetchBlaster::handleEvent(), and PrefetchTransform::~PrefetchTransform().
TS_INLINE Event * EThread::schedule_imm_signal | ( | Continuation * | c, | |
int | callback_event = EVENT_IMMEDIATE , |
|||
void * | cookie = NULL | |||
) |
Definition at line 56 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, Thread::eventAllocator, Event::init(), and schedule().
Referenced by Vol::aggWrite(), Vol::aggWriteDone(), aio_thread_main(), ClusterProcessor::connect_local(), dns_result(), and DNSEntry::post().
TS_INLINE Event * EThread::schedule_in | ( | Continuation * | c, | |
ink_hrtime | atimeout_in, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event after the timeout elapses.
Instructs the EventProcessor to schedule the callback to the continuation 'c' after the time specified in atimeout_in elapses. The event is assigned to this EThread.
c | Continuation to be called back after the timeout elapses. | |
atimeout_in | Amount of time after which to callback. | |
callback_event | Event code to be passed back to the continuation's handler. See the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 74 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, Thread::eventAllocator, Event::init(), ink_get_based_hrtime(), and schedule().
Referenced by UnixNetVConnection::acceptEvent(), HostDBContinuation::dnsEvent(), HostDBContinuation::do_dns(), HostDBContinuation::do_get_response(), HostDBProcessor::getbyname_imm(), HostDBProcessor::getSRVbyname_imm(), PrefetchBlaster::handleEvent(), BlasterUrlList::handleEvent(), SocksEntry::init(), KeepAliveLockHandler::init(), SocksProxy::mainEvent(), SocksEntry::mainEvent(), CacheSync::mainEvent(), HostDBContinuation::probeEvent(), UnixNetVConnection::set_active_timeout(), ClusterVConnectionBase::set_active_timeout(), UnixNetVConnection::set_enabled(), UnixNetVConnection::set_inactivity_timeout(), ClusterVConnectionBase::set_inactivity_timeout(), HostDBProcessor::setby(), ShowNet::showConnectionsOnThread(), ShowNet::showSingleThread(), OpenDir::signal_readers(), ClusterVConnection::start(), ClusterHandler::startClusterEvent(), and SocksEntry::startEvent().
TS_INLINE Event * EThread::schedule_in_local | ( | Continuation * | c, | |
ink_hrtime | atimeout_in, | |||
int | callback_event = EVENT_INTERVAL , |
|||
void * | cookie = NULL | |||
) |
Schedules the continuation on this EThread to receive an event after the timeout elapses.
Schedules the callback to the continuation 'c' after the time specified in atimeout_in elapses. The event is assigned to this EThread.
c | Continuation to be called back after the timeout elapses. | |
atimeout_in | Amount of time after which to callback. | |
callback_event | Event code to be passed back to the continuation's handler. See the Remarks section in the EventProcessor class. | |
cookie | User-defined value or pointer to be passed back in the Event's object cookie field. |
Definition at line 124 of file P_UnixEThread.h.
References Event::callback_event, Event::cookie, EVENT_ALLOC, Thread::eventAllocator, Event::init(), ink_get_based_hrtime(), and schedule_local().
Referenced by net_activity(), UnixNetVConnection::set_active_timeout(), UnixNetVConnection::set_enabled(), and UnixNetVConnection::set_inactivity_timeout().
Definition at line 142 of file P_UnixEThread.h.
References Action::continuation, DEDICATED, ProtectedQueue::enqueue_local(), ET_CALL, Event::ethread, eventProcessor, EventQueueExternal, Event::globally_allocated, ink_assert, Ptr< T >::m_ptr, Continuation::mutex, Action::mutex, REGULAR, EventProcessor::schedule(), and tt.
Referenced by schedule_at_local(), schedule_every_local(), schedule_imm_local(), and schedule_in_local().
TS_INLINE Event * EThread::schedule_spawn | ( | Continuation * | cont | ) |
Definition at line 40 of file P_UnixEThread.h.
References EVENT_ALLOC, Thread::eventAllocator, Event::init(), and schedule().
void EThread::set_event_type | ( | EventType | et | ) |
Definition at line 125 of file UnixEThread.cc.
References event_types.
Referenced by EventProcessor::spawn_event_threads(), and EventProcessor::start().
Event* EThread::accept_event[MAX_ACCEPT_EVENTS] |
Definition at line 300 of file I_EThread.h.
DiskHandler* EThread::diskHandler |
Private Data for the Disk Processor.
Definition at line 289 of file I_EThread.h.
Referenced by CacheProcessor::start_internal().
Definition at line 320 of file I_EThread.h.
Referenced by initialize_thread_for_net(), and net_signal_hook_function().
Definition at line 297 of file I_EThread.h.
Referenced by ProtectedQueue::enqueue(), EThread(), flush_signals(), and ~EThread().
unsigned int EThread::event_types |
Definition at line 304 of file I_EThread.h.
Referenced by is_event_type(), set_event_type(), and TSThreadCreate().
Definition at line 295 of file I_EThread.h.
Referenced by execute(), Event::schedule_at(), Event::schedule_every(), Event::schedule_imm(), and Event::schedule_in().
Definition at line 294 of file I_EThread.h.
Referenced by ProtectedQueue::enqueue(), execute(), flush_signals(), process_event(), EventProcessor::schedule(), schedule(), Event::schedule_at(), Event::schedule_every(), Event::schedule_imm(), Event::schedule_in(), and schedule_local().
int EThread::evpipe[2] |
Definition at line 318 of file I_EThread.h.
Referenced by EThread(), initialize_thread_for_net(), net_signal_hook_callback(), and net_signal_hook_function().
Definition at line 265 of file I_EThread.h.
Referenced by HttpTransact::calculate_freshness_fuzz(), create_config(), HttpSM::process_srv_info(), rand_CacheKey(), PrefetchProcessor::start(), TSdrandom(), and TSrandom().
int EThread::id |
Definition at line 303 of file I_EThread.h.
Referenced by ProtectedQueue::enqueue(), ShowNet::showConnectionsOnThread(), DNSHandler::startEvent(), and DNSHandler::startEvent_sdns().
Definition at line 301 of file I_EThread.h.
Definition at line 298 of file I_EThread.h.
Referenced by ProtectedQueue::enqueue(), execute(), flush_signals(), and ~EThread().
Definition at line 323 of file I_EThread.h.
Referenced by execute().
Definition at line 325 of file I_EThread.h.
Referenced by HttpSessionManager::acquire_session(), initialize_thread_for_http_sessions(), and HttpSessionManager::release_session().
void(* EThread::signal_hook)(EThread *) |
Definition at line 313 of file I_EThread.h.
Referenced by ProtectedQueue::enqueue(), flush_signals(), initialize_thread_for_net(), ClusterProcessor::internal_invoke_remote(), ClusterHandler::mainClusterEvent(), ClusterProcessor::open_local(), and UnixNetVConnection::reenable().
char EThread::thread_private[PER_THREAD_DATA] |
Block of memory to allocate thread specific data e.g.
stat system arrays.
Definition at line 286 of file I_EThread.h.
Referenced by EThread().
Definition at line 322 of file I_EThread.h.
Referenced by execute(), new_CacheVC(), schedule(), schedule_local(), TSHttpSsnReenable(), and TSHttpTxnReenable().