FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
CTCLThread.h
Go to the documentation of this file.
1 /*
2  This software is Copyright by the Board of Trustees of Michigan
3  State University (c) Copyright 2017.
4 
5  You may use this software under the terms of the GNU public license
6  (GPL). The terms of this license are described at:
7 
8  http://www.gnu.org/licenses/gpl.txt
9 
10  Authors:
11  Ron Fox
12  Giordano Cerriza
13  NSCL
14  Michigan State University
15  East Lansing, MI 48824-1321
16 */
17 
21 #ifndef CTCLTHREAD_H
22 #define CTCLTHREAD_H
23 #include <tcl.h>
30 {
31 private:
32  Tcl_ThreadId m_threadId;
33  int m_flags;
34  int m_stacksize;
35  bool m_exitRequested;
36 
37  // A pointer to this is passed as client data to the static thread starter.
38 
39  struct MyClientData {
40  CTCLThread* m_pThis;
41  ClientData m_pArg;
42  } m_trampolineArgs;
43  static Tcl_ThreadDataKey m_tsdkey;
44 public:
45  CTCLThread(int flags = TCL_THREAD_JOINABLE, int stacksize = TCL_THREAD_STACK_DEFAULT);
46  virtual ~CTCLThread();
47 
48  void start(ClientData pData = nullptr);
49  void requestExit();
50 
51  virtual int operator()(ClientData arg) = 0;
52  virtual void exitHandler();
53 
54  int join();
55 
56  static Tcl_ThreadId currentThread();
57 protected:
58  bool exitRequested() const;
59 private:
60  static Tcl_ThreadCreateType runTrampoline(ClientData pData);
61  static void exitTrampoline(ClientData obj);
62 };
63 
64 
65 #endif
static Tcl_ThreadId currentThread()
Definition: CTCLThread.cpp:125
virtual ~CTCLThread()
Definition: CTCLThread.cpp:53
virtual void exitHandler()
Definition: CTCLThread.cpp:99
CTCLThread(int flags=TCL_THREAD_JOINABLE, int stacksize=TCL_THREAD_STACK_DEFAULT)
Definition: CTCLThread.cpp:35
Definition: CTCLThread.h:29
void start(ClientData pData=nullptr)
Definition: CTCLThread.cpp:67
void requestExit()
Definition: CTCLThread.cpp:84
bool exitRequested() const
Definition: CTCLThread.cpp:138
int join()
Definition: CTCLThread.cpp:111