Basic locks for threads. More...
#include "libts.h"
#include "I_Thread.h"
Go to the source code of this file.
Data Structures | |
class | ProxyMutex |
Lock object used in continuations and threads. More... | |
struct | MutexLock |
struct | MutexTryLock |
Defines | |
#define | MAX_LOCK_TIME HRTIME_MSECONDS(200) |
#define | THREAD_MUTEX_THREAD_HOLDING (-1024*1024) |
#define | MUTEX_LOCK(_l, _m, _t) MutexLock _l(_m,_t) |
Blocks until the lock to the ProxyMutex is acquired. | |
#define | MUTEX_TRY_LOCK(_l, _m, _t) MutexTryLock _l(_m,_t) |
#define | MUTEX_TRY_LOCK_SPIN(_l, _m, _t, _sc) MutexTryLock _l(_m,_t,_sc) |
#define | MUTEX_TRY_LOCK_FOR(_l, _m, _t, _c) MutexTryLock _l(_m,_t) |
#define | MUTEX_RELEASE(_l) (_l).release() |
Releases the lock on a ProxyMutex. | |
#define | MUTEX_TAKE_TRY_LOCK(_m, _t) Mutex_trylock(_m,_t) |
#define | MUTEX_TAKE_TRY_LOCK_FOR(_m, _t, _c) Mutex_trylock(_m,_t) |
#define | MUTEX_TAKE_TRY_LOCK_FOR_SPIN(_m, _t, _c, _sc) Mutex_trylock_spin(_m,_t,_sc) |
#define | MUTEX_TAKE_LOCK(_m, _t) Mutex_lock(_m,_t) |
#define | MUTEX_SET_AND_TAKE_LOCK(_s, _m, _t) _s.set_and_take(_m,_t) |
#define | MUTEX_TAKE_LOCK_FOR(_m, _t, _c) Mutex_lock(_m,_t) |
#define | MUTEX_UNTAKE_LOCK(_m, _t) Mutex_unlock(_m,_t) |
Typedefs | |
typedef EThread * | EThreadPtr |
typedef volatile EThreadPtr | VolatileEThreadPtr |
Functions | |
inkcoreapi void | lock_waiting (const char *file, int line, const char *handler) |
inkcoreapi void | lock_holding (const char *file, int line, const char *handler) |
void | lock_taken (const char *file, int line, const char *handler) |
bool | Mutex_trylock (ProxyMutex *m, EThread *t) |
bool | Mutex_trylock_spin (ProxyMutex *m, EThread *t, int spincnt=1) |
int | Mutex_lock (ProxyMutex *m, EThread *t) |
void | Mutex_unlock (ProxyMutex *m, EThread *t) |
ProxyMutex * | new_ProxyMutex () |
Creates a new ProxyMutex object. | |
Variables | |
inkcoreapi ClassAllocator < ProxyMutex > | mutexAllocator |
Basic locks for threads.
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.
Definition in file I_Lock.h.
#define MAX_LOCK_TIME HRTIME_MSECONDS(200) |
Definition at line 30 of file I_Lock.h.
Referenced by Mutex_unlock().
#define MUTEX_LOCK | ( | _l, | ||
_m, | ||||
_t | ||||
) | MutexLock _l(_m,_t) |
Blocks until the lock to the ProxyMutex is acquired.
This macro performs a blocking call until the lock to the ProxyMutex is acquired. This call allocates a special object that holds the lock to the ProxyMutex only for the scope of the function or region. It is a good practice to delimit such scope explicitly with '{' and '}'.
_l | Arbitrary name for the lock to use in this call | |
_m | A pointer to (or address of) a ProxyMutex object | |
_t | The current EThread executing your code. |
Definition at line 477 of file I_Lock.h.
Referenced by aio_thread_main(), RegressionSM::child_done(), NetAccept::do_blocking_accept(), InkStaticPool_r< C >::get(), HostDBProcessor::getbyname_imm(), SocksProxy::init(), PrefetchUrlBlaster::init(), OneWayTunnel::init(), net_accept(), Cache::open_write(), InkStaticPool_r< C >::put(), CacheTestSM::run(), send_connection_event(), Http2ClientSession::start(), HttpUpdateSM::start_scheduled_update(), and InkStaticPool_r< C >::~InkStaticPool_r().
#define MUTEX_RELEASE | ( | _l | ) | (_l).release() |
Releases the lock on a ProxyMutex.
This macro releases the lock on the ProxyMutex, provided it is currently held. The lock must have been successfully acquired with one of the MUTEX macros.
_l | Arbitrary name for the lock to use in this call (lock variable) It must be the same name as the one used to acquire the lock. |
Definition at line 550 of file I_Lock.h.
Referenced by CacheContinuation::do_op(), ClusterHandler::do_open_local_requests(), CacheContinuation::do_remote_lookup(), CacheContinuation::localVCsetupEvent(), CacheVC::openReadFromWriter(), CacheVC::openReadStartHead(), EThread::process_event(), CacheContinuation::remoteOpEvent(), and CacheContinuation::remove_and_delete().
#define MUTEX_SET_AND_TAKE_LOCK | ( | _s, | ||
_m, | ||||
_t | ||||
) | _s.set_and_take(_m,_t) |
#define MUTEX_TAKE_LOCK | ( | _m, | ||
_t | ||||
) | Mutex_lock(_m,_t) |
Definition at line 576 of file I_Lock.h.
Referenced by RamCacheCLFUS::compress_entries(), PluginVCCore::connect_re(), FetchSM::ext_write_data(), ClusterHandler::machine_down(), HttpClientSession::new_connection(), send_plugin_event(), ClusterHandler::startClusterEvent(), sync_cache_dir_on_shutdown(), Thread::Thread(), TSAddClusterRPCFunction(), TSAddClusterStatusFunction(), TSDeleteClusterRPCFunction(), TSDeleteClusterStatusFunction(), TSMutexLock(), ClusterHandler::~ClusterHandler(), and ICPProcessor::~ICPProcessor().
#define MUTEX_TAKE_LOCK_FOR | ( | _m, | ||
_t, | ||||
_c | ||||
) | Mutex_lock(_m,_t) |
Definition at line 578 of file I_Lock.h.
Referenced by EThread::execute().
#define MUTEX_TAKE_TRY_LOCK | ( | _m, | ||
_t | ||||
) | Mutex_trylock(_m,_t) |
Definition at line 562 of file I_Lock.h.
Referenced by cache_op_result_ClusterFunction(), HttpSM::get_http_schedule(), CacheContinuation::handleReplyEvent(), AtomicLock::Lock(), PluginVC::main_handler(), ICPPeerReadCont::PeerReadStateMachine(), HttpSM::state_api_callout(), and TSMutexLockTry().
#define MUTEX_TAKE_TRY_LOCK_FOR | ( | _m, | ||
_t, | ||||
_c | ||||
) | Mutex_trylock(_m,_t) |
Definition at line 563 of file I_Lock.h.
Referenced by net_accept().
#define MUTEX_TAKE_TRY_LOCK_FOR_SPIN | ( | _m, | ||
_t, | ||||
_c, | ||||
_sc | ||||
) | Mutex_trylock_spin(_m,_t,_sc) |
Definition at line 564 of file I_Lock.h.
Referenced by ClusterHandler::build_initial_vector(), ClusterHandler::get_read_locks(), ClusterHandler::get_write_locks(), ClusterHandler::valid_for_data_write(), and ClusterHandler::valid_for_freespace_write().
#define MUTEX_TRY_LOCK | ( | _l, | ||
_m, | ||||
_t | ||||
) | MutexTryLock _l(_m,_t) |
Definition at line 533 of file I_Lock.h.
Referenced by UnixNetVConnection::acceptEvent(), NetAccept::acceptEvent(), HttpSessionManager::acquire_session(), CongestionDB::addRecord(), KeepAliveConnTable::append(), Cache_dir(), cache_lookup_ClusterFunction(), cache_op_ClusterFunction(), cache_op_result_ClusterFunction(), CacheContinuation::callback_user(), InactivityCop::check_inactivity(), UpdateScheduler::ChildExitEventHandler(), clusterAPI_init(), HostDBContinuation::clusterResponseEvent(), ClusterProcessor::connect_local(), UnixNetProcessor::connect_re_internal(), Cache::deref(), dns_result(), PluginVC::do_io_close(), CacheContinuation::do_op(), ClusterHandler::do_open_local_requests(), CacheContinuation::do_remote_lookup(), ClusterState::doIO(), ConfigUpdateCallback::event_handler(), ClusterVConnectionCacheEvent::eventHandler(), RecursiveHttpGet::ExitEventHandler(), FetchSM::ext_destroy(), FetchSM::ext_read_data(), CongestionEntry::failed_at(), SocksEntry::free(), CongestionDBCont::GC(), get_congest_entry(), CongestionDBCont::get_congest_entry(), get_congest_list(), CongestionDBCont::get_congest_list(), DNSProcessor::getby(), UpdateConfigManager::GetConfigList(), UpdateConfigManager::GetConfigParams(), HostDBProcessor::getSRVbyname_imm(), HttpPagesHandler::handle_callback(), RangeTransform::handle_event(), NullTransform::handle_event(), TransformTerminus::handle_event(), PrefetchTransform::handle_event(), HttpPagesHandler::handle_smdetails(), HttpPagesHandler::handle_smlist(), CacheContinuation::handleDisposeEvent(), PrefetchBlaster::handleEvent(), CacheVC::handleReadDone(), CacheContinuation::handleReplyEvent(), UpdateSM::HandleSMEvent(), ClusterVConnectionCache::insert(), ClusterProcessor::internal_invoke_remote(), ClusterState::IOComplete(), HttpUpdateSM::kill_this_async_hook(), CacheContinuation::localVCsetupEvent(), ClusterVConnectionCache::lookup(), MachineStatusSM::MachineStatusSMEvent(), UnixNetVConnection::mainEvent(), NetTesterSM::NetTesterSM(), HttpClientSession::new_connection(), ObjectReloadCont::ObjectReloadEvent(), ClusterProcessor::open_local(), ICPPeerReadCont::PeerReadStateMachine(), DNSEntry::post(), ClusterHandler::protoZombieEvent(), HttpSessionManager::purge_keepalives(), UnixNetVConnection::reenable(), PluginVC::reenable_re(), HttpSessionManager::release_session(), CacheContinuation::remoteOpEvent(), CacheContinuation::remove_and_delete(), CongestionDB::removeAllRecords(), HostDBContinuation::removeEvent(), CacheVC::removeEvent(), CongestionDB::removeRecord(), revalidateCongestionDB(), RegressionSM::run(), HostDBProcessor::setby(), CacheContinuation::setupVCdataRead(), ShowNet::showConnectionsOnThread(), ShowNet::showSingleThread(), ClusterAccept::ShutdownDelete(), ClusterVConnection::start(), PVCTestDriver::start_tests(), ClusterHandler::startClusterEvent(), UnixNetVConnection::startEvent(), HttpSM::state_add_to_list(), HttpSM::state_remove_from_list(), PluginVCCore::state_send_accept(), PluginVCCore::state_send_accept_failed(), TSHttpSsnReenable(), and TSHttpTxnReenable().
#define MUTEX_TRY_LOCK_FOR | ( | _l, | ||
_m, | ||||
_t, | ||||
_c | ||||
) | MutexTryLock _l(_m,_t) |
Definition at line 535 of file I_Lock.h.
Referenced by HostDBContinuation::clusterEvent(), HostDBContinuation::dnsEvent(), HostDBContinuation::dnsPendingEvent(), SSLNetVConnection::net_read_io(), HostDBContinuation::probeEvent(), EThread::process_event(), read_from_net(), UDPNetProcessorInternal::udp_callback(), and write_to_net_io().
#define MUTEX_TRY_LOCK_SPIN | ( | _l, | ||
_m, | ||||
_t, | ||||
_sc | ||||
) | MutexTryLock _l(_m,_t,_sc) |
Definition at line 534 of file I_Lock.h.
Referenced by ClusterHandler::finish_delayed_reads().
#define MUTEX_UNTAKE_LOCK | ( | _m, | ||
_t | ||||
) | Mutex_unlock(_m,_t) |
Definition at line 581 of file I_Lock.h.
Referenced by ClusterHandler::build_write_descriptors(), cache_op_result_ClusterFunction(), ClusterHandler::close_free_lock(), RamCacheCLFUS::compress_entries(), PluginVCCore::connect_re(), NetAccept::do_blocking_accept(), EThread::execute(), FetchSM::ext_write_data(), ClusterHandler::free_locks(), ClusterHandler::get_read_locks(), CacheContinuation::handleReplyEvent(), ClusterHandler::machine_down(), net_accept(), HttpClientSession::new_connection(), ICPPeerReadCont::PeerReadStateMachine(), CacheContinuation::remoteOpEvent(), send_plugin_event(), ClusterHandler::startClusterEvent(), TSAddClusterRPCFunction(), TSAddClusterStatusFunction(), TSDeleteClusterRPCFunction(), TSDeleteClusterStatusFunction(), TSMutexUnlock(), AtomicLock::Unlock(), and ClusterHandler::~ClusterHandler().
typedef EThread* EThreadPtr |
typedef volatile EThreadPtr VolatileEThreadPtr |
inkcoreapi void lock_holding | ( | const char * | file, | |
int | line, | |||
const char * | handler | |||
) |
void lock_taken | ( | const char * | file, | |
int | line, | |||
const char * | handler | |||
) |
inkcoreapi void lock_waiting | ( | const char * | file, | |
int | line, | |||
const char * | handler | |||
) |
Definition at line 46 of file Lock.cc.
References is_diags_on.
Referenced by Mutex_trylock(), and Mutex_trylock_spin().
int Mutex_lock | ( | ProxyMutex * | m, | |
EThread * | t | |||
) | [inline] |
Definition at line 258 of file I_Lock.h.
References ink_assert, ink_get_hrtime(), and ink_mutex_acquire().
Referenced by MutexLock::MutexLock(), and MutexLock::set_and_take().
bool Mutex_trylock | ( | ProxyMutex * | m, | |
EThread * | t | |||
) | [inline] |
Definition at line 161 of file I_Lock.h.
References ink_assert, ink_get_hrtime(), ink_mutex_try_acquire(), lock_waiting(), and this_thread().
Referenced by MutexTryLock::MutexTryLock().
bool Mutex_trylock_spin | ( | ProxyMutex * | m, | |
EThread * | t, | |||
int | spincnt = 1 | |||
) | [inline] |
Definition at line 207 of file I_Lock.h.
References ink_assert, ink_get_hrtime(), ink_mutex_try_acquire(), and lock_waiting().
Referenced by MutexTryLock::MutexTryLock().
void Mutex_unlock | ( | ProxyMutex * | m, | |
EThread * | t | |||
) | [inline] |
Definition at line 292 of file I_Lock.h.
References ink_assert, ink_get_hrtime(), ink_mutex_release(), lock_holding(), lock_taken(), MAX_LOCK_TIME, ProxyMutex::nthread_holding, ProxyMutex::the_mutex, and ProxyMutex::thread_holding.
Referenced by HttpSM::get_http_schedule(), PluginVC::main_handler(), MutexTryLock::release(), MutexLock::release(), HttpSM::state_api_callout(), DestructorLock::~DestructorLock(), ICPProcessor::~ICPProcessor(), MutexLock::~MutexLock(), and MutexTryLock::~MutexTryLock().
ProxyMutex* new_ProxyMutex | ( | ) | [inline] |
Creates a new ProxyMutex object.
This is the preferred mechanism for constructing objects of the ProxyMutex class. It provides you with faster allocation than that of the normal constructor.
Definition at line 449 of file I_Lock.h.
References ProxyMutex::init(), and mutexAllocator.
Referenced by NetAccept::acceptFastEvent(), MultiCacheBase::alloc_mutexes(), AtomicLock::AtomicLock(), cache_lookup_ClusterFunction(), cache_op_ClusterFunction(), cache_op_result_ClusterFunction(), ClusterAccept::ClusterAccept(), clusterAPI_init(), ClusterCalloutContinuation::ClusterCalloutContinuation(), ClusterHandler::ClusterHandler(), ClusterState::ClusterState(), ConfigurationContinuation::ConfigurationContinuation(), Congestion_CongestionDB(), Congestion_FailHistory(), CongestionEntry::CongestionEntry(), create_this_cluster_machine(), NetAccept::do_blocking_accept(), FetchSM::ext_init(), NetTesterAccept::handle_accept(), http_pages_init(), ObjectReloadCont::Init(), SpdyClientSession::init(), SocksProxy::init(), PrefetchUrlBlaster::init(), BlasterUrlList::init(), KeepAliveConnTable::init(), PrefetchBlaster::init(), PluginVCCore::init(), OneWayTunnel::init(), OneWayMultiTunnel::init(), ICPPeerReadCont::init(), FetchSM::init(), CacheContinuation::init(), ClusterVConnectionCache::init(), init_http_update_test(), init_HttpProxyServer(), init_reverse_proxy(), NetVCTest::init_test(), UDPReadContinuation::init_token(), initCacheControl(), initialize_all_global_stats(), initialize_thread_for_net(), InkStaticPool_r< C >::InkStaticPool_r(), MTHashTable< key_t, data_t >::MTHashTable(), net_accept(), new_CacheRemoveCont(), Http2ClientSession::new_connection(), PeriodicCont::PeriodicCont(), RecProcessStart(), RegressionSM::RegressionSM(), PrefetchProcessor::start(), HostDBProcessor::start(), ClusterVConnection::start(), PVCTestDriver::start_tests(), SocksServerConfig::startup(), test_main(), Thread::Thread(), TransformControl::TransformControl(), TSMutexCreate(), TSMutexCreateInternal(), TSVConnCreate(), TSVConnFdCreate(), UDPNetHandler::UDPNetHandler(), and UDPReadContinuation::UDPReadContinuation().
inkcoreapi ClassAllocator<ProxyMutex> mutexAllocator |
Referenced by ProxyMutex::free(), and new_ProxyMutex().