blob: 744ca90c9535d7c570a999086146d3ee9023ba17 [file] [log] [blame]
Jeff Thompsonfa306642013-06-17 15:06:57 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Alexander Afanasyev
5 * Zhenkai Zhu
6 *
7 * BSD license, See the LICENSE file for more information
8 *
9 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
10 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
11 */
12
13#ifndef ONE_TIME_TASK_H
14#define ONE_TIME_TASK_H
15
16#include "task.h"
17
18class OneTimeTask : public Task
19{
20public:
21 OneTimeTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler, double delay);
22 virtual ~OneTimeTask(){}
23
24 // invoke callback and mark self as invoked and deregister self from scheduler
25 virtual void
26 run() _OVERRIDE;
27
28 // after reset, the task is marked as un-invoked and can be add to scheduler again, with same delay
29 // if not invoked yet, no effect
30 virtual void
31 reset() _OVERRIDE;
32
33private:
34 // this is to deregister itself from scheduler automatically after invoke
35 void
36 deregisterSelf();
37};
38
39
40#endif // EVENT_SCHEDULER_H