3 * Copyright 2007,2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef INCLUDED_MB_TIMER_QUEUE_H
23 #define INCLUDED_MB_TIMER_QUEUE_H
25 #include <mblock/time.h>
29 #include <mblock/msg_accepter.h>
33 mb_time d_when; // absolute time to fire timeout
34 mb_time d_delta; // if periodic, delta_t to next timeout
35 bool d_is_periodic; // true iff this is a periodic timeout
36 pmt_t d_user_data; // data from %timeout msg
37 pmt_t d_handle; // handle for cancellation
38 mb_msg_accepter_sptr d_accepter; // where to send the message
40 // one-shot constructor
41 mb_timeout(const mb_time &abs_time,
42 pmt_t user_data, mb_msg_accepter_sptr accepter);
44 // periodic constructor
45 mb_timeout(const mb_time &first_abs_time, const mb_time &delta_time,
46 pmt_t user_data, mb_msg_accepter_sptr accepter);
48 pmt_t handle() const { return d_handle; }
51 typedef boost::shared_ptr<mb_timeout> mb_timeout_sptr;
54 //! Sort criterion for priority_queue
58 bool operator() (const mb_timeout_sptr t1, const mb_timeout_sptr t2)
60 return t1->d_when > t2->d_when;
65 class mb_timer_queue : public std::priority_queue<mb_timeout_sptr,
66 std::vector<mb_timeout_sptr>,
70 void cancel(pmt_t handle);
73 #endif /* INCLUDED_MB_TIMER_QUEUE_H */