我正在尝试编写一个命令行服务器,它可以接收串口传来的信息,对其进行解析,并将其记录在内部对象中。
然后,在客户端的请求下,服务器会返回所请求的信息。
我想要做的是将接收器和解析器部分放在一个单独的线程中,以便让服务器在数据收集过程中不受干扰地运行。
然后,在客户端的请求下,服务器会返回所请求的信息。
我想要做的是将接收器和解析器部分放在一个单独的线程中,以便让服务器在数据收集过程中不受干扰地运行。
#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
public void completeProcess() { ..
可以编译吗? - Deqing