Valkka  1.6.1
OpenSource Video Management
testthread.h
Go to the documentation of this file.
1 #ifndef testthread_HEADER_GUARD
2 #define testthread_HEADER_GUARD
3 /*
4  * testthread.h :
5  *
6  * (c) Copyright 2017-2024 Sampsa Riikonen
7  *
8  * Authors: Sampsa Riikonen <sampsa.riikonen@iki.fi>
9  *
10  * This file is part of the Valkka library.
11  *
12  * Valkka is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License as
14  * published by the Free Software Foundation, either version 3 of the
15  * License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program. If not, see <https://www.gnu.org/licenses/>
24  *
25  */
26 
36 #include "Python.h"
37 #include "thread.h"
38 
39 
40 enum class TestSignal {
41  none,
42  exit,
43  add
44 };
45 
46 
47 
49  TestSignal signal;
50 };
51 
52 
53 
54 class TestThread : public Thread { // <pyapi>
55 
56 public: // <pyapi>
57  TestThread(const char* name); // <pyapi>
58  virtual ~TestThread(); // <pyapi>
59 
60 protected:
61  std::deque<TestSignalContext> signal_fifo;
62 
63 protected:
64  PyObject *pyfunc;
65 
66 public:
67  void run();
68  void preRun();
69  void postRun();
70 
71 protected:
72  void triggerCallback(int i);
73  void sendSignal(TestSignalContext signal_ctx);
74 
75 public: // <pyapi>
76  void setCallback(PyObject* pobj); // <pyapi>
77  void stopCall(); // <pyapi>
78  void addCall(); // <pyapi>
79 }; // <pyapi>
80 
81 
82 #endif
Definition: testthread.h:54
void stopCall()
API method: stops the thread.
Definition: testthread.cpp:150
void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: testthread.cpp:56
std::deque< TestSignalContext > signal_fifo
Redefinition of signal fifo (Thread::signal_fifo becomes hidden)
Definition: testthread.h:61
void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: testthread.cpp:53
void run()
Main execution loop is defined here.
Definition: testthread.cpp:110
A class for multithreading with a signaling system.
Definition: thread.h:87
std::string name
Name of the thread.
Definition: thread.h:116
Definition: testthread.h:48
Base class for multithreading.
@ none
undefined (initial value)
Definition: usbthread.h:143