当前位置: 首页>>代码示例>>C++>>正文


C++ mutex::Locker类代码示例

本文整理汇总了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;
}
开发者ID:AlexShiLucky,项目名称:swift-lldb,代码行数:31,代码来源:ModuleList.cpp

示例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;
}
开发者ID:jashank,项目名称:freebsd,代码行数:59,代码来源:ConnectionFileDescriptor.cpp

示例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;
}
开发者ID:Rutuja15,项目名称:lldb-310.2.36,代码行数:9,代码来源:GDBRemoteCommunication.cpp

示例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();
    }
}
开发者ID:carlokok,项目名称:lldb,代码行数:14,代码来源:ExecutionContext.cpp

示例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;
    }
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:38,代码来源:SBValue.cpp

示例6:

void
WatchpointList::GetListMutex (Mutex::Locker &locker)
{
    return locker.Lock (m_mutex);
}
开发者ID:BlueRiverInteractive,项目名称:lldb,代码行数:5,代码来源:WatchpointList.cpp


注:本文中的mutex::Locker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。