1
+ // //////////////////////////////////////////////////////////////////////////////////////////////////
2
+ // Copyright (c) 2024 RacoonStudios
3
+ //
4
+ // Permission is hereby granted, free of charge, to any person obtaining a copy of this
5
+ // software and associated documentation files (the "Software"), to deal in the Software
6
+ // without restriction, including without limitation the rights to use, copy, modify, merge,
7
+ // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
8
+ // to whom the Software is furnished to do so, subject to the following conditions:
9
+ //
10
+ // The above copyright notice and this permission notice shall be included in all copies or
11
+ // substantial portions of the Software.
12
+ //
13
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
+ // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
15
+ // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
16
+ // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
17
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
+ // DEALINGS IN THE SOFTWARE.
19
+ // //////////////////////////////////////////////////////////////////////////////////////////////////
20
+
21
+
22
+ // [-------------------------------------------------------]
23
+ // [ Header guard ]
24
+ // [-------------------------------------------------------]
25
+ #pragma once
26
+
27
+
28
+ // [-------------------------------------------------------]
29
+ // [ Includes ]
30
+ // [-------------------------------------------------------]
31
+ #include " core/core.h"
32
+
33
+
34
+ // [-------------------------------------------------------]
35
+ // [ Namespace ]
36
+ // [-------------------------------------------------------]
37
+ namespace core {
38
+
39
+
40
+ // [-------------------------------------------------------]
41
+ // [ Forward declarations ]
42
+ // [-------------------------------------------------------]
43
+
44
+
45
+ // [-------------------------------------------------------]
46
+ // [ Classes ]
47
+ // [-------------------------------------------------------]
48
+ /* *
49
+ * @class
50
+ * Runnable
51
+ *
52
+ * @brief
53
+ * Runnable implementation, which are used within the multi-threading pipeline.
54
+ */
55
+ class Runnable {
56
+
57
+ // [-------------------------------------------------------]
58
+ // [ Public functions ]
59
+ // [-------------------------------------------------------]
60
+ public:
61
+
62
+ /* *
63
+ * @brief
64
+ * Constructor.
65
+ */
66
+ Runnable () = default ;
67
+
68
+ /* *
69
+ * @brief
70
+ * Destructor.
71
+ */
72
+ virtual ~Runnable () = default ;
73
+
74
+
75
+ /* *
76
+ * @brief
77
+ * Called on initialization.
78
+ *
79
+ * @return
80
+ */
81
+ virtual bool init ();
82
+
83
+ /* *
84
+ * @brief
85
+ * This method is called on stop.
86
+ */
87
+ virtual void stop ();
88
+
89
+ /* *
90
+ * @brief
91
+ * This method is called on exit.
92
+ */
93
+ virtual void exit ();
94
+
95
+ /* *
96
+ * @brief
97
+ * This method is called when the threads reaches the end of the runnable instance.
98
+ *
99
+ * @param[in] killed
100
+ * True if the thread itself was killed.
101
+ */
102
+ virtual void post_work (bool killed);
103
+
104
+
105
+ /* *
106
+ * @brief
107
+ * Runs the runnable instance.
108
+ *
109
+ * @return
110
+ * The return code of the runnable.
111
+ */
112
+ virtual int32 run () = 0;
113
+ };
114
+
115
+
116
+ // [-------------------------------------------------------]
117
+ // [ Namespace ]
118
+ // [-------------------------------------------------------]
119
+ } // core
0 commit comments