#include "libts.h"
#include "I_ProxyAllocator.h"
Go to the source code of this file.
Data Structures | |
class | Thread |
Base class for the threads in the Event System. More... | |
Defines | |
#define | THREADAPI |
#define | THREADAPI_RETURN_TYPE void * |
Functions | |
typedef | THREADAPI_RETURN_TYPE (THREADAPI *ThreadFunction)(void *arg) |
ink_hrtime | ink_get_hrtime () |
ink_hrtime | ink_get_based_hrtime () |
Thread * | this_thread () |
Variables | |
ProxyMutex * | global_mutex |
static const int | MAX_THREAD_NAME_LENGTH = 16 |
static const int | DEFAULT_STACKSIZE = 1048576 |
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Thread class provides the basic functionality for threads. Typically, there will be additional derived classes. Having a common base class for all threads is useful in many cases. I discuss below the use of Threads in the context of Event Subsystem. Hopefully this would be typical of other situations.
EventProcessor needs to create a bunch of threads. It declares a class called EThread, derived from Thread. It is the responsibility of the EventProcessor to create and manage all the threads needed in the Event Subsystem (Note: we have removed the original ThreadManager class which used to create and manage *all* the threads in the system). By monitoring, we mean checking the heartbeat of each thread and the number of threads in the system etc.
A derived class should either provide the function (and arguments) needed by the Thread class (see start()), or should define the virtual function execute().
The Thread class maintains a thread_key which registers *all* the threads in the system (that have been created using Thread or a derived class), using thread specific data calls. Whenever, you call this_thread() you get a pointer to the Thread that is currently executing you. Additionally, the EThread class (derived from Thread) maintains its own independent key. All (and only) the threads created in the Event Subsystem are registered with this key. Thus, whenever you call this_ethread() you get a pointer to EThread. If you happen to call this_ethread() from inside a thread which is not an EThread, you will get a NULL value (since that thread will not be registered with the EThread key). This will hopefully make the use of this_ethread() safer. Note that an event created with EThread can also call this_thread(), in which case, it will get a pointer to Thread (rather than to EThread).
Definition in file I_Thread.h.
#define THREADAPI |
Definition at line 71 of file I_Thread.h.
#define THREADAPI_RETURN_TYPE void * |
Definition at line 72 of file I_Thread.h.
ink_hrtime ink_get_based_hrtime | ( | ) |
Definition at line 64 of file P_Thread.h.
References Thread::cur_time.
Referenced by agg_copy(), cmd_check_internal(), UpdateEntry::ComputeScheduleTime(), Vol::evacuateDocReadDone(), INKBasedTimeGet(), EThread::process_event(), Event::schedule_every(), EventProcessor::schedule_every(), EThread::schedule_every(), EThread::schedule_every_local(), Event::schedule_in(), EventProcessor::schedule_in(), EThread::schedule_in(), EThread::schedule_in_local(), UpdateScheduler::ScheduleEvent(), HostDBProcessor::start(), and TShrtime().
ink_hrtime ink_get_hrtime | ( | ) |
Definition at line 58 of file P_Thread.h.
References Thread::cur_time.
Referenced by NetAccept::acceptFastEvent(), ClusterHandler::add_small_controlmsg_descriptors(), aio_stats_cb(), aio_thread_main(), HttpSM::attach_client_session(), ClusterHandler::build_initial_vector(), cache_op_ClusterFunction(), cache_op_result_ClusterFunction(), check_emergency_throttle(), InactivityCop::check_inactivity(), check_shedding_warning(), check_throttle_warning(), check_transient_accept_error(), CongestionEntry::client_retry_after(), ClusterHandler::close_ClusterVConnection(), cluster_machine_at_depth(), complete(), configuration_add_machine(), configuration_remove_machine(), ClusterProcessor::connect_local(), UnixNetProcessor::connect_re_internal(), dns_process(), dns_result(), HttpSM::do_api_callout_internal(), NetAccept::do_blocking_accept(), HttpSM::do_cache_lookup_and_read(), HttpSM::do_cache_prepare_write(), HttpSM::do_hostdb_lookup(), HttpSM::do_http_server_open(), CacheContinuation::do_op(), CacheContinuation::do_remote_lookup(), DNSHandler::failover_now(), DNSHandler::failover_soon(), Log::flush_thread_main(), CongestionDBCont::GC(), ICPlog::GetElapsedTime(), ICPPeerReadCont::ICPPeerQueryCont(), ICPPeerReadCont::init(), HttpSM::init(), DNSEntry::init(), ink_cluster_time(), ClusterProcessor::internal_invoke_remote(), ClusterProcessor::invoke_remote_data(), CacheContinuation::localVCsetupEvent(), LogObjectManager_Transfer(), Peer::LogRecvMsg(), MultiCastPeer::LogSendMsg(), ParentSiblingPeer::LogSendMsg(), PluginVC::main_handler(), ClusterHandler::mainClusterEvent(), UnixNetVConnection::mainEvent(), DNSHandler::mainEvent(), CacheTestSM::make_request(), HttpSM::mark_server_down_on_client_abort(), Mutex_lock(), Mutex_trylock(), Mutex_trylock_spin(), Mutex_unlock(), net_accept(), net_activity(), new_CacheVC(), ClusterProcessor::open_local(), CacheVC::openReadFromWriter(), ICPPeerReadCont::PeerReadStateMachine(), preCongestEntryGC(), HttpSM::process_hostdb_info(), ClusterHandler::process_incoming_callouts(), ClusterHandler::process_read(), ClusterHandler::process_small_control_msgs(), ClusterHandler::process_write(), CacheContinuation::remoteOpEvent(), CacheContinuation::replyLookupEvent(), CacheContinuation::replyOpEvent(), EventProcessor::schedule_imm(), EventProcessor::schedule_imm_signal(), send_throttle_message(), DNSHandler::sent_one(), UnixNetVConnection::set_enabled(), PluginVC::set_inactivity_timeout(), UnixNetVConnection::set_inactivity_timeout(), ICPRequestCont::SetRequestStartTime(), HttpSM::setup_blind_tunnel(), HttpSM::setup_server_send_request(), ShowNet::showConnectionsOnThread(), CongestionEntry::sprint(), SSLNetVConnection::sslServerHandShakeEvent(), HttpSM::state_cache_open_read(), HttpSM::state_cache_open_write(), HttpSM::state_http_server_open(), HttpSM::state_raw_http_server_open(), HttpSM::state_read_client_request_header(), HttpSM::state_read_push_response_header(), HttpSM::state_read_server_response_header(), HttpSM::state_watch_for_client_abort(), HostDBSyncer::sync_event(), take_rusage_snap(), test(), DNSHandler::try_primary_named(), TSVConnFdCreate(), HttpSM::tunnel_handler_server(), HttpSM::tunnel_handler_ua(), ClusterHandler::update_channels_written(), HttpSM::update_stats(), HostDBSyncer::wait_event(), and write_dns_event().
Thread* this_thread | ( | ) |
Definition at line 52 of file P_Thread.h.
References ink_thread_getspecific(), and Thread::thread_data_key.
Referenced by LogFile::close_file(), RamCacheCLFUS::destroy(), HttpServerSession::destroy(), HttpClientSession::destroy(), HdrHeap::destroy(), Log::flush_thread_main(), IOBufferBlock::free(), IOBufferData::free(), HdrStrHeap::free(), free_CacheVC(), free_empty_MIOBuffer(), free_MIOBuffer(), LogObjectManager::log(), main(), Mutex_trylock(), new_empty_MIOBuffer_internal(), new_IOBufferBlock_internal(), new_IOBufferData_internal(), new_MIOBuffer_internal(), LogFile::open_file(), LogHost::orphan_write_and_try_delete(), LogFile::preproc_and_try_delete(), LogBufferManager::preproc_buffers(), rec_mutex_acquire(), RamCacheLRU::remove(), UDPReadContinuation::setupPollDescriptor(), this_ethread(), RamCacheCLFUS::tick(), and LogFile::write_ascii_logbuffer3().
typedef THREADAPI_RETURN_TYPE | ( | THREADAPI * | ThreadFunction | ) |
const int DEFAULT_STACKSIZE = 1048576 [static] |
Definition at line 78 of file I_Thread.h.
Definition at line 39 of file Thread.cc.
Referenced by EventProcessor::start().
const int MAX_THREAD_NAME_LENGTH = 16 [static] |
Definition at line 77 of file I_Thread.h.
Referenced by UnixNetProcessor::accept_internal(), aio_init_fildes(), EventProcessor::spawn_event_threads(), EventProcessor::start(), and Thread::start().