POCO时间戳和时间班

Poco TimeStamps and Timespans

本文关键字:时间 时间戳 POCO      更新时间:2023-10-16

我正在尝试使用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;
    }
}

但是,如果语句不编译,则在上面的超时检查:说非法结构操作。

有关如何使用这些POCO类的线索?

这与Poco::Timespan

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