Data Structures | Defines | Functions | Variables

I_Thread.h File Reference

Thread. More...

#include "libts.h"
#include "I_ProxyAllocator.h"
Include dependency graph for I_Thread.h:
This graph shows which files directly or indirectly include this file:

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 ()
Threadthis_thread ()

Variables

ProxyMutexglobal_mutex
static const int MAX_THREAD_NAME_LENGTH = 16
static const int DEFAULT_STACKSIZE = 1048576

Detailed Description

Thread.

License

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.

Details

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 Documentation

#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.


Function Documentation

ink_hrtime ink_get_based_hrtime (  ) 
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 (  ) 
typedef THREADAPI_RETURN_TYPE ( THREADAPI *  ThreadFunction  ) 

Variable Documentation

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]