22 #if defined(__QNXNTO__)
25 #include <sys/neutrino.h>
39 struct qnx_tick_source
52 template<
typename... Tasks>
53 class qnx_pulse_task_executor
56 explicit qnx_pulse_task_executor(Tasks&... tasks)
59 channel_id_ = ChannelCreate(_NTO_CHF_PRIVATE);
60 if (channel_id_ >= 0) {
62 ConnectAttach(0, 0, channel_id_, _NTO_SIDE_CHANNEL, 0);
66 qnx_pulse_task_executor(qnx_pulse_task_executor
const&) =
delete;
67 qnx_pulse_task_executor& operator=(qnx_pulse_task_executor
const&) =
delete;
69 ~qnx_pulse_task_executor()
71 if (connection_id_ >= 0) {
72 ConnectDetach(connection_id_);
74 if (channel_id_ >= 0) {
75 ChannelDestroy(channel_id_);
82 [[nodiscard]]
bool valid() const noexcept
84 return channel_id_ >= 0 && connection_id_ >= 0;
89 if (connection_id_ >= 0) {
90 static_cast<void>(MsgSendPulse(connection_id_, -1, wake_code, 0));
101 if (channel_id_ < 0) {
105 std::uint64_t timeout_ns = receive_timeout_ns;
106 static_cast<void>(TimerTimeout(CLOCK_MONOTONIC,
107 _NTO_TIMEOUT_RECEIVE,
114 MsgReceivePulse(channel_id_, &pulse,
sizeof(pulse),
nullptr));
117 [[nodiscard]]
bool step()
119 return ready_.step();
122 std::size_t run_ready()
124 const auto ran = ready_.run_ready();
133 const auto resumed = ready_.tick(elapsed_ticks);
142 return tick(elapsed_ticks.
count());
150 template<auto Entry, std::
size_t Instance = 0U>
153 auto result = ready_.template start<Entry, Instance>();
160 template<
auto Entry,
typename... Args>
163 auto result = ready_.template spawn<Entry>(std::forward<Args>(args)...);
170 [[nodiscard]] runtime::task_spawner<qnx_pulse_task_executor>
spawner()
172 return runtime::task_spawner<qnx_pulse_task_executor>{ *
this };
175 template<auto Entry, std::
size_t Instance = 0U>
178 return ready_.template task_status<Entry, Instance>();
181 template<auto Entry, std::
size_t Instance = 0U>
184 return ready_.template task_failure_reason<Entry, Instance>();
187 template<auto Entry, std::
size_t Instance = 0U>
188 [[nodiscard]]
bool cancel() noexcept
190 const bool cancelled = ready_.template cancel<Entry, Instance>();
197 void cancel_all() noexcept
204 static constexpr
int wake_code = _PULSE_CODE_MINAVAIL;
205 static constexpr std::uint64_t receive_timeout_ns = 1'000'000ULL;
208 int channel_id_{ -1 };
209 int connection_id_{ -1 };
212 template<
typename... Tasks>
213 qnx_pulse_task_executor(Tasks&...) -> qnx_pulse_task_executor<Tasks...>;
215 template<
typename... Tasks>
task_spawner< Executor > spawner
Definition: executor.h:150
cooperative_executor(Tasks &...) -> cooperative_executor< Tasks... >
Definition: bare_metal.h:20
constexpr unsigned qnx_supported_major
QNX support is intentionally a QNX 7.x target surface.
Definition: qnx.h:18
task_failure_reason
Definition: coroutine.h:170
constexpr tick_count ticks(tick_rep value) noexcept
Definition: ticks.h:85
task_status
Definition: coroutine.h:160
bare_metal_task_executor< Tasks... > task_executor
Definition: bare_metal.h:166
spawn_result
Definition: coroutine.h:181
TSM_TICK_REP tick_rep
Definition: ticks.h:35
Strong value type for semantic scheduler ticks.
Definition: ticks.h:54
constexpr tick_rep count() const noexcept
Definition: ticks.h:73