編譯時出現了一個問題。C++ POCO運行在線程問題
我recive錯誤:
In member function 'void CSConnection::onReadable(const Poco::AutoPtr&)':| CSConnection.cpp|92|error: no matching function for call to 'Poco::ThreadPool::start(QuitHandler*)'| CSConnection.cpp|92|note: candidates are:| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|122|note: void Poco::ThreadPool::start(Poco::Runnable&)| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|122|note: no known conversion for argument 1 from 'QuitHandler*' to 'Poco::Runnable&'| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|127|note: void Poco::ThreadPool::start(Poco::Runnable&, const string&)| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|127|note: candidate expects 2 arguments, 1 provided| ||=== Build finished: 1 errors, 0 warnings (0 minutes, 1 seconds) ===|
這裏是quithandler類:
class QuitHandler : public Runnable
{
public:
QuitHandler(){}
CSConnection * _con;
void run();
virtual ~QuitHandler();
protected:
private:
char * _packet;
};
以下錯誤行
QuitHandler * qh;
qh = new QuitHandler();
WorkerThreadPool::getInstance().tp->start(qh);
謝謝!
現在,我得到這個錯誤:CSConnection.cpp | 90 |錯誤:穿越的 'QuitHandler QH' 初始化| –
請發佈演示此錯誤的最簡單示例。或者閱讀「交叉初始化」意思的一些解釋,你可能會發現它自己:http://stackoverflow.com/questions/2392655/what-are-the-signs-of-crosses-initialization。 – BartoszKP
{} in switch修復了它,但是應用程序在線程啓動時崩潰,run函數不被調用。 –