2013-08-20 2 views
-1

컴파일 할 때 한 가지 문제가 있습니다.스레드에서 실행되는 C++ POCO 문제

다음
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); 

감사 :

여기

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 클래스 :

나는 오류 받아 봐!

답변

1

시작 메소드는 포인터가 아니라 참조를 허용합니다 : http://pocoproject.org/docs/Poco.ThreadPool.html#11337.

빠른 수정은 다음과 같습니다 CSConnection.cpp | 90 | 오류 :

QuitHandler qh; 
WorkerThreadPool::getInstance().tp->start(qh); 

또는

QuitHandler* qh = new QuitHandler(); 
WorkerThreadPool::getInstance().tp->start(*qh); 
+0

지금 내가이 오류가 발생했습니다 'QuitHandler QH'의 초기화를 교차 | –

+0

이 오류를 설명하는 최소 예를 게시하십시오. 또는 "교차 초기화"의 의미에 대한 설명을 읽으면 아마 스스로를 찾을 수 있습니다. http://stackoverflow.com/questions/2392655/what-are-the-signs-of-crosses-initialization. – BartoszKP

+0

{}의 스위치가이를 수정했지만 스레드 시작, 실행 함수가 호출되지 않으면 응용 프로그램이 충돌합니다. –