Skip to content

This PR adds a new class to manage threads - #11

Merged
mmmarinho merged 19 commits into
SmartArmStack:jazzyfrom
juanjqo:jazzy_loopancho
Sep 4, 2026
Merged

This PR adds a new class to manage threads #11
mmmarinho merged 19 commits into
SmartArmStack:jazzyfrom
juanjqo:jazzy_loopancho

Conversation

@juanjqo

@juanjqo juanjqo commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Hi @mmmarinho,

This PR adds the class sas::thread_manager (codename: loopancho) to manage threads. The main motivation is the standardisation of the SAS drivers (at least in the Adorno-lab::RAICo projects), which currently implement custom threads. This class is experimental, since I haven't tested it yet with real platforms. It is the first version and we can improve it.

Current features:

  • Based on modern C++ and the standard library (no Boost =) )
  • Support for priority levels (only for GNU/Linux)
  • The class relies on sas::Clock for time computations.
  • Thread-safety

Please let me know what you think and whether the design aligns with what you have in mind.

Minimal example

#include <sas_core/sas_thread_manager.hpp>
#include <iostream>
#include <thread>

int main() {
    int counter = 0;

    // Create and start thread
    sas::thread_manager tm("test", 0.1, [&counter]() {
        std::cout << ++counter << "\n";
    });

    tm.start();

    // Run for 1 second
    std::this_thread::sleep_for(std::chrono::seconds(1));

    // Clean up
    tm.stop();
    return 0;
}

CMake

cmake_minimum_required(VERSION 3.16)

project(minimal_example LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
    sas_core
    GIT_REPOSITORY https://github.com/juanjqo/sas_core.git
    GIT_TAG        jazzy_loopancho
)
set(ROS2_BUILD OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(sas_core)
add_executable(minimal_example main.cpp)
target_link_libraries(minimal_example PRIVATE sas_core_pure)

output

./minimal_example
**************************************************************************
sas::Clock (c) Murilo M. Marinho (murilomarinho.info) 2016-2026 LGPLv3
**************************************************************************
1
2
3
4
5
6
7
8
9
10
11
17:05:20: The command "/home/juanjqo/Documents/sas_core_test_examples/thread_manager/minimal_example/build/Desktop_Qt_6_10_1-Debug/minimal_example" finished successfully.

Kind regards,

Juancho

@mmmarinho mmmarinho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission. Some suggestions!

Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread src/sas_thread_manager.cpp Outdated
Comment thread src/sas_thread_manager.cpp
Comment thread src/sas_thread_manager.cpp Outdated
@juanjqo
juanjqo marked this pull request as draft August 30, 2026 22:43
@juanjqo
juanjqo marked this pull request as ready for review August 30, 2026 23:52
@juanjqo

juanjqo commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mmmarinho. I implemented all modifications!

@mmmarinho mmmarinho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @juanjqo. Some minor additional comments.

Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread src/sas_thread_manager.cpp Outdated
@juanjqo
juanjqo marked this pull request as draft September 1, 2026 09:01
@juanjqo

juanjqo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @mmmarinho,

I updated the implementation taking into account your comments.

Kind regards,

Juancho

@juanjqo
juanjqo marked this pull request as ready for review September 1, 2026 22:01

@mmmarinho mmmarinho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @juanjqo. One last push and we should be ok.

Comment thread include/sas_core/sas_thread_manager.hpp Outdated
Comment thread src/sas_thread_manager.cpp Outdated
Comment thread src/sas_thread_manager.cpp Outdated
@juanjqo

juanjqo commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@mmmarinho, it's ready for the next round!

@mmmarinho
mmmarinho merged commit 1507ac2 into SmartArmStack:jazzy Sep 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants