-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fiber scheduling is now thread local, and truly thread-shared data structures are protected by a global lock.
- Loading branch information
Showing
18 changed files
with
311 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
|
||
#include <cassert> | ||
#include <mutex> | ||
#include <utility> | ||
|
||
|
||
namespace simsycl::detail { | ||
|
||
class system_lock { | ||
public: | ||
system_lock(); | ||
|
||
private: | ||
template<typename F> | ||
friend decltype(auto) with_system_lock(F &&f); | ||
|
||
std::lock_guard<std::recursive_mutex> m_lock; | ||
}; | ||
|
||
template<typename T> | ||
class shared_value { | ||
public: | ||
shared_value() : m_value() {} | ||
shared_value(const T &v) : m_value(v) {} | ||
shared_value(T &&v) : m_value(std::move(v)) {} | ||
|
||
template<typename... Params> | ||
shared_value(const std::in_place_t /* tag */, Params &&...params) : m_value(std::forward<Params>(params)...) {} | ||
|
||
shared_value(const shared_value &) = delete; | ||
shared_value(shared_value &&) = delete; | ||
shared_value &operator=(const shared_value &) = delete; | ||
shared_value &operator=(shared_value &&) = delete; | ||
|
||
~shared_value() = default; | ||
|
||
T &with(system_lock & /* lock */) { return m_value; } | ||
|
||
private: | ||
T m_value; | ||
}; | ||
|
||
} // namespace simsycl::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.