Data Structures | Defines | Typedefs | Functions | Variables

I_Lock.h File Reference

Basic locks for threads. More...

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

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 EThreadEThreadPtr
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)
ProxyMutexnew_ProxyMutex ()
 Creates a new ProxyMutex object.

Variables

inkcoreapi ClassAllocator
< ProxyMutex
mutexAllocator

Detailed Description

Basic locks for threads.

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.

Definition in file I_Lock.h.


Define Documentation

#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 '&#123;' and '&#125;'.

Parameters:
_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.

Parameters:
_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)

Definition at line 577 of file I_Lock.h.

#define MUTEX_TAKE_LOCK (   _m,
  _t 
)    Mutex_lock(_m,_t)
#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)
#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)
#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)
#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)
#define THREAD_MUTEX_THREAD_HOLDING   (-1024*1024)

Definition at line 31 of file I_Lock.h.


Typedef Documentation

typedef EThread* EThreadPtr

Definition at line 33 of file I_Lock.h.

typedef volatile EThreadPtr VolatileEThreadPtr

Definition at line 35 of file I_Lock.h.


Function Documentation

inkcoreapi void lock_holding ( const char *  file,
int  line,
const char *  handler 
)

Definition at line 59 of file Lock.cc.

References is_diags_on.

Referenced by Mutex_unlock().

void lock_taken ( const char *  file,
int  line,
const char *  handler 
)

Definition at line 72 of file Lock.cc.

References is_diags_on.

Referenced by Mutex_unlock().

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

Returns:
A pointer to a ProxyMutex object appropriate for the build environment.

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


Variable Documentation

Referenced by ProxyMutex::free(), and new_ProxyMutex().