Skip to content

Commit

Permalink
pollAwaitableResourcesFor now part of IPosixExecutorExtension int…
Browse files Browse the repository at this point in the history
…erface.
  • Loading branch information
serges147 committed Dec 23, 2024
1 parent ca67bb8 commit 5416290
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/common/platform/posix_executor_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <cetl/pf17/cetlpf.hpp>
#include <cetl/rtti.hpp>
#include <libcyphal/executor.hpp>
#include <libcyphal/transport/errors.hpp>

namespace ocvsmd
{
Expand Down Expand Up @@ -49,6 +50,11 @@ class IPosixExecutorExtension
libcyphal::IExecutor::Callback::Function&& function,
const Trigger::Variant& trigger) = 0;

using PollFailure = cetl::variant<libcyphal::transport::PlatformError, libcyphal::ArgumentError>;

CETL_NODISCARD virtual cetl::optional<PollFailure> pollAwaitableResourcesFor(
const cetl::optional<libcyphal::Duration> timeout) const = 0;

// MARK: RTTI

static constexpr cetl::type_id _get_type_id_() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ class KqueueSingleThreadedExecutor final : public libcyphal::platform::SingleThr
}
}

using PollFailure = cetl::variant<libcyphal::transport::PlatformError, libcyphal::ArgumentError>;

CETL_NODISCARD cetl::optional<PollFailure> pollAwaitableResourcesFor(
const cetl::optional<libcyphal::Duration> timeout) const
const cetl::optional<libcyphal::Duration> timeout) const override
{
CETL_DEBUG_ASSERT((total_awaitables_ > 0) || timeout,
"Infinite timeout without awaitables means that we will sleep forever.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ class EpollSingleThreadedExecutor final : public libcyphal::platform::SingleThre
}
}

using PollFailure = cetl::variant<libcyphal::transport::PlatformError, libcyphal::ArgumentError>;

CETL_NODISCARD cetl::optional<PollFailure> pollAwaitableResourcesFor(
const cetl::optional<libcyphal::Duration> timeout) const
const cetl::optional<libcyphal::Duration> timeout) const override
{
CETL_DEBUG_ASSERT((total_awaitables_ > 0) || timeout,
"Infinite timeout without awaitables means that we will sleep forever.");
Expand Down
4 changes: 4 additions & 0 deletions src/daemon/engine/platform/posix_platform_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class PosixPlatformError final : public libcyphal::transport::IPlatformError

// MARK: IPlatformError

/// Gets platform-specific error code.
///
/// In this case, the error code is the POSIX error code (aka `errno`).
///
std::uint32_t code() const noexcept override
{
return static_cast<std::uint32_t>(code_);
Expand Down

0 comments on commit 5416290

Please sign in to comment.