Advertisement

基于c++11实现自定义线程类

阅读量:

利用c++11,简单定制自己的线程类

  • 借助c11实现对自定义线程类的简易开发
    • simplethreadh

simplethread.h

复制代码
    #ifndef SIMPLETHREAD_H
    #define SIMPLETHREAD_H
    
    #include <thread>
    #include <condition_variable>
    #include <memory>
    using namespace std::chrono;
    
    class SimpleThread
    {
    public:
    SimpleThread() :m_finished(false),
                    m_isStart(false)
    {
    
    }
    
    void start(){   
        m_thd = std::make_unique<std::thread>(&SimpleThread::entry,this);
        m_tid = m_thd->get_id();
    
        m_thd->detach(); // 分离线程
        m_isStart

全部评论 (0)

还没有任何评论哟~