Skip to content

chrono clock should be defined in config.hpp #399

@thirtytwobits

Description

@thirtytwobits

See https://en.cppreference.com/w/cpp/named_req/TrivialClock

This is a design change, not a bug.

Using chrono becomes tricky when implementing the platform layer because C++ chrono treats system time as a global resource. Furthermore, on some systems chrono clocks are implemented by lower-level (read -> C) clocks also used by the platform implementation. We may want to remove ITimeProvider in favor of simply designating a chrono clock all parts of libcyphal will use as a compile-time configuration (with defaults) allowing a given platform to ensure the same timebase by providing a custom chrono clock backed by the low-level implementation for said platform.

If libcyphal always uses a compile-time-configured clock then unit testing is just as easy to handle as a dummy clock can be configured for tests when control over time is needed.

There doesn't seem to be another other benefit to supporting polymorphism in our timekeeping mechanism, unless I'm missing something.

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions