00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef LIBMUTH_WAITQUEUE_H
00020 #define LIBMUTH_WAITQUEUE_H
00021
00022 #include <queue>
00023 #include "callback_decls.h"
00024 #include "timeval_decls.h"
00025
00029 class WaitQueue {
00030 private:
00031 class Waiter : public Timeval {
00032 public:
00033 Callback &callback;
00034 Waiter(Callback&, const timeval&);
00035 Timeval delay() const;
00036 Timeval delay(const timeval &now) const;
00037 bool iscompleted() const;
00038 };
00039 class WaiterComparator : public std::binary_function<Waiter*,
00040 Waiter*, bool> {
00041 public:
00042 bool operator()(Waiter *a, Waiter *b) {
00043 return *a > *b; }
00044 };
00045
00046 std::priority_queue<Waiter*, std::vector<Waiter*>,
00047 WaiterComparator> waits;
00048 public:
00055 bool isempty() const;
00061 Timeval delay() const;
00068 Timeval delay(const timeval &now) const;
00075 void put(Callback &callback, const timeval &tv);
00081 Callback *get();
00088 Callback *get(const timeval &now);
00095 bool cleanup();
00096
00097 };
00098
00099 #endif