-1

我在编译时遇到了一个问题。

我收到错误:

在成员函数 'void CSConnection::onReadable(const Poco::AutoPtr&)':| CSConnection.cpp|92|错误:没有匹配的函数调用 'Poco::ThreadPool::start(QuitHandler* )'| CSConnection.cpp|92|注意:候选人是:| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|122|注意:void Poco::ThreadPool::start(Poco: :可运行&)| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|122|注意:'QuitHandler 中的参数 1 没有已知的转换*' 到 'Poco::Runnable&'| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|127|注意:void Poco::ThreadPool::start(Poco: :Runnable&, 常量字符串&)| c:\mingw\bin..\lib\gcc\mingw32\4.7.2........\include\Poco\ThreadPool.h|127|注意:候选人需要 2 个参数,提供 1 个| ||=== 构建完成:1 个错误,0 个警告(0 分钟,1 秒)===|

这是 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);

谢谢!

4

1 回答 1

1

start 方法接受引用,而不是指针: http: //pocoproject.org/docs/Poco.ThreadPool.html#11337

快速修复将是:

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

或者

QuitHandler* qh = new QuitHandler();
WorkerThreadPool::getInstance().tp->start(*qh);
于 2013-08-20T23:12:40.823 回答