Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ezekiel Dohmen
advLigoRTS
Commits
45a72207
Commit
45a72207
authored
Aug 02, 2022
by
Ezekiel Dohmen
Browse files
Fixing typo, and adding some comments
parent
fd317c09
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dolphin_daemon/include/LIGO_Thread.hpp
View file @
45a72207
...
...
@@ -8,24 +8,53 @@ class LIGO_Thread
{
public:
/**
* @brief This is the method that LIGO_Thread inheritors must implement
*
*/
virtual
void
thread_body
()
=
0
;
/**
* @brief When this method is called, the thread is spawned and started.
* The caller will not be blocked, and can continue doing other work.
*
*/
void
nonblocking_start
()
{
_thread
=
std
::
thread
(
&
LIGO_Thread
::
thread_body
,
this
);
}
void
blocking_satrt
()
/**
* @brief When this method is called, the calling thread is blocked until
* the thread_body() implementation exits, usually signaled to do
* so by signal_stop()
*
*/
void
blocking_start
()
{
nonblocking_start
();
join
();
if
(
_joined
==
false
)
{
join
();
_joined
=
true
;
}
}
/**
* @brief When this method is called, the _should_stop variable is set to stop.
* The thread_body() implementation should be checking should_stop() in
* its main loop and respond by exiting.
*
*/
void
signal_stop
()
{
_should_stop
=
true
;
}
/**
* @brief Joins with an exited thread.
*
*/
void
join
()
{
if
(
_joined
==
false
)
...
...
@@ -35,10 +64,19 @@ class LIGO_Thread
}
}
/**
* @brief This method signals the thread to stop and waits for the thread
* join.
*
*/
void
signal_stop_and_join
()
{
signal_stop
();
join
();
if
(
_joined
==
false
)
{
join
();
_joined
=
true
;
}
}
virtual
~
LIGO_Thread
()
{}
...
...
@@ -50,6 +88,11 @@ class LIGO_Thread
{
}
/**
* @brief The thread_body() implementation should be checking should_stop() in
* its main loop and respond by exiting when true.
*
*/
bool
should_stop
()
{
return
_should_stop
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment