1
0
Fork 0
mirror of https://gitlab.com/niansa/cosched.git synced 2025-03-06 20:53:26 +01:00

Added some hints to ScheduledThread functions

This commit is contained in:
niansa/tuxifan 2023-05-04 15:07:56 +02:00
parent 637889421a
commit 1e3e3c7786
2 changed files with 5 additions and 2 deletions

View file

@ -11,8 +11,8 @@ add_library(cosched STATIC scheduler.cpp include/scheduler.hpp include/scheduled
target_link_libraries(cosched PUBLIC async)
target_include_directories(cosched PUBLIC include/)
add_executable(test test.cpp)
target_link_libraries(test PRIVATE cosched)
#add_executable(test test.cpp)
#target_link_libraries(test PRIVATE cosched)
install(TARGETS cosched
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View file

@ -46,6 +46,7 @@ class ScheduledThread {
public:
ScheduledThread() {}
// MUST NOT already be running
void start() {
thread = std::thread([this] () {
main_loop();
@ -64,11 +65,13 @@ public:
conditional_lock.notify_one();
}
// MUST already be running
void wait() {
joined = true;
thread.join();
}
// MUST already be running
void shutdown() {
enqueue([this] (Scheduler&) {
shutdown_requested = true;