Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Macros | Typedefs | Functions | Variables
util.h File Reference
#include <array>
#include <capnp/schema.h>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <functional>
#include <kj/async-io.h>
#include <kj/memory.h>
#include <kj/string-tree.h>
#include <mutex>
#include <string>
#include <tuple>
#include <typeinfo>
#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 >
 Type holding a list of types. 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 >
 Function parameter type for prioritizing overloaded function calls that would otherwise be ambiguous. More...
 
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
 Helper class that detects when a promise is canceled. More...
 
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.
 

Concepts

concept  mp::FieldTypeIs
 Concept satisfied when T's .get() method returns exactly type U.
 
concept  mp::InterfaceField
 Concept satisfied when T's .get() method returns a capnp interface type (i.e., a type that exposes a nested Calls type in generated code).
 

Macros

#define MP_TSA(x)
 
#define MP_CAPABILITY(x)   MP_TSA(capability(x))
 
#define MP_SCOPED_CAPABILITY   MP_TSA(scoped_lockable)
 
#define MP_REQUIRES(x)   MP_TSA(requires_capability(x))
 
#define MP_ACQUIRE(...)   MP_TSA(acquire_capability(__VA_ARGS__))
 
#define MP_RELEASE(...)   MP_TSA(release_capability(__VA_ARGS__))
 
#define MP_ASSERT_CAPABILITY(x)   MP_TSA(assert_capability(x))
 
#define MP_GUARDED_BY(x)   MP_TSA(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::Stream = kj::Own< kj::AsyncIoStream >
 
using mp::ProcessId = int
 
using mp::SocketId = int
 
using mp::SpawnConnectInfo = std::string
 Information about parent process passed to child process as a command-line argument.
 
using mp::SpawnConnectInfoToArgsFn = std::function< std::vector< std::string >(const SpawnConnectInfo &)>
 Callback type used by SpawnProcess below.
 

Functions

template<typename A , typename B >
constexpr bool mp::safe_less_equal (A a, B b)
 Generic utility functions used by capnp code.
 
template<typename A , typename B >
constexpr bool mp::safe_greater_equal (A a, B b)
 
template<template< typename... > class Class, typename... Types, typename... Args>
Class< Types..., std::remove_reference_t< Args >... > mp::Make (Args &&... args)
 Construct a template class value by deducing template arguments from the types of constructor arguments, so they don't need to be specified manually.
 
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)
 Invoke a function and run a follow-up action before returning the original result.
 
void mp::SetOsThreadName (const char *name)
 Set the OS-level name of the current thread.
 
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)
 Escape binary string for use in log so it doesn't trigger unicode decode errors in python unit tests.
 
std::tuple< ProcessId, SocketId > mp::SpawnProcess (SpawnConnectInfoToArgsFn &&connect_info_to_args)
 Spawn a new process that communicates with the current process over a socket pair.
 
SocketId mp::StartSpawned (const SpawnConnectInfo &connect_info)
 Initialize spawned child process using the SpawnConnectInfo string passed to it, returning a socket id for communicating with the parent process.
 
std::array< SocketId, 2 > mp::SocketPair ()
 Create a socket pair that can be used to communicate within a process or between parent and child processes.
 
ProcessId mp::StartProcess (const std::vector< std::string > &args)
 Start a process and return its process id.
 
int mp::WaitProcess (ProcessId 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)
 
std::string mp::_demangle (const char *m)
 
template<class T >
std::string mp::CxxTypeName (const T &)
 

Variables

constexpr SocketId mp::SocketError {-1}
 

Macro Definition Documentation

◆ MP_ACQUIRE

#define MP_ACQUIRE (   ...)    MP_TSA(acquire_capability(__VA_ARGS__))

Definition at line 194 of file util.h.

◆ MP_ASSERT_CAPABILITY

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

Definition at line 196 of file util.h.

◆ MP_CAPABILITY

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

Definition at line 191 of file util.h.

◆ MP_GUARDED_BY

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

Definition at line 197 of file util.h.

◆ MP_NO_TSA

Definition at line 198 of file util.h.

◆ MP_RELEASE

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

Definition at line 195 of file util.h.

◆ MP_REQUIRES

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

Definition at line 193 of file util.h.

◆ MP_SCOPED_CAPABILITY

#define MP_SCOPED_CAPABILITY   MP_TSA(scoped_lockable)

Definition at line 192 of file util.h.

◆ MP_TSA

#define MP_TSA (   x)

Definition at line 188 of file util.h.