blob: d3b536ab6b050e93e5a1bb64cacd03b06dc22c6d [file] [log] [blame]
Alexander Afanasyevca6f3292012-04-09 10:03:30 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * Chaoyi Bian <bcy@pku.edu.cn>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
22
23#ifndef SYNC_SCHEDULER_H
24#define SYNC_SCHEDULER_H
25
26#include <boost/date_time/posix_time/posix_time.hpp>
27#include "sync-event.h"
28
29namespace Sync {
30
31/**
32 * @ingroup sync
33 * @brief General purpose event scheduler
34 *
35 * This class internally runs a thread and events can be scheduled by specifying an absolute or relative time of the event
36 */
37class Scheduler
38{
39public:
40 /**
41 * @brief Default constructor. Thread will be created
42 */
43 Scheduler ();
44 /**
45 * @brief Destructor. Thread will be nicely stopped
46 */
47 ~Scheduler ();
48
49 /**
50 * @brief Schedule an event at absolute time 'abstime'
51 * @param abstime Absolute time
52 * @param event function to be called at the time
53 * @param label Label for the event
54 */
55 // void
56 // schedule (const boost::system_time &abstime, Event event, uint32_t label);
57
58 /**
59 * @brief Schedule an event at relative time 'reltime'
60 * @param reltime Relative time
61 * @param event function to be called at the time
62 * @param label Label for the event
63 */
64 void
65 schedule (const boost::posix_time::time_duration &reltime, Event event, uint32_t label);
66
67 /**
68 * @brief Cancel all events for the label
69 * @param label Label of the event that needs to be cancelled
70 */
71 void
72 cancel (uint32_t label);
73};
74
75}
76
77#endif // SYNC_SCHEDULER_H