sigx++  2.0.1
tunnel_context_base.h
Go to the documentation of this file.
1 #ifndef _SIGX_TUNNEL_CONTEXT_BASE_HPP_
2 #define _SIGX_TUNNEL_CONTEXT_BASE_HPP_
3 
4 /*
5  * Copyright 2008 Klaus Triendl
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21 */
22 
23 #include <glibmm/thread.h>
24 #include <sigx/fwddecl.h>
25 #include <sigx/bad_dispatcher.h>
26 #include <sigx/operator_new.h>
29 
30 
31 namespace sigx
32 {
33 
42 class SIGX_API tunnel_context_base: public operator_new
43 {
44 public:
45  tunnel_context_base(const shared_dispatchable& _A_disp, const tunnel_validity_tracker& _A_validity_tracker, bool sync = false);
46  virtual ~tunnel_context_base();
47 
50  virtual void invoke() = 0;
51 
52  bool is_sync() const { return m_sync; }
53  bool is_valid() const { return m_validity_tracker.is_valid(); }
54  const void* creator_thread() const { return m_creator_thread; }
55 
56 protected:
60  void dispatch_me();
61 
62 protected:
65  bool m_sync;
66  const void* const m_creator_thread;
67 };
68 
69 
74 {
75 public:
76  sync_tunnel_context_base(const shared_dispatchable& _A_disp, const tunnel_validity_tracker& _A_validity_tracker);
77 
78 
79 protected:
88  void dispatch_me();
89 
90 
91 protected:
92  Glib::Cond m_cond;
93  Glib::Mutex m_mutex;
94 };
95 
96 
97 } // namespace sigx
98 
99 
100 #endif // end file guard
const void *const m_creator_thread
Definition: tunnel_context_base.h:66
Glib::Cond m_cond
Definition: tunnel_context_base.h:92
the base class for all tunnel_context classes.
Definition: tunnel_context_base.h:42
tunnel_validity_tracker m_validity_tracker
Definition: tunnel_context_base.h:63
const void * creator_thread() const
Definition: tunnel_context_base.h:54
Ensures allocation of derived objects in the sigx module.
Definition: operator_new.h:33
Interface for tracking the validity of a tunnel.
Definition: tunnel_validity_tracker.h:34
shared_dispatchable m_disp
Definition: tunnel_context_base.h:64
Specialities for synchronous tunnel context.
Definition: tunnel_context_base.h:73
bool m_sync
Definition: tunnel_context_base.h:65
bool is_valid() const
Definition: tunnel_context_base.h:53
bool is_sync() const
Definition: tunnel_context_base.h:52
Glib::Mutex m_mutex
Definition: tunnel_context_base.h:93
thread safe dispatcher reference that can be passed around.
Definition: shared_dispatchable.h:50