Represents an operation initiated on a Processor. More...
#include <I_Action.h>
Inherited by Event, HttpCacheAction, and NetAcceptAction.
Public Member Functions | |
virtual void | cancel (Continuation *c=NULL) |
Cancels the asynchronous operation represented by this action. | |
void | cancel_action (Continuation *c=NULL) |
Cancels the asynchronous operation represented by this action. | |
Continuation * | operator= (Continuation *acont) |
Action () | |
Constructor of the Action object. | |
Data Fields | |
Continuation * | continuation |
Contination that initiated this action. | |
Ptr< ProxyMutex > | mutex |
Reference to the Continuation's lock. | |
volatile int | cancelled |
Internal flag used to indicate whether the action has been cancelled. |
Represents an operation initiated on a Processor.
The Action class is an abstract representation of an operation being executed by some Processor. A reference to an Action object allows you to cancel an ongoing asynchronous operation before it completes. This means that the Continuation specified for the operation will not be called back.
Actions or classes derived from Action are the typical return type of methods exposed by Processors in the Event System and throughout the IO Core libraries.
The canceller of an action 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.
Processor implementers:
You must ensure that no events are sent to the state machine after the operation has been cancelled appropriately.
Returning an Action:
Processor functions that are asynchronous must return actions to allow the calling state machine to cancel the task before completion. Because some processor functions are reentrant, they can call back the state machine before the returning from the call that creates the actions. To handle this case, special values are returned in place of an action to indicate to the state machine that the action is already completed.
To make matters more complicated, it's possible if the result is ACTION_RESULT_DONE that state machine deallocated itself on the reentrant callback. Thus, state machine implementers MUST either use a scheme to never deallocate their machines on reentrant callbacks OR immediately check the returned action when creating an asynchronous task and if it is ACTION_RESULT_DONE neither read nor write any state variables. With either method, it's imperative that the returned action always be checked for special values and the value handled accordingly.
Allocation policy:
Actions are allocated by the Processor performing the actions. It is the processor's responsbility to handle deallocation once the action is complete or cancelled. A state machine MUST NOT access an action once the operation that returned the Action has completed or it has cancelled the Action.
Definition at line 88 of file I_Action.h.
Action::Action | ( | ) | [inline] |
Constructor of the Action object.
Processor implementers are responsible for associating this action with the proper Continuation.
Definition at line 188 of file I_Action.h.
virtual void Action::cancel | ( | Continuation * | c = NULL |
) | [inline, virtual] |
Cancels the asynchronous operation represented by this action.
This method is called by state machines willing to cancel an ongoing asynchronous operation. Classes derived from Action may perform additional steps before flagging this action as cancelled. There are certain rules that must be followed in order to cancel an action (see the Remarks section).
c | Continuation associated with this Action. |
Reimplemented in HttpCacheAction.
Definition at line 139 of file I_Action.h.
References cancelled, continuation, and ink_assert.
Referenced by NetAccept::acceptEvent(), NetAccept::acceptFastEvent(), HttpCacheAction::cancel(), ClusterVConnectionBase::cancel_active_timeout(), ClusterVConnectionBase::cancel_inactivity_timeout(), CacheTestSM::cancel_timeout(), ClusterHandler::close_ClusterVConnection(), ClusterAccept::ClusterAcceptEvent(), HostDBContinuation::clusterEvent(), dns_result(), HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), RegressionSM::done(), CacheTestSM::event_handler(), SocksEntry::free(), PrefetchUrlBlaster::free(), free_CacheVC(), BlasterUrlList::handleEvent(), hostdb_cont_free(), init_tracker(), HttpSM::kill_this(), CacheContinuation::localVCsetupEvent(), CacheContinuation::lookupOpenWriteVCEvent(), PluginVC::main_handler(), SocksProxy::mainEvent(), SocksEntry::mainEvent(), DNSEntry::post(), ClusterHandler::protoZombieEvent(), UDPReadContinuation::readPollEvent(), CacheContinuation::remoteOpEvent(), UpdateScheduler::ScheduleEvent(), PluginVC::set_active_timeout(), ClusterVConnectionBase::set_active_timeout(), PluginVC::set_inactivity_timeout(), ClusterVConnectionBase::set_inactivity_timeout(), CacheContinuation::setup_local_vc(), ClusterAccept::ShutdownDelete(), SocksEntry::startEvent(), HttpSM::state_congestion_control_lookup(), Stop::stop(), TSActionCancel(), write_dns_event(), ClusterHandler::zombify(), CCFailHistoryTestCont::~CCFailHistoryTestCont(), GlobalClusterPeriodicEvent::~GlobalClusterPeriodicEvent(), ICPProcessor::~ICPProcessor(), ICPRequestCont::~ICPRequestCont(), LogCollationAccept::~LogCollationAccept(), and UnixUDPConnection::~UnixUDPConnection().
void Action::cancel_action | ( | Continuation * | c = NULL |
) | [inline] |
Cancels the asynchronous operation represented by this action.
This method is called by state machines willing to cancel an ongoing asynchronous operation. There are certain rules that must be followed in order to cancel an action (see the Remarks section).
c | Continuation associated with this Action. |
Definition at line 161 of file I_Action.h.
References cancelled, continuation, and ink_assert.
Referenced by UnixNetVConnection::cancel_active_timeout(), UnixNetVConnection::cancel_OOB(), Vol::cancel_trigger(), CacheVC::cancel_trigger(), close_UnixNetVConnection(), CacheSync::mainEvent(), and UnixNetVConnection::set_active_timeout().
Continuation* Action::operator= | ( | Continuation * | acont | ) | [inline] |
Definition at line 172 of file I_Action.h.
References continuation, Continuation::mutex, and mutex.
volatile int Action::cancelled |
Internal flag used to indicate whether the action has been cancelled.
This flag is set after a call to cancel or cancel_action and it should not be accesed or modified directly by the state machine.
Definition at line 125 of file I_Action.h.
Referenced by UnixNetVConnection::acceptEvent(), aio_thread_main(), CacheContinuation::callback_user(), CacheContinuation::callbackEvent(), CacheContinuation::callbackResultEvent(), cancel(), HttpCacheAction::cancel(), cancel_action(), PriorityEventQueue::check_ready(), HostDBContinuation::clusterEvent(), ShowCont::complete(), ShowCont::complete_error(), ProtectedQueue::dequeue_timed(), CacheVC::derefRead(), dns_result(), HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), HostDBContinuation::do_dns(), CacheContinuation::do_op(), CacheContinuation::do_remote_lookup(), EThread::execute(), HostDBContinuation::failed_cluster_request(), SocksEntry::free(), free_CacheVC(), CongestionDBCont::get_congest_entry(), CongestionDBCont::get_congest_list(), HttpPagesHandler::handle_callback(), CheckConnect::handle_connect(), ICPRequestCont::ICPRequestCont(), Event::init(), AIOCallbackInternal::io_complete(), HttpUpdateSM::kill_this_async_hook(), CacheVC::linkWrite(), CacheContinuation::localVCsetupEvent(), UnixNetVConnection::mainEvent(), CacheVC::openReadFromWriter(), CacheVC::openReadStartEarliest(), CacheVC::openReadStartHead(), CacheVC::openWriteOverwrite(), CacheVC::openWriteStartBegin(), ICPPeerReadCont::PeerReadStateMachine(), DNSEntry::postEvent(), HostDBContinuation::probeEvent(), EThread::process_event(), UDPReadContinuation::readPollEvent(), CacheContinuation::remoteOpEvent(), HostDBContinuation::removeEvent(), CacheVC::removeEvent(), RemapPlugins::run_remap(), CacheVC::scanObject(), CacheVC::scanVol(), PluginVC::set_active_timeout(), ClusterVConnectionBase::set_active_timeout(), ClusterVConnectionBase::set_inactivity_timeout(), and UnixNetVConnection::startEvent().
Contination that initiated this action.
The reference to the initiating continuation is only used to verify that the action is being cancelled by the correct continuation. This field should not be accesed or modified directly by the state machine.
Definition at line 102 of file I_Action.h.
Referenced by UnixNetVConnection::acceptEvent(), aio_thread_main(), CacheContinuation::callback_user(), CacheContinuation::callbackEvent(), CacheContinuation::callbackResultEvent(), CacheVC::callcont(), cancel(), cancel_action(), HostDBContinuation::clusterEvent(), HostDBContinuation::clusterResponseEvent(), ShowCont::complete(), ShowCont::complete_error(), UnixNetVConnection::connectUp(), CacheVC::derefRead(), HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), HostDBContinuation::do_dns(), ClusterHandler::do_open_local_requests(), EThread::execute(), SocksEntry::free(), free_CacheVC(), CongestionDBCont::get_congest_entry(), CongestionDBCont::get_congest_list(), UDPIOEvent::getContinuation(), HttpPagesHandler::handle_callback(), CheckConnect::handle_connect(), CacheContinuation::handleDisposeEvent(), Event::init(), UDPReadContinuation::init_token(), ink_aio_read(), ink_aio_write(), AIOCallbackInternal::io_complete(), CacheVC::linkWrite(), CacheContinuation::localVCsetupEvent(), CacheVC::openReadFromWriterFailure(), CacheVC::openReadStartEarliest(), CacheVC::openReadStartHead(), CacheVC::openWriteStartBegin(), operator=(), DNSEntry::postEvent(), HostDBContinuation::probeEvent(), EThread::process_event(), CacheContinuation::remoteOpEvent(), HostDBContinuation::removeEvent(), CacheVC::removeEvent(), RemapPlugins::run_remap(), CacheVC::scanObject(), CacheVC::scanOpenWrite(), CacheVC::scanVol(), EventProcessor::schedule(), EThread::schedule(), Event::schedule_at(), Event::schedule_every(), Event::schedule_imm(), Event::schedule_in(), EThread::schedule_local(), EventProcessor::spawn_thread(), ClusterVConnection::start(), TSActionCancel(), CacheContinuation::tunnelClosedEvent(), and UDPReadContinuation::UDPReadContinuation().
Reference to the Continuation's lock.
Keeps a reference to the Continuation's lock to preserve the access to the cancelled field valid even when the state machine has been deallocated. This field should not be accesed or modified directly by the state machine.
Definition at line 114 of file I_Action.h.
Referenced by aio_thread_main(), CacheContinuation::callback_failure(), HostDBContinuation::clusterEvent(), HostDBContinuation::clusterResponseEvent(), ProtectedQueue::dequeue_timed(), dns_result(), HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), ClusterHandler::do_open_local_requests(), EThread::execute(), UnixNetVConnection::free(), SocksEntry::free(), Event::free(), UDPIOEvent::free(), free_CacheVC(), EThread::free_event(), get_hostinfo_ClusterFunction(), HttpPagesHandler::handle_callback(), hostdb_cont_free(), HostDBContinuation::init(), HttpUpdateSM::kill_this_async_hook(), operator=(), DNSEntry::post(), DNSEntry::postEvent(), HostDBContinuation::probeEvent(), EThread::process_event(), RemapPlugins::run_remap(), EventProcessor::schedule(), EThread::schedule(), Event::schedule_at(), Event::schedule_every(), Event::schedule_imm(), Event::schedule_in(), EThread::schedule_local(), EventProcessor::spawn_thread(), and ClusterVConnection::start().