我正在尝试编写一个命令行服务器,该服务器将从串行端口接收信息,解析它,并将其记录在一个内部对象中。
然后根据客户端的请求,服务器将返回请求的信息。
我想要做的是将接收器和解析器部分放在一个单独的线程中,以便让服务器同时运行,而不干扰数据收集。
#include <iostream>
#include <thread>
class exampleClass{
    std::thread *processThread;
    public void completeProcess(){
        while(1){
            processStep1();
            if (verification()){processStep2()}
        }
    };
    void processStep1(){...};
    void processStep2(){...};
    bool verification(){...};
    void runThreaded();
} // End example class definition
// The idea being that this thread runs independently
// until I call the object's destructor
exampleClass::runThreaded(){
    std::thread processThread(&exampleClass::completeProcess, this);
} // Unfortunately The program ends up crashing here with CIGARET