Skip to content
Snippets Groups Projects
Commit 5f1f2ccb authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[Fiber] Make isRunnable() perform a relaxed load and add documentation

It is safe to perform a relaxed load in isRunnable(), since the
information is potentially outdated immediately after it was looked
at.

Also, since Fiber::isRunnable() is a virtual method, keeping its
definition in the header has no real advantage, hence we move it out
of the header.
parent 043c8dc7
No related branches found
No related tags found
1 merge request!325Introduce AbstractFiber as superclass of all scheduled control flows
......@@ -13,6 +13,8 @@ void Fiber::run() const {
function(arg);
}
auto Fiber::isRunnable() const -> bool { return runnable.load(std::memory_order_relaxed); }
void Fiber::printTo(std::ostream &strm, bool withPtr) const {
strm << "Fiber [";
if (withPtr) {
......
......@@ -128,7 +128,17 @@ class ALIGN_TO_CACHE_LINE Fiber : public AbstractFiber, public Logger<LogSubsyst
void printTo(std::ostream& strm, bool withPtr) const;
[[nodiscard]] auto isRunnable() const -> bool { return runnable; }
/**
* @brief check if this Fiber is runnable.
*
* Checks if this Fiber can be run, i.e. if it still needs to be
* run. Note that with multi Fibers, a positive result, i.e., if
* this function returns 'true', may be outdated immediately due to
* concurrency.
*
* @return 'true' if this fiber is runnable, 'false' otherwhise.
*/
[[nodiscard]] auto isRunnable() const -> bool;
[[nodiscard]] auto isMultiFiber() const -> bool { return isMulti; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment