xsignal.h
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13  ***************************************************************************/
14 #ifndef signalH
15 #define signalH
16 
17 #include "support.h"
18 #include "xtime.h"
19 #include "xthread.h"
20 #include "atomic_smart_ptr.h"
21 #include <deque>
22 
23 //! Detect whether the current thread is the main thread.
24 DECLSPEC_KAME bool isMainThread();
25 
26 namespace Transactional {
27 template <class SS, typename...Args>
28 class Talker;}
29 
30 //! Base class of listener, which holds pointers to object and function.
31 //! Hold instances by shared_ptr.
32 class DECLSPEC_KAME XListener {
33 public:
34  virtual ~XListener();
35  //! \return an appropriate delay for delayed transactions.
36  unsigned int delay_ms() const;
37 
38  enum FLAGS : int {
39  FLAG_MAIN_THREAD_CALL = 0x01, FLAG_AVOID_DUP = 0x02,
40  FLAG_DELAY_SHORT = 0x100, FLAG_DELAY_ADAPTIVE = 0x200
41  };
42 
43  int flags() const {return (int)m_flags;}
44 protected:
45  template <class SS, typename...Args>
46  friend class Transactional::Talker;
47  XListener(FLAGS flags);
48  atomic<int> m_flags;
49 };
50 
51 class DECLSPEC_KAME XTalkerBase_ {
52 protected:
53 public:
54  virtual ~XTalkerBase_() = default;
55 protected:
56 };
57 
58 struct XTransaction_ {
59  XTransaction_() : registered_time(XTime::now()) {}
60  virtual ~XTransaction_() = default;
61  const XTime registered_time;
62  virtual bool talkBuffered() = 0;
63 };
64 
65 DECLSPEC_KAME void registerTransactionList(XTransaction_ *);
66 
67 #endif

Generated for KAME4 by  doxygen 1.8.3