update scheduler test for reschedule
diff --git a/scheduler/scheduler.cc b/scheduler/scheduler.cc
index 029be5c..2806075 100644
--- a/scheduler/scheduler.cc
+++ b/scheduler/scheduler.cc
@@ -124,7 +124,7 @@
Scheduler::rescheduleTask(const TaskPtr &task)
{
ReadLock lock(m_mutex);
- TaskMapIt it = m_taskMap.find(tag);
+ TaskMapIt it = m_taskMap.find(task->tag());
if (it != m_taskMap.end())
{
TaskPtr task = it->second;
diff --git a/test/test-event-scheduler.cc b/test/test-event-scheduler.cc
index 0eacba0..4db9a0e 100644
--- a/test/test-event-scheduler.cc
+++ b/test/test-event-scheduler.cc
@@ -96,6 +96,16 @@
BOOST_CHECK_EQUAL(scheduler->size(), 1);
usleep(1000000);
+ BOOST_CHECK_EQUAL(scheduler->size(), 0);
+ scheduler->addTask(task1);
+ usleep(400000);
+ BOOST_CHECK_EQUAL(scheduler->size(), 1);
+ scheduler->rescheduleTask(task1);
+ usleep(400000);
+ BOOST_CHECK_EQUAL(scheduler->size(), 1);
+ usleep(110000);
+ BOOST_CHECK_EQUAL(scheduler->size(), 0);
+
int hello = 0, world = 0, period = 0;
@@ -116,8 +126,8 @@
period = it->second;
}
- // added four times, canceled once before invoking callback
- BOOST_CHECK_EQUAL(hello, 3);
+ // added five times, canceled once before invoking callback
+ BOOST_CHECK_EQUAL(hello, 4);
// added two times, canceled once by matcher before invoking callback
BOOST_CHECK_EQUAL(world, 1);
// invoked every 0.2 seconds before deleted by matcher