xsignal.cpp
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 #include "xsignal.h"
15 #include "atomic_queue.h"
16 #include "xscheduler.h"
17 
18 threadid_t g_main_thread_id = threadID();
19 
20 bool isMainThread() {
21  return is_thread_equal(threadID(), g_main_thread_id);
22 }
23 
24 XListener::XListener(FLAGS flags) :
25  m_flags(flags) {
26  if(flags & FLAG_AVOID_DUP) {
27  assert(flags & FLAG_MAIN_THREAD_CALL);
28  }
29  if((flags & FLAG_DELAY_SHORT) || (flags & FLAG_DELAY_ADAPTIVE)) {
30  assert(flags & FLAG_AVOID_DUP);
31  }
32 }
33 XListener::~XListener() {}
34 
35 unsigned int
37  unsigned int delay = std::min(20u, (unsigned int)g_adaptiveDelay);
38  if(m_flags & FLAG_DELAY_ADAPTIVE)
39  delay = g_adaptiveDelay;
40  if(m_flags & FLAG_DELAY_SHORT)
41  delay /= 4;
42  return delay;
43 }
44 

Generated for KAME4 by  doxygen 1.8.3