Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
util.h File Reference
#include <capnp/schema.h>
#include <cassert>
#include <cstddef>
#include <cstring>
#include <exception>
#include <functional>
#include <kj/string-tree.h>
#include <mutex>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mp::TypeList< Types >
 Generic utility functions used by capnp code. More...
struct  mp::Split< 0, _Second, _First, true >
 Specialization of above (base case). More...
struct  mp::Split< index, TypeList< Type, _Second... >, TypeList< _First... >, false >
 Specialization of above (recursive case). More...
struct  mp::_Require< SfinaeExpr, Result_ >
 SFINAE helper, see using Require below. More...
struct  mp::Priority< priority >
struct  mp::Priority< 0 >
 Specialization of above (base case). More...
struct  mp::PtrOrValue< T >
 Convenient wrapper around std::variant<T*, T>. More...
class  mp::Lock
struct  mp::GuardedRef< T >
struct  mp::UnlockGuard< Lock >
 Analog to std::lock_guard that unlocks instead of locks. More...
struct  mp::InterruptException
 Exception thrown from code executing an IPC call that is interrupted. More...
class  mp::CancelMonitor
class  mp::CancelProbe
 Helper object to attach to a promise and update a CancelMonitor. More...

Namespaces

namespace  mp
 Functions to serialize / deserialize common bitcoin types.

Macros

#define MP_TSA(x)
#define MP_CAPABILITY(x)
#define MP_SCOPED_CAPABILITY   MP_TSA(scoped_lockable)
#define MP_REQUIRES(x)
#define MP_ACQUIRE(...)
#define MP_RELEASE(...)
#define MP_ASSERT_CAPABILITY(x)
#define MP_GUARDED_BY(x)
#define MP_NO_TSA   MP_TSA(no_thread_safety_analysis)

Typedefs

template<typename Callable>
using mp::ResultOf = decltype(std::declval<Callable>()())
 Type helper giving return type of a callable type.
template<typename T>
using mp::RemoveCvRef = std::remove_cv_t<std::remove_reference_t<T>>
 Substitutue for std::remove_cvref_t.
template<typename T>
using mp::Decay = std::decay_t<T>
 Type helper abbreviating std::decay.
template<typename SfinaeExpr, typename Result = void>
using mp::Require = typename _Require<SfinaeExpr, Result>::Result
 SFINAE helper, basically the same as to C++17's void_t, but allowing types other than void to be returned.
using mp::FdToArgsFn = std::function<std::vector<std::string>(int fd)>
 Callback type used by SpawnProcess below.

Functions

template<template< typename... > class Class, typename... Types, typename... Args>
Class< Types..., std::remove_reference_t< Args >... > mp::Make (Args &&... args)
template<typename T>
const char * mp::TypeName ()
 Return capnp type name with filename prefix removed.
class mp::MP_CAPABILITY ("mutex") Mutex
template<class U>
 mp::GuardedRef (Mutex &, U &) -> GuardedRef< U >
template<typename Lock, typename Callback>
void mp::Unlock (Lock &lock, Callback &&callback)
template<typename Fn, typename After>
decltype(auto) mp::TryFinally (Fn &&fn, After &&after)
std::string mp::ThreadName (const char *exe_name)
 Format current thread name as "{exe_name}-{$pid}/{thread_name}-{$tid}".
std::string mp::LogEscape (const kj::StringTree &string, size_t max_size)
int mp::SpawnProcess (int &pid, FdToArgsFn &&fd_to_args)
void mp::ExecProcess (const std::vector< std::string > &args)
int mp::WaitProcess (int pid)
 Wait for a process to exit and return its exit code.
char * mp::CharCast (char *c)
char * mp::CharCast (unsigned char *c)
const char * mp::CharCast (const char *c)
const char * mp::CharCast (const unsigned char *c)

Macro Definition Documentation

◆ MP_ACQUIRE

#define MP_ACQUIRE ( ...)
Value:
MP_TSA(acquire_capability(__VA_ARGS__))
#define MP_TSA(x)
Definition util.h:151

Definition at line 157 of file util.h.

◆ MP_ASSERT_CAPABILITY

#define MP_ASSERT_CAPABILITY ( x)
Value:
MP_TSA(assert_capability(x))

Definition at line 159 of file util.h.

◆ MP_CAPABILITY

#define MP_CAPABILITY ( x)
Value:
MP_TSA(capability(x))

Definition at line 154 of file util.h.

◆ MP_GUARDED_BY

#define MP_GUARDED_BY ( x)
Value:
MP_TSA(guarded_by(x))

Definition at line 160 of file util.h.

◆ MP_NO_TSA

#define MP_NO_TSA   MP_TSA(no_thread_safety_analysis)

Definition at line 161 of file util.h.

◆ MP_RELEASE

#define MP_RELEASE ( ...)
Value:
MP_TSA(release_capability(__VA_ARGS__))

Definition at line 158 of file util.h.

◆ MP_REQUIRES

#define MP_REQUIRES ( x)
Value:
MP_TSA(requires_capability(x))

Definition at line 156 of file util.h.

◆ MP_SCOPED_CAPABILITY

#define MP_SCOPED_CAPABILITY   MP_TSA(scoped_lockable)

Definition at line 155 of file util.h.

◆ MP_TSA

#define MP_TSA ( x)

Definition at line 151 of file util.h.