मैं एक कमांड लाइन सर्वर प्रोग्राम करने की कोशिश कर रहा हूं जो एक सीरियल पोर्ट से जानकारी प्राप्त करेगा, इसे पार्स करेगा, और इसे किसी आंतरिक ऑब्जेक्ट में रिकॉर्ड करेगा।सी ++ std :: सदस्य फ़ंक्शन का थ्रेड
फिर क्लाइंट से अनुरोध पर सर्वर अनुरोधित जानकारी वापस कर देगा।
मैं क्या करना चाहता हूं, रिसेवर & एक अलग थ्रेड में पार्सर भागों को रखने के लिए सर्वर को डेटा संग्रह के साथ हस्तक्षेप न करने के लिए रखा गया है।
#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
क्या सार्वजनिक शून्य पूर्ण प्रसंस्करण() {..' संकलित किया जा सकता है? – Deqing
[संभावित कार्य के साथ प्रारंभ धागा] का संभावित डुप्लिकेट (http://stackoverflow.com/questions/10673585/start-thread-with-member- कार्यक्षमता) –