Poco 时间戳和时间跨度

Poco TimeStamps and Timespans

我正在尝试使用 Poco 时间 类 来计算我程序中的一些时间。我想检测线程中的超时。

我首先创建一个表示我的超时时间的时间跨度,一个线程启动时间的时间戳,并检查当前时间跨度是否大于超时时间,即

Poco::Timestamp startTime;
Poco::Timespan timeOutTime(60*Poco::Timespan::SECONDS); // 60s timeout

我想在定时器函数中检查超时:

bool Process::isTimedOut()
{
    Timestamp now;
    if((now - startTime) > timeOutTime)
    {
        return true;
    }
    else
    {
        return false;
    }
}

但是上面if语句中的超时检查不编译:说非法结构操作。

关于如何使用这些 poco 的任何线索 类?

这适用于 Poco::Timespan:

bool isTimedOut()
{
    Poco::Timestamp now;
    Poco::Timespan timeElapsed(now - startTime);
    if( timeElapsed > timeOutTime)
    {
        return true;
    }
    else
    {
        return false;
    }
}