TheChess

TaskTracker.hpp

Go to the documentation of this file.
00001 /*
00002  * thechess, chess game web application written in C++ and based on Wt
00003  * Copyright (C) 2010 Boris Nagaev
00004  *
00005  * thechess is licensed under the GNU GPL Version 2.
00006  * Other versions of the GPL do not apply.
00007  * See the LICENSE file for terms of use.
00008  */
00009 
00010 #ifndef THECHESS_TASKTRACKER_HPP_
00011 #define THECHESS_TASKTRACKER_HPP_
00012 
00013 #include <boost/thread/mutex.hpp>
00014 #include <boost/asio.hpp>
00015 
00016 #include <Wt/WDateTime>
00017 
00018 #include "model/Object.hpp"
00019 #include "ThechessSession.hpp"
00020 
00021 namespace dbo = Wt::Dbo;
00022 
00023 namespace thechess {
00024 
00025 class ThechessServer;
00026 
00027 class TaskTracker {
00028 public:
00029     TaskTracker(ThechessServer& server);
00030     ~TaskTracker();
00031     void add_or_update_task(const Object& object);
00032 
00033 private:
00034     typedef std::multimap<Wt::WDateTime, Object> W2T;
00035     typedef W2T::iterator W2T_It;
00036     typedef std::map<Object, W2T_It> T2I;
00037     typedef T2I::iterator T2I_It;
00038 
00039     W2T w2t;
00040     T2I t2i;
00041     ThechessServer& server_;
00042     ThechessSession session_;
00043     boost::mutex mutex_;
00044     boost::asio::io_service io_;
00045     boost::asio::deadline_timer timer_;
00046     boost::asio::deadline_timer dummy_timer_; // to avoid io_'s stopping
00047 
00048     void io_run_();
00049     void check_(const boost::system::error_code& error);
00050     void add_or_update_task_(const Object& object);
00051     void refresh_();
00052 };
00053 
00054 }
00055 
00056 #endif
00057 
 All Classes Namespaces Files Functions