Lumiera  0.pre.03
»edit your freedom«
steam-dispatcher.hpp
Go to the documentation of this file.
1 /*
2  STEAM-DISPATCHER.hpp - Steam-Layer command dispatch and execution
3 
4  Copyright (C) Lumiera.org
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program 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.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
54 #ifndef STEAM_CONTROL_PROC_DISPATCHER_H
55 #define STEAM_CONTROL_PROC_DISPATCHER_H
56 
57 #include "common/subsys.hpp"
58 #include "lib/depend.hpp"
59 #include "lib/sync.hpp"
60 
61 #include <memory>
62 
63 
64 
65 namespace steam {
66 namespace control {
67 
68  using std::unique_ptr;
69  using lumiera::Subsys;
70 
71 
72  class DispatcherLoop;
73 
74 
87  : public lib::Sync<>
88  {
89  unique_ptr<DispatcherLoop> runningLoop_;
90  bool active_{false};
91 
92  public:
94 
95  bool start (Subsys::SigTerm);
96  bool isRunning();
97  void requestStop() noexcept;
98 
99  void activate();
100  void deactivate();
101  void awaitDeactivation();
102  void clear();
103 
104  bool empty() const ;
105 
106  private:
107  void endRunningLoopState();
108 
109  ~SteamDispatcher();
110  SteamDispatcher();
111  friend class lib::DependencyFactory<SteamDispatcher>;
112  };
113 
114 
115 
116 
117 }} // namespace steam::control
118 #endif /*STEAM_CONTROL_PROC_DISPATCHER_H*/
Facility for monitor object based locking.
Definition: sync.hpp:217
static lib::Depend< SteamDispatcher > instance
storage for Singleton access
void awaitDeactivation()
block until the dispatcher has actually reached disabled state.
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition: subsys.hpp:70
Guard to manage processing commands to operate on the session.
void clear()
discard any commands waiting in the dispatcher queue
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:289
Implementation namespace for support and library code.
bool start(Subsys::SigTerm)
starting the SteamDispatcher means to start the session subsystem.
Object Monitor based synchronisation.
Describing dependencies and lifecycle of the application&#39;s primary parts.
void requestStop() noexcept
signal to the loop thread that it needs to terminate.
Singleton services and Dependency Injection.
void deactivate()
halt further processing of session commands
void activate()
activate processing of enqueued session commands.
bool isRunning()
whether the »session subsystem« is operational.