Skip to content

If I release the **timer** immediately after I call cancel, it will cause a permanent wait. #2095

@Missmiaom

Description

@Missmiaom

Expected behavior

When I call the timer's cancel at the end of the program, the timing task should exit exactly, even if the timer is immediately released after the call is called.

Actual behavior

If I set the parameter of cancel to false, it will cause a permanent wait.

Steps to reproduce the problem

So here's my demo.

class TimerTest
{
public:
	TimerTest()
		: _timerTask(new Poco::Util::TimerTaskAdapter<TimerTest>(*this, &TimerTest::doSomething))
	{
		_timer.schedule(_timerTask, 0, 1000);
	}

	~TimerTest()
	{
		stop();
	}

	void stop()
	{
		_timer.cancel(false);
	}

	void doSomething(Poco::Util::TimerTask& timerTask)
	{
		std::cout << "doSomething" << std::endl;
	}
private:
	Poco::Util::Timer _timer;
	Poco::Util::TimerTask::Ptr _timerTask;
};

int main()
{
	TimerTest* t = new TimerTest();
	delete t;
}

POCO version

1.8.0.1

Compiler and version

VS2017

Operating system and version

windows10

Other relevant information

I don't know if I'm using the wrong thing, but I think it should be taken into account.For example, if my timing task is longer, when my program ends, I want cancel to return immediately and release the timer, which is the problem.I would be grateful if anyone could help me.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions