-
Notifications
You must be signed in to change notification settings - Fork 24
Implement task and task_scheduler #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0ab6dd5
Fix issue where lvalue scope-tokens cannot be used as arguments for `…
Cra3z 4ae10ef
Exception safety on `spawn` allocation failure
Cra3z 920e89d
WIP(exec.task)
Cra3z ac2fd63
WIP(exec.task)
Cra3z 76e54fc
Fix bugs
Cra3z 33081a5
Add test
Cra3z 3229b9c
Merge branch 'exec-task'
Cra3z 5c0a3ee
Add missing headers
Cra3z 3220ad9
Format code
Cra3z 6dd91ee
Workaround failed template argument deduction for optional::value_or
Cra3z e548149
Workaround for the bug of equality operator in gcc 15
Cra3z File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,33 @@ | ||
| // include/beman/execution/detail/meta_index.hpp -*-C++-*- | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX | ||
| #define INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX | ||
|
|
||
| #include <beman/execution/detail/common.hpp> | ||
| #ifdef BEMAN_HAS_IMPORT_STD | ||
| import std; | ||
| #else | ||
| #include <cstddef> | ||
| #endif | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| namespace beman::execution::detail::meta { | ||
| template <::std::size_t, typename, typename> | ||
| struct index { | ||
| static constexpr ::std::size_t value = static_cast<::std::size_t>(-1); | ||
| }; | ||
| template <::std::size_t I, template <typename...> class L, typename First, typename... Rest, typename T> | ||
| struct index<I, L<First, Rest...>, T> : index<I + 1uz, L<Rest...>, T> {}; | ||
| template <::std::size_t I, template <typename...> class L, typename... Rest, typename T> | ||
| struct index<I, L<T, Rest...>, T> { | ||
| static constexpr ::std::size_t value = I; | ||
| }; | ||
| template <typename List, typename T> | ||
| inline constexpr ::std::size_t index_v{::beman::execution::detail::meta::index<0uz, List, T>::value}; | ||
| } // namespace beman::execution::detail::meta | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| #endif // INCLUDED_BEMAN_EXECUTION_DETAIL_META_INDEX |
This file contains hidden or 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,45 @@ | ||
| // include/beman/execution/detail/new_object.hpp -*-C++-*- | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #ifndef INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT | ||
| #define INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT | ||
|
|
||
| #include <beman/execution/detail/common.hpp> | ||
| #ifdef BEMAN_HAS_IMPORT_STD | ||
| import std; | ||
| #else | ||
| #include <memory> | ||
| #include <utility> | ||
| #endif | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| namespace beman::execution::detail { | ||
| template <typename T, typename Allocator, typename... Args> | ||
| [[nodiscard]] auto new_object(const Allocator& allocator, Args&&... args) -> T* { | ||
| using alloc_t = typename ::std::allocator_traits<Allocator>::template rebind_alloc<T>; | ||
| using alloc_traits = ::std::allocator_traits<alloc_t>; | ||
| alloc_t alloc(allocator); | ||
| auto ptr = alloc_traits::allocate(alloc, 1); | ||
| try { | ||
| alloc_traits::construct(alloc, ptr, ::std::forward<Args>(args)...); | ||
| return ptr; | ||
| } catch (...) { | ||
| alloc_traits::deallocate(alloc, ptr, 1); | ||
| throw; | ||
| } | ||
| } | ||
|
|
||
| template <typename Allocator, typename T> | ||
| auto delete_object(const Allocator& allocator, T* ptr) noexcept -> void { | ||
| using alloc_t = typename ::std::allocator_traits<Allocator>::template rebind_alloc<T>; | ||
| using alloc_traits = ::std::allocator_traits<alloc_t>; | ||
| alloc_t alloc(allocator); | ||
| alloc_traits::destroy(alloc, ptr); | ||
| alloc_traits::deallocate(alloc, ptr, 1); | ||
| } | ||
| } // namespace beman::execution::detail | ||
|
|
||
| // ---------------------------------------------------------------------------- | ||
|
|
||
| #endif // INCLUDED_INCLUDE_BEMAN_EXECUTION_DETAIL_NEW_OBJECT |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? I don't think it is wrong.