您还必须意识到,从 Wt 3.3.0 开始,只有收到请求后才会清除会话(请参阅这个回复 http://redmine.webtoolkit.eu/boards/2/topics/5614?r=5615#message-5615Wt 开发人员)。为了克服这个限制,开发人员建议使用类似于以下代码的内容。
static bool terminating = false;
void
callRepeatedly(boost::function<void()> function, int seconds)
{
if (!terminating) {
Wt::WServer::instance()->ioService().schedule(
seconds * 1000, boost::bind(callRepeatedly, function, seconds));
}
function();
}
int
main(int argc, char** argv)
{
...
callRepeatedly(boost::bind(&Wt::WServer::expireSessions, &server), 60);
Wt::WServer::waitForShutdown();
terminating = true;
server.stop();
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)