Skip to content
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

Clang format all but the Win32-specific files #580

Merged
merged 157 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
2c271f4
Format adapt_stream.hpp
ispeters Oct 30, 2023
d5250e9
Format allocate.hpp
ispeters Oct 30, 2023
6e35396
Format any_object.hpp
ispeters Oct 30, 2023
cde78e4
Format any_ref.hpp
ispeters Oct 30, 2023
5b074bc
Format any_scheduler.hpp
ispeters Oct 30, 2023
efe7be7
Format any_sender_of.hpp
ispeters Oct 30, 2023
816cb41
Format any_unique.hpp
ispeters Oct 30, 2023
c32f34d
Format async_manual_reset_event.hpp
ispeters Oct 30, 2023
47781ad
Format async_mutext.hpp
ispeters Oct 30, 2023
25327bc
Format async_trace.hpp
ispeters Oct 30, 2023
3a3d07a
Format at_coroutine_exit.hpp
ispeters Oct 30, 2023
9558405
Format await_transform.hpp
ispeters Oct 30, 2023
67bafd8
Format bind_back.hpp
ispeters Oct 30, 2023
ac9df63
Format blocking.hpp
ispeters Oct 30, 2023
1898f13
Format bulk_join.hpp
ispeters Oct 30, 2023
4386b66
Format bulk_schedule.hpp
ispeters Oct 30, 2023
2f55797
Format bulk_transform.hpp
ispeters Oct 30, 2023
6cbb7e2
Format connect_awaitable.hpp
ispeters Oct 30, 2023
356f94c
Format continuations.hpp
ispeters Oct 30, 2023
11c7514
Format coroutine_concepts.hpp
ispeters Oct 30, 2023
5e9d237
Format coroutine.hpp
ispeters Oct 30, 2023
56f3e54
Format create.hpp
ispeters Oct 30, 2023
d26dcbe
Format defer.hpp
ispeters Oct 30, 2023
0590a87
Format delay.hpp
ispeters Oct 30, 2023
88a59d6
Format dematerialize.hpp
ispeters Oct 30, 2023
4b48816
Format detach_on_cancel.hpp
ispeters Oct 30, 2023
7668026
Format done_as_optional.hpp
ispeters Oct 30, 2023
f075e3a
Format exception.hpp
ispeters Oct 30, 2023
e40ee52
Format execution_policy.hpp
ispeters Oct 30, 2023
56e981b
Format file_concepts.hpp
ispeters Oct 30, 2023
42681b4
Format filesystem.hpp
ispeters Oct 30, 2023
30e93e9
Format finally.hpp
ispeters Oct 30, 2023
8380f15
Format find_if.hpp
ispeters Oct 30, 2023
3588d04
Format for_each.hpp
ispeters Oct 30, 2023
8e8e6b9
Format get_allocator.hpp
ispeters Oct 30, 2023
a77063d
Format get_execution_policy.hpp
ispeters Oct 30, 2023
d095da7
Format get_stop_token.hpp
ispeters Oct 30, 2023
f4de5aa
Format indexed_for.hpp
ispeters Oct 30, 2023
94c95ba
Format inline_scheduler.hpp
ispeters Oct 30, 2023
59e7fa2
Format inplace_stop_token.hpp
ispeters Oct 30, 2023
5a52898
Format into_variant.hpp
ispeters Oct 30, 2023
a081b57
Format invoke.hpp
ispeters Oct 30, 2023
535dbe9
Format io_concepts.hpp
ispeters Oct 30, 2023
1f0149c
Format just_done.hpp
ispeters Oct 30, 2023
5d2b735
Format just_error.hpp
ispeters Oct 30, 2023
98ecd47
Format just_from.hpp
ispeters Oct 30, 2023
210c9ae
Format just.hpp
ispeters Oct 30, 2023
21b3452
Format just_void_or_done.hpp
ispeters Oct 30, 2023
e931987
Format let_done.hpp
ispeters Oct 30, 2023
bbca264
format let_error.hpp
ispeters Oct 30, 2023
1ee7f43
Format let_value.hpp
ispeters Oct 30, 2023
835169e
Format let_value_with.hpp
ispeters Oct 30, 2023
56e0f4c
Format let_value_with_stop_source.hpp
ispeters Oct 30, 2023
1ab3efe
Format let_value_with_stop_token.hpp
ispeters Oct 30, 2023
0b73828
Format manual_event_loop.hpp
ispeters Oct 30, 2023
8a1152a
Format manual_lifetime.hpp
ispeters Oct 30, 2023
876d7f1
Format manual_lifetime_union.hpp
ispeters Oct 30, 2023
5fc00d8
Format materialize.hpp
ispeters Oct 30, 2023
85199df
Format memory_resource.hpp
ispeters Oct 30, 2023
2a0b91c
Format nest.hpp
ispeters Oct 30, 2023
0405f34
Format never.hpp
ispeters Oct 30, 2023
0960844
Format new_thread_context.hpp
ispeters Oct 30, 2023
059892b
Format next_adapt_stream.hpp
ispeters Oct 30, 2023
d46b1d4
Format null_receiver.hpp
ispeters Oct 30, 2023
9ceed7c
Format on.hpp
ispeters Oct 30, 2023
64278d4
Format on_stream.hpp
ispeters Oct 30, 2023
c142d4a
Format overload.hpp
ispeters Oct 30, 2023
956c71d
Format pipe_concepts.hpp
ispeters Oct 30, 2023
2a03788
Format range_stream.hpp
ispeters Oct 30, 2023
cf1e956
Format receiver_concepts.hpp
ispeters Oct 30, 2023
27c418d
Format reduce_stream.hpp
ispeters Oct 30, 2023
09a6860
Format repeat_effect_until.hpp
ispeters Oct 30, 2023
ecdf0bc
Format retry_when.hpp
ispeters Oct 30, 2023
06de4dd
Format scheduler_concepts.hpp
ispeters Oct 30, 2023
d161d5a
Format schedule_with_subscheduler.hpp
ispeters Oct 30, 2023
74a2597
Format scope_guard.hpp
ispeters Oct 30, 2023
821dc2a
Format sender_concepts.hpp
ispeters Oct 30, 2023
c46fbe9
Format sender_for.hpp
ispeters Oct 30, 2023
1f07788
Format sequence.hpp
ispeters Oct 30, 2023
8f9d317
Format single.hpp
ispeters Oct 30, 2023
c2614d3
Format single_thread_context.hpp
ispeters Oct 30, 2023
3eb0015
Format span.hpp
ispeters Oct 30, 2023
78ff4cd
Format spawn_detached.hpp
ispeters Oct 30, 2023
cc00bb1
Format spawn_future.hpp
ispeters Oct 30, 2023
6908fb1
Format spin_wait.hpp
ispeters Oct 30, 2023
12c08b7
Format static_thread_pool.hpp
ispeters Oct 30, 2023
b8facdc
Format std_concepts.hpp
ispeters Oct 30, 2023
d6f4daa
Format stop_if_requested.hpp
ispeters Oct 30, 2023
ba87b3c
Format stop_immediately.hpp
ispeters Oct 30, 2023
4abce9b
Format stop_token_concepts.hpp
ispeters Oct 30, 2023
0174994
Format stop_when.hpp
ispeters Oct 30, 2023
c9fe85d
Format stream_concepts.hpp
ispeters Oct 30, 2023
e2fa981
Format swap.hpp
ispeters Oct 30, 2023
1468ea3
Format sync_wait.hpp
ispeters Oct 30, 2023
2d101b2
Format tag_invoke.hpp
ispeters Oct 30, 2023
5572310
Format take_until.hpp
ispeters Oct 30, 2023
ade1a1c
Format then_execute.hpp
ispeters Oct 30, 2023
193e71c
Format then.hpp
ispeters Oct 30, 2023
e44b828
Format this.hpp
ispeters Oct 30, 2023
c968b70
Format thread_unsafe_event_loop.hpp
ispeters Oct 30, 2023
c6c762d
Format timed_single_thread_context.hpp
ispeters Oct 30, 2023
77c5711
Format trampoline_scheduler.hpp
ispeters Oct 30, 2023
107b2a0
Format transform_stream.hpp
ispeters Oct 30, 2023
0b6f14c
Format type_erased_stream.hpp
ispeters Oct 30, 2023
17c7f4b
Format type_index.hpp
ispeters Oct 30, 2023
0216a47
Format type_list.hpp
ispeters Oct 30, 2023
baa2be9
Format type_traits.hpp
ispeters Oct 30, 2023
bd49d74
Format unstoppable.hpp
ispeters Oct 30, 2023
b2c9ab4
Format unstoppable_token.hpp
ispeters Oct 30, 2023
86c262b
Format upon_done.hpp
ispeters Oct 30, 2023
c874131
Format upon_error.hpp
ispeters Oct 30, 2023
803f117
Format variant_sender.hpp
ispeters Oct 30, 2023
14ae7e7
Format via.hpp
ispeters Oct 30, 2023
fa0822d
Format via_stream.hpp
ispeters Oct 30, 2023
23ca28e
Format when_all.hpp
ispeters Oct 30, 2023
018a2d6
Format when_all_range.hpp
ispeters Oct 30, 2023
c190588
Format with_allocator.hpp
ispeters Oct 30, 2023
e615bfc
Format with_query_value.hpp
ispeters Oct 30, 2023
fcbe1e9
Format with_scheduler_affinity.hpp
ispeters Oct 30, 2023
94b884d
Format test/mock_receiver.hpp
ispeters Oct 30, 2023
d23b13a
Format detail/any_heap_allocated_storage.hpp
ispeters Oct 30, 2023
fd45d1b
Format detail/atomic_intrusive_queue.hpp
ispeters Oct 30, 2023
6a29507
Format detail/concept_macros.hpp
ispeters Oct 30, 2023
46483ff
Format detail/epilogue.hpp
ispeters Oct 30, 2023
f9b23cf
Format detail/intrusive_heap.hpp
ispeters Oct 30, 2023
726b504
Format detail/intrusive_list.hpp
ispeters Oct 30, 2023
c9aea7d
Format detail/intrusive_queue.hpp
ispeters Oct 30, 2023
1fa96bb
Format detail/intrusive_stack.hpp
ispeters Oct 30, 2023
914ddd0
Format detail/prologue.hpp
ispeters Oct 30, 2023
96b4b6f
Format detail/type_erasure_builtins.hpp
ispeters Oct 30, 2023
b0539d1
Format detail/unifex_fwd.hpp
ispeters Oct 30, 2023
f31a1e2
Format detail/vtable.hpp
ispeters Oct 30, 2023
1a5b453
Format detail/with_forwarding_tag_invoke.hpp
ispeters Oct 30, 2023
7ec1b8e
Format detail/with_type_erased_tag_invoke.hpp
ispeters Oct 30, 2023
f07e894
Format linux/io_epoll_context.hpp
ispeters Oct 30, 2023
e9d00f4
Format linux/io_uring_context.hpp
ispeters Oct 30, 2023
59831df
Format linux/mmap_region.hpp
ispeters Oct 30, 2023
0f0e31f
Format linux/monotonic_clock.hpp
ispeters Oct 30, 2023
b0729d0
Format linux/safe_file_descriptor.hpp
ispeters Oct 30, 2023
9f909a8
Format v0/async_scope.hpp
ispeters Oct 30, 2023
3fbd680
Format v1/async_scope.hpp
ispeters Oct 30, 2023
312b583
Format async_manual_reset_event.cpp
ispeters Oct 30, 2023
d0faea7
Format async_mutex.cpp
ispeters Oct 30, 2023
b0d282d
Format exception.cpp
ispeters Oct 30, 2023
68e070c
Format inplace_stop_token.cpp
ispeters Oct 30, 2023
ff780b9
Format manual_event_loop.cpp
ispeters Oct 30, 2023
2badc7b
Format static_thread_pool.cpp
ispeters Oct 30, 2023
4b3d7e9
Format task.cpp
ispeters Oct 30, 2023
00ba2bc
Format thread_unsage_event_loop.cpp
ispeters Oct 30, 2023
f945610
Format timed_single_thread_context.cpp
ispeters Oct 30, 2023
4bd8779
Format trampoline_scheduler.cpp
ispeters Oct 30, 2023
97b5e99
Format linux/io_epoll_context.cpp
ispeters Oct 30, 2023
4325b74
Format linux/io_uring_context.cpp
ispeters Oct 30, 2023
383b5fc
Format linux/mmap_region.cpp
ispeters Oct 30, 2023
75f6386
Format linux/monotonic_clock.cpp
ispeters Oct 30, 2023
8340c57
Format linux/safe_file_descriptor.cpp
ispeters Oct 30, 2023
16f1748
Format linux/io_uring_syscall.hpp
ispeters Oct 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions include/unifex/adapt_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ template <typename Stream, typename NextAdaptFunc, typename CleanupAdaptFunc>
struct _adapted {
struct type;
};
template <typename Stream, typename NextAdaptFunc, typename CleanupAdaptFunc = void>
template <
typename Stream,
typename NextAdaptFunc,
typename CleanupAdaptFunc = void>
using adapted = typename _adapted<
remove_cvref_t<Stream>,
std::decay_t<NextAdaptFunc>,
Expand Down Expand Up @@ -70,33 +73,33 @@ struct _adapted<Stream, AdaptFunc, void>::type {
return std::invoke(s.adapter_, cleanup(s.innerStream_));
}
};
} // namespace _adapt_stream
} // namespace _adapt_stream

namespace _adapt_stream_cpo {
inline const struct _fn {
template <typename Stream, typename AdapterFunc>
auto operator()(Stream&& stream, AdapterFunc&& adapt) const
-> _adapt_stream::adapted<Stream, AdapterFunc> {
return {(Stream &&) stream, (AdapterFunc &&) adapt};
}
inline const struct _fn {
template <typename Stream, typename AdapterFunc>
auto operator()(Stream&& stream, AdapterFunc&& adapt) const
-> _adapt_stream::adapted<Stream, AdapterFunc> {
return {(Stream &&) stream, (AdapterFunc &&) adapt};
}

template <
typename Stream,
typename NextAdapterFunc,
typename CleanupAdapterFunc>
auto operator()(
Stream&& stream,
NextAdapterFunc&& adaptNext,
CleanupAdapterFunc&& adaptCleanup) const
-> _adapt_stream::adapted<Stream, NextAdapterFunc, CleanupAdapterFunc> {
return {
(Stream &&) stream,
(NextAdapterFunc &&) adaptNext,
(CleanupAdapterFunc &&) adaptCleanup};
}
} adapt_stream {};
} // namespace _adapt_stream_cpo
template <
typename Stream,
typename NextAdapterFunc,
typename CleanupAdapterFunc>
auto operator()(
Stream&& stream,
NextAdapterFunc&& adaptNext,
CleanupAdapterFunc&& adaptCleanup) const
-> _adapt_stream::adapted<Stream, NextAdapterFunc, CleanupAdapterFunc> {
return {
(Stream &&) stream,
(NextAdapterFunc &&) adaptNext,
(CleanupAdapterFunc &&) adaptCleanup};
}
} adapt_stream{};
} // namespace _adapt_stream_cpo
using _adapt_stream_cpo::adapt_stream;
} // namespace unifex
} // namespace unifex

#include <unifex/detail/epilogue.hpp>
244 changes: 123 additions & 121 deletions include/unifex/allocate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
#pragma once

#include <unifex/config.hpp>
#include <unifex/bind_back.hpp>
#include <unifex/blocking.hpp>
#include <unifex/get_allocator.hpp>
#include <unifex/receiver_concepts.hpp>
#include <unifex/scope_guard.hpp>
#include <unifex/sender_concepts.hpp>
#include <unifex/tag_invoke.hpp>
#include <unifex/bind_back.hpp>
#include <unifex/blocking.hpp>

#include <memory>
#include <type_traits>
Expand All @@ -31,128 +31,130 @@

namespace unifex {
namespace _alloc {
template <typename Operation, typename Allocator>
struct _op {
class type;
};
template <typename Operation, typename Allocator>
using operation = typename _op<Operation, Allocator>::type;

template <typename Operation, typename Allocator>
class _op<Operation, Allocator>::type {
using operation = type;
using allocator_t = typename std::allocator_traits<
Allocator>::template rebind_alloc<Operation>;

public:
template <typename Sender, typename Receiver>
explicit type(Sender&& s, Receiver&& r)
: allocator_(get_allocator(r)) {
using allocator_traits = std::allocator_traits<allocator_t>;
Operation* op = allocator_traits::allocate(allocator_, 1);
scope_guard freeOnError = [&]() noexcept {
allocator_traits::deallocate(allocator_, op, 1);
};
op_ = ::new (static_cast<void*>(op))
Operation(connect((Sender &&) s, (Receiver &&) r));
freeOnError.release();
}

~type() {
op_->~Operation();
std::allocator_traits<allocator_t>::deallocate(allocator_, op_, 1);
}

friend void tag_invoke(tag_t<start>, operation& op) noexcept {
start(*op.op_);
}

private:
Operation* op_;
UNIFEX_NO_UNIQUE_ADDRESS allocator_t allocator_;
};

template <typename Sender>
struct _sender {
class type;
};
template <typename Sender>
using sender = typename _sender<remove_cvref_t<Sender>>::type;

template <typename Sender>
class _sender<Sender>::type {
using sender = type;
public:
template <
template <typename...> class Variant,
template <typename...> class Tuple>
using value_types = sender_value_types_t<Sender, Variant, Tuple>;

template <template <typename...> class Variant>
using error_types = sender_error_types_t<Sender, Variant>;

static constexpr bool sends_done = sender_traits<Sender>::sends_done;

static constexpr blocking_kind blocking = sender_traits<Sender>::blocking;

static constexpr bool is_always_scheduler_affine
= sender_traits<Sender>::is_always_scheduler_affine;

template(typename Self, typename Receiver)
(requires same_as<remove_cvref_t<Self>, type> AND
receiver<Receiver>)
friend auto tag_invoke(tag_t<connect>, Self&& s, Receiver&& r)
-> operation<
connect_result_t<member_t<Self, Sender>, Receiver>,
remove_cvref_t<get_allocator_t<Receiver>>> {
return operation<
connect_result_t<member_t<Self, Sender>, Receiver>,
remove_cvref_t<get_allocator_t<Receiver>>>{
static_cast<Self&&>(s).sender_, (Receiver &&) r};
}

friend constexpr blocking_kind tag_invoke(tag_t<unifex::blocking>, const type& self) noexcept {
return unifex::blocking(self.sender_);
}

Sender sender_;
};
} // namespace _alloc
template <typename Operation, typename Allocator>
struct _op {
class type;
};
template <typename Operation, typename Allocator>
using operation = typename _op<Operation, Allocator>::type;

template <typename Operation, typename Allocator>
class _op<Operation, Allocator>::type {
using operation = type;
using allocator_t = typename std::allocator_traits<
Allocator>::template rebind_alloc<Operation>;

public:
template <typename Sender, typename Receiver>
explicit type(Sender&& s, Receiver&& r) : allocator_(get_allocator(r)) {
using allocator_traits = std::allocator_traits<allocator_t>;
Operation* op = allocator_traits::allocate(allocator_, 1);
scope_guard freeOnError = [&]() noexcept {
allocator_traits::deallocate(allocator_, op, 1);
};
op_ = ::new (static_cast<void*>(op))
Operation(connect((Sender &&) s, (Receiver &&) r));
freeOnError.release();
}

~type() {
op_->~Operation();
std::allocator_traits<allocator_t>::deallocate(allocator_, op_, 1);
}

friend void tag_invoke(tag_t<start>, operation& op) noexcept {
start(*op.op_);
}

private:
Operation* op_;
UNIFEX_NO_UNIQUE_ADDRESS allocator_t allocator_;
};

template <typename Sender>
struct _sender {
class type;
};
template <typename Sender>
using sender = typename _sender<remove_cvref_t<Sender>>::type;

template <typename Sender>
class _sender<Sender>::type {
using sender = type;

public:
template <
template <typename...>
class Variant,
template <typename...>
class Tuple>
using value_types = sender_value_types_t<Sender, Variant, Tuple>;

template <template <typename...> class Variant>
using error_types = sender_error_types_t<Sender, Variant>;

static constexpr bool sends_done = sender_traits<Sender>::sends_done;

static constexpr blocking_kind blocking = sender_traits<Sender>::blocking;

static constexpr bool is_always_scheduler_affine =
sender_traits<Sender>::is_always_scheduler_affine;

template(typename Self, typename Receiver) //
(requires same_as<remove_cvref_t<Self>, type> AND receiver<Receiver>) //
friend auto tag_invoke(tag_t<connect>, Self&& s, Receiver&& r)
-> operation<
connect_result_t<member_t<Self, Sender>, Receiver>,
remove_cvref_t<get_allocator_t<Receiver>>> {
return operation<
connect_result_t<member_t<Self, Sender>, Receiver>,
remove_cvref_t<get_allocator_t<Receiver>>>{
static_cast<Self&&>(s).sender_, (Receiver &&) r};
}

friend constexpr blocking_kind
tag_invoke(tag_t<unifex::blocking>, const type& self) noexcept {
return unifex::blocking(self.sender_);
}

Sender sender_;
};
} // namespace _alloc

namespace _alloc_cpo {
inline const struct _fn {
private:
template <typename Sender>
using _result_t =
typename conditional_t<
tag_invocable<_fn, Sender>,
meta_tag_invoke_result<_fn>,
meta_quote1<_alloc::sender>>::template apply<Sender>;
public:
template(typename Sender)
(requires tag_invocable<_fn, Sender>)
auto operator()(Sender&& predecessor) const
noexcept(is_nothrow_tag_invocable_v<_fn, Sender>)
-> _result_t<Sender> {
return unifex::tag_invoke(_fn{}, (Sender&&) predecessor);
}
template(typename Sender)
(requires (!tag_invocable<_fn, Sender>))
auto operator()(Sender&& predecessor) const
noexcept(std::is_nothrow_constructible_v<_alloc::sender<Sender>, Sender>)
-> _result_t<Sender> {
return _alloc::sender<Sender>{(Sender &&) predecessor};
}
constexpr auto operator()() const
noexcept(is_nothrow_callable_v<
tag_t<bind_back>, _fn>)
-> bind_back_result_t<_fn> {
return bind_back(*this);
}
} allocate{};
} // namespace _alloc_cpo
inline const struct _fn {
private:
template <typename Sender>
using _result_t = typename conditional_t<
tag_invocable<_fn, Sender>,
meta_tag_invoke_result<_fn>,
meta_quote1<_alloc::sender>>::template apply<Sender>;

public:
template(typename Sender) //
(requires tag_invocable<_fn, Sender>) //
auto
operator()(Sender&& predecessor) const
noexcept(is_nothrow_tag_invocable_v<_fn, Sender>) -> _result_t<Sender> {
return unifex::tag_invoke(_fn{}, (Sender &&) predecessor);
}
template(typename Sender) //
(requires(!tag_invocable<_fn, Sender>)) //
auto
operator()(Sender&& predecessor) const
noexcept(std::is_nothrow_constructible_v<_alloc::sender<Sender>, Sender>)
-> _result_t<Sender> {
return _alloc::sender<Sender>{(Sender &&) predecessor};
}
constexpr auto operator()() const
noexcept(is_nothrow_callable_v<tag_t<bind_back>, _fn>)
-> bind_back_result_t<_fn> {
return bind_back(*this);
}
} allocate{};
} // namespace _alloc_cpo
using _alloc_cpo::allocate;

} // namespace unifex
} // namespace unifex

#include <unifex/detail/epilogue.hpp>
Loading
Loading