mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 11:07:34 +00:00
Added barrier pattern, thread yield and updated event API
This commit is contained in:
31
include/sta/rtos/patterns/barrier.hpp
Normal file
31
include/sta/rtos/patterns/barrier.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* barrier.hpp
|
||||
*
|
||||
* Created on: Mar 16, 2024
|
||||
* Author: Dario
|
||||
*/
|
||||
|
||||
#ifndef RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
|
||||
#define RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP
|
||||
|
||||
#include <sta/rtos/mutex.hpp>
|
||||
#include <sta/rtos/event.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
class Barrier {
|
||||
public:
|
||||
Barrier(const char* name, uint8_t n_threads);
|
||||
|
||||
void wait();
|
||||
private:
|
||||
RtosMutex mutex_;
|
||||
RtosEvent flag_;
|
||||
const uint8_t n_threads_;
|
||||
uint8_t n_entered_;
|
||||
uint8_t n_left_;
|
||||
};
|
||||
} // namespace sta
|
||||
|
||||
#endif /* RTOS2_UTILS_STA_PATTERNS_BARRIER_HPP_ */
|
Reference in New Issue
Block a user