Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
async.hh File Reference
#include "lix/libutil/error.hh"
#include "lix/libutil/result.hh"
#include "lix/libutil/signals.hh"
#include <future>
#include <kj/async-io.h>
#include <kj/async.h>
#include <optional>
#include <source_location>

Go to the source code of this file.

Classes

struct  nix::AsyncContext
struct  nix::AsyncIoRoot

Macros

#define LIX_RUN_ASYNC_IN_NEW_THREAD(...)
#define LIX_TRY_AWAIT_CONTEXT(ctx, ...)
#define LIX_TRY_AWAIT(...)

Functions

AsyncContextnix::AIO ()
void nix::detail::materializeResult (Result< void > r)
template<typename T>
nix::detail::materializeResult (Result< T > r)
template<typename T>
nix::detail::runAsyncUnwrap (T t)
template<typename T>
nix::detail::runAsyncUnwrap (Result< T > t)
auto nix::detail::runAsyncInNewThread (std::invocable< AsyncIoRoot & > auto fn)

Macro Definition Documentation

◆ LIX_RUN_ASYNC_IN_NEW_THREAD

#define LIX_RUN_ASYNC_IN_NEW_THREAD ( ...)
Value:
::nix::detail::runAsyncInNewThread([&](AsyncIoRoot & AIOROOT) { \
return AIOROOT.blockOn(__VA_ARGS__); \
})

◆ LIX_TRY_AWAIT

#define LIX_TRY_AWAIT ( ...)
Value:
LIX_TRY_AWAIT_CONTEXT(lixAsyncTaskContext, __VA_ARGS__)

◆ LIX_TRY_AWAIT_CONTEXT

#define LIX_TRY_AWAIT_CONTEXT ( ctx,
... )
Value:
({ \
auto _lix_awaited = co_await (__VA_ARGS__); \
if (_lix_awaited.has_error()) { \
try { \
_lix_awaited.value(); \
} catch (::nix::BaseException & e) { \
e.addAsyncTrace(::std::source_location::current(), ctx()); \
throw; \
} catch (::std::exception & e) { /* NOLINT(lix-foreign-exceptions) */ \
::nix::ForeignException fe(e); \
fe.addAsyncTrace(::std::source_location::current(), ctx()); \
throw fe; \
} \
} \
::nix::detail::materializeResult(std::move(_lix_awaited)); \
})
Definition error.hh:103