Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Files | Concepts | Macros | Typedefs | Functions
Asynchronous Expression System

Files

file  async_traits.hpp
 Payload classification and write-through customization for asynchronous values.
 

Concepts

concept  uni20::async::read_buffer_awaitable
 concept for a valid type that behaves as a read buffer awaitable This requires that the awaiter has a value_type and await_resume() is available.
 
concept  uni20::async::write_buffer_awaitable
 concept for a valid type that behaves as a write buffer awaitable This requires that value_type x; co_await a = x is valid.
 
concept  uni20::async::emplace_buffer_awaitable
 concept for a valid type that supports in-place construction via emplace(...)
 
concept  uni20::async::emplace_buffer_awaitable_of
 
concept  uni20::async::read_buffer_awaitable_of
 concept for a valid type that behaves as a read buffer awaitable for type T.
 
concept  uni20::async::write_buffer_awaitable_of
 concept for a valid type that behaves as a write buffer awaitable This requires that T x; co_await a = x is valid.
 
concept  uni20::async::read_write_buffer_awaitable
 concept for a valid type that behaves as a write buffer that is also readable This requires that value_type x = co_await a; co_await a = x is valid
 
concept  uni20::async::read_write_buffer_awaitable_of
 concept for a valid type that behaves as a write buffer that is also readable This requires that T x = co_await a; co_await a = x is valid
 
concept  uni20::async::async_reader
 An async_reader is satisfied if .read() returns an async read buffer.
 
concept  uni20::async::async_writer
 An async_writer is satisfied if .write() returns a buffer supporting emplace(...).
 
concept  uni20::async::async_reader_of
 
concept  uni20::async::async_writer_to
 Concept requiring an async writer that accepts values constructible from T.
 
concept  uni20::async::async_movable_to
 Concept for an Awaitable that yields a movable object that can be moved into T.
 
concept  uni20::async::async_mutable_writer_of
 
concept  uni20::async::async_read_writer
 Concept for a type that behaves like an asynchronous writer that is also readable: it has a write() function that returns an awaiter that can be assigned from the nested value_type, and also read from.
 
concept  uni20::async::async_like
 Concept for a type that behaves like an asynchronous reader and writer (like Async<T>).
 
concept  uni20::async::async_binary_applicable
 Concept to determine if Op(T,U) is a candidate for forwarding for Async.
 
concept  uni20::async::async_binary_assignable
 concept for validating a binary operation true if the operation result can be emplaced into the writer output type.
 
concept  uni20::async::is_async_compound_applicable
 

Macros

#define UNI20_DEFINE_ASSIGN_OP(NAME, OP)
 
#define UNI20_DEFINE_ASYNC_COMPOUND_OPERATOR(OPSYM, FUNCTOR)
 
#define UNI20_DEFINE_BINARY_OP(OPNAME, OP)
 

Typedefs

template<typename T , typename U , typename Op >
using uni20::async::async_binary_result_t = decltype(std::declval< Op >()(std::declval< async_value_t< T > >(), std::declval< async_value_t< U > >()))
 Result type of applying binary op Op to async_value_t<T>, async_value_t
 
template<typename AsyncLike >
using uni20::async::take_awaiter_t = decltype(std::declval< write_buffer_t< AsyncLike > & >().take())
 Alias for the awaiter type returned by write_buffer_t::take().
 
template<typename AsyncLike >
using uni20::async::write_buffer_t = decltype(std::declval< AsyncLike & >().write())
 Alias for the write-buffer type produced by write() on an lvalue.
 

Functions

template<typename T , typename U >
requires (detail::current_value_assignment_source<T, U> || (is_async_alias_v<T> && detail::async_alias_assignable_from<T, async_value_t<U> const&>))
void uni20::async::async_assign (Async< T > &lhs, U &&rhs)
 Assigns an Async or scalar value into an Async destination.
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && read_buffer_awaitable_of<U, T> && detail::write_proxy_assignable_source<T, T>)
void uni20::async::async_assign (WriteBuffer< T > destination, U &&source)
 Assign an awaitable value into an existing independent-value timeline.
 
template<typename A , typename B , async_writer Writer, typename Op >
requires async_binary_applicable<A, B, Op>
void uni20::async::async_binary_op (Writer &out, A &&a, B &&b, Op op)
 Launch a coroutine computing result = op(a, b)
 
template<typename T , typename U , typename Op >
void uni20::async::async_compound_op (Async< T > &lhs, U &&rhs, Op op)
 Launch a coroutine applying an in-place operation op(lhs, rhs).
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_source<U> && std::constructible_from<T, async_value_t<U> const&>)
void uni20::async::async_initialize (Async< T > &destination, U &&source)
 Initialize a fresh independent async value from another async source.
 
template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_initialization_awaitable<U, T>)
void uni20::async::async_initialize (WriteBuffer< T > destination, U &&source)
 Initialize empty independent-value storage from an awaitable source.
 
template<typename T , typename U >
requires (!is_async_alias_v<T>)
void uni20::async::async_move (Async< T > &lhs, U &&rhs)
 Move-assign from a source expression into an Async destination.
 
template<typename T , typename U >
requires (!is_async_alias_v<T>) && async_mutable_writer_of<U, T> && async_movable_to<U, T>
void uni20::async::async_move (WriteBuffer< T > lhs, U &&rhs)
 
template<typename T , typename U >
requires read_buffer_awaitable_of<U, T>
void uni20::async::async_negate (WriteBuffer< T > lhs, U &&rhs)
 Negate a source value asynchronously and write into a destination buffer.
 
template<typename T >
requires requires(T t) { -t; }
auto uni20::async::operator- (Async< T > const &x)
 Unary negation overload for Async values.
 

Detailed Description

Macro Definition Documentation

◆ UNI20_DEFINE_ASSIGN_OP

#define UNI20_DEFINE_ASSIGN_OP (   NAME,
  OP 
)
Value:
struct NAME \
{ \
template <typename LHS, typename RHS> void operator()(LHS& lhs, RHS&& rhs) const \
{ \
lhs OP std::forward<RHS>(rhs); \
} \
};

◆ UNI20_DEFINE_ASYNC_COMPOUND_OPERATOR

#define UNI20_DEFINE_ASYNC_COMPOUND_OPERATOR (   OPSYM,
  FUNCTOR 
)
Value:
template <typename T, typename U> \
requires uni20::async::is_async_compound_applicable<Async<T>&, U, uni20::async::FUNCTOR> \
Async<T>& operator OPSYM(Async<T>& lhs, U && rhs) \
{ \
uni20::async::async_compound_op(lhs, std::forward<U>(rhs), uni20::async::FUNCTOR{}); \
return lhs; \
}
Definition async_ops.hpp:167

◆ UNI20_DEFINE_BINARY_OP

#define UNI20_DEFINE_BINARY_OP (   OPNAME,
  OP 
)
Value:
template <typename T, typename U> \
requires async_binary_applicable<T, U, OP> \
auto operator OPNAME(T&& a, U&& b) \
{ \
using R = async_binary_result_t<T, U, OP>; \
Async<R> result; \
async_binary_op(result, std::forward<T>(a), std::forward<U>(b), OP{}); \
return result; \
}

Typedef Documentation

◆ async_binary_result_t

template<typename T , typename U , typename Op >
using uni20::async::async_binary_result_t = typedef decltype(std::declval<Op>()(std::declval<async_value_t<T> >(), std::declval<async_value_t<U> >()))

Result type of applying binary op Op to async_value_t<T>, async_value_t

◆ take_awaiter_t

template<typename AsyncLike >
using uni20::async::take_awaiter_t = typedef decltype(std::declval<write_buffer_t<AsyncLike>&>().take())

Alias for the awaiter type returned by write_buffer_t::take().

◆ write_buffer_t

template<typename AsyncLike >
using uni20::async::write_buffer_t = typedef decltype(std::declval<AsyncLike&>().write())

Alias for the write-buffer type produced by write() on an lvalue.

Function Documentation

◆ async_assign() [1/2]

template<typename T , typename U >
requires (detail::current_value_assignment_source<T, U> || (is_async_alias_v<T> && detail::async_alias_assignable_from<T, async_value_t<U> const&>))
void uni20::async::async_assign ( Async< T > &  lhs,
U &&  rhs 
)

Assigns an Async or scalar value into an Async destination.

Template Parameters
TDestination value type.
USource type (scalar or Async-like).
Parameters
lhsDestination async value.
rhsSource expression.

◆ async_assign() [2/2]

template<typename T , typename U >
requires (!is_async_alias_v<T> && read_buffer_awaitable_of<U, T> && detail::write_proxy_assignable_source<T, T>)
void uni20::async::async_assign ( WriteBuffer< T >  destination,
U &&  source 
)

Assign an awaitable value into an existing independent-value timeline.

The destination may already be constructed, so this operation requires both construction and assignment capability.

◆ async_binary_op()

template<typename A , typename B , async_writer Writer, typename Op >
requires async_binary_applicable<A, B, Op>
void uni20::async::async_binary_op ( Writer &  out,
A &&  a,
B &&  b,
Op  op 
)

Launch a coroutine computing result = op(a, b)

Constructs read/write buffers in dependency order and schedules the operation.

Template Parameters
AFirst operand (scalar or Async<T>)
BSecond operand (scalar or Async)
RResult value type
OpCallable with signature R(op(A, B))

◆ async_compound_op()

template<typename T , typename U , typename Op >
void uni20::async::async_compound_op ( Async< T > &  lhs,
U &&  rhs,
Op  op 
)

Launch a coroutine applying an in-place operation op(lhs, rhs).

The left operand contributes one exclusive WriteBuffer, which supplies access to its existing value. The right operand is a distinct reader or immediate value.

Template Parameters
URight-hand operand type (scalar or Async)
TValue type of the Async<T> being modified
OpCallable with signature void(T&, U const&)
Parameters
lhsLeft-hand operand of the form Async<T>& — this is the value being modified
rhsRight-hand operand (either U or Async)
op In-place operation to apply (e.g., a lambda using operator+=)

◆ async_initialize() [1/2]

template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_source<U> && std::constructible_from<T, async_value_t<U> const&>)
void uni20::async::async_initialize ( Async< T > &  destination,
U &&  source 
)

Initialize a fresh independent async value from another async source.

◆ async_initialize() [2/2]

template<typename T , typename U >
requires (!is_async_alias_v<T> && detail::async_initialization_awaitable<U, T>)
void uni20::async::async_initialize ( WriteBuffer< T >  destination,
U &&  source 
)

Initialize empty independent-value storage from an awaitable source.

This is used for fresh value timelines and deliberately requires construction but not assignment of T.

◆ async_move() [1/2]

template<typename T , typename U >
requires (!is_async_alias_v<T>)
void uni20::async::async_move ( Async< T > &  lhs,
U &&  rhs 
)

Move-assign from a source expression into an Async destination.

Template Parameters
TDestination value type.
USource type.
Parameters
lhsDestination async value.
rhsSource expression.

◆ async_move() [2/2]

template<typename T , typename U >
requires (!is_async_alias_v<T>) && async_mutable_writer_of<U, T> && async_movable_to<U, T>
void uni20::async::async_move ( WriteBuffer< T >  lhs,
U &&  rhs 
)

◆ async_negate()

template<typename T , typename U >
requires read_buffer_awaitable_of<U, T>
void uni20::async::async_negate ( WriteBuffer< T >  lhs,
U &&  rhs 
)

Negate a source value asynchronously and write into a destination buffer.

Template Parameters
USource type.
TDestination value type.
Parameters
lhsDestination write buffer.
rhsSource expression.

◆ operator-()

template<typename T >
requires requires(T t) { -t; }
auto uni20::async::operator- ( Async< T > const &  x)

Unary negation overload for Async values.

Template Parameters
TValue type.
Parameters
xSource async value.
Returns
Async value representing -x.