00001 // 00002 // plumbing - C++ wrapper facades for Berkeley sockets 00003 // Copyright (C) 2009 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU General Public License, version 3, as published 00007 // by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT 00010 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00012 // more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along 00015 // with this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #ifndef LIBPLUMBING_AT_SERVICE_H 00019 #define LIBPLUMBING_AT_SERVICE_H 00020 00021 #include <deque> 00022 00023 #include <libplumbing/time_value.h> 00024 00025 namespace plumbing { 00026 00027 class at_job; // forward 00028 00038 class at_service 00039 { 00040 public: 00044 virtual ~at_service(); 00045 00049 at_service(); 00050 00060 void register_job(const time_value &when, at_job *jp); 00061 00071 void register_job_delta(const time_value &seconds, at_job *jp); 00072 00080 void unregister_job(at_job *jp); 00081 00087 time_value get_maximum_sleep() const; 00088 00100 void process(); 00101 00109 bool empty() const { return queue.empty(); } 00110 00111 private: 00112 struct queue_item 00113 { 00114 time_value when; 00115 at_job *job; 00116 }; 00117 00118 typedef std::deque<queue_item> queue_t; 00119 00124 queue_t queue; 00125 00129 at_service(const at_service &); 00130 00134 at_service &operator=(const at_service &); 00135 }; 00136 00137 } 00138 00139 #endif // LIBPLUMBING_AT_SERVICE_H 00140 // vim: set ts=4 et