本文整理汇总了C++中mutex::Locker类的典型用法代码示例。如果您正苦于以下问题:C++ Locker类的具体用法?C++ Locker怎么用?C++ Locker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Locker类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
size_t
ModuleList::RemoveOrphans (bool mandatory)
{
Mutex::Locker locker;
if (mandatory)
{
locker.Lock (m_modules_mutex);
}
else
{
// Not mandatory, remove orphans if we can get the mutex
if (!locker.TryLock(m_modules_mutex))
return 0;
}
collection::iterator pos = m_modules.begin();
size_t remove_count = 0;
while (pos != m_modules.end())
{
if (pos->unique())
{
pos = RemoveImpl(pos);
++remove_count;
}
else
{
++pos;
}
}
return remove_count;
}
示例2: if
ConnectionStatus
ConnectionFileDescriptor::Disconnect (Error *error_ptr)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf ("%p ConnectionFileDescriptor::Disconnect ()",
static_cast<void*>(this));
ConnectionStatus status = eConnectionStatusSuccess;
if (!IsConnected())
{
if (log)
log->Printf ("%p ConnectionFileDescriptor::Disconnect(): Nothing to disconnect",
static_cast<void*>(this));
return eConnectionStatusSuccess;
}
if (m_read_sp && m_read_sp->IsValid() && m_read_sp->GetFdType() == IOObject::eFDTypeSocket)
static_cast<Socket&>(*m_read_sp).PreDisconnect();
// Try to get the ConnectionFileDescriptor's mutex. If we fail, that is quite likely
// because somebody is doing a blocking read on our file descriptor. If that's the case,
// then send the "q" char to the command file channel so the read will wake up and the connection
// will then know to shut down.
m_shutting_down = true;
Mutex::Locker locker;
bool got_lock = locker.TryLock (m_mutex);
if (!got_lock)
{
if (m_pipe.WriteDescriptorIsValid())
{
int result;
result = m_pipe.Write("q", 1) == 1;
if (log)
log->Printf ("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, sent 'q' to %d, result = %d.",
static_cast<void*>(this), m_pipe.GetWriteFileDescriptor(), result);
}
else if (log)
{
log->Printf ("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.",
static_cast<void*>(this));
}
locker.Lock (m_mutex);
}
Error error = m_read_sp->Close();
Error error2 = m_write_sp->Close();
if (error.Fail() || error2.Fail())
status = eConnectionStatusError;
if (error_ptr)
*error_ptr = error.Fail() ? error : error2;
m_shutting_down = false;
return status;
}
示例3:
bool
GDBRemoteCommunication::GetSequenceMutex (Mutex::Locker& locker, const char *failure_message)
{
if (IsRunning())
return locker.TryLock (m_sequence_mutex, failure_message);
locker.Lock (m_sequence_mutex);
return true;
}
示例4:
ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref, Mutex::Locker &locker) :
m_target_sp (exe_ctx_ref.GetTargetSP()),
m_process_sp (),
m_thread_sp (),
m_frame_sp ()
{
if (m_target_sp)
{
locker.Lock(m_target_sp->GetAPIMutex());
m_process_sp = exe_ctx_ref.GetProcessSP();
m_thread_sp = exe_ctx_ref.GetThreadSP();
m_frame_sp = exe_ctx_ref.GetFrameSP();
}
}
示例5: process_sp
lldb::ValueObjectSP
GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
if (!m_valobj_sp)
{
error.SetErrorString("invalid value object");
return m_valobj_sp;
}
lldb::ValueObjectSP value_sp = m_valobj_sp;
Target *target = value_sp->GetTargetSP().get();
if (target)
api_locker.Lock(target->GetAPIMutex());
ProcessSP process_sp(value_sp->GetProcessSP());
if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock()))
{
// We don't allow people to play around with ValueObject if the process is running.
// If you want to look at values, pause the process, then look.
if (log)
log->Printf ("SBValue(%p)::GetSP() => error: process is running", value_sp.get());
error.SetErrorString ("process must be stopped.");
return ValueObjectSP();
}
if (value_sp->GetDynamicValue(m_use_dynamic))
value_sp = value_sp->GetDynamicValue(m_use_dynamic);
if (value_sp->GetSyntheticValue(m_use_synthetic))
value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
if (!value_sp)
error.SetErrorString("invalid value object");
if (!m_name.IsEmpty())
value_sp->SetName(m_name);
return value_sp;
}
示例6:
void
WatchpointList::GetListMutex (Mutex::Locker &locker)
{
return locker.Lock (m_mutex);
}