![]() |
Bitcoin Core 32.99.0
P2P Digital Currency
|
Functions to serialize / deserialize common bitcoin types. More...
Namespaces | |
| namespace | test |
Classes | |
| struct | _Require |
| SFINAE helper, see using Require below. More... | |
| struct | Accessor |
| Accessor type holding flags that determine how to access a message field. More... | |
| class | CancelMonitor |
| Helper class that detects when a promise is canceled. More... | |
| class | CancelProbe |
| Helper object to attach to a promise and update a CancelMonitor. More... | |
| struct | CapRequestTraits |
| struct | CapRequestTraits<::capnp::Request< _Params, _Results > > |
| struct | ClientException |
| struct | ClientInvokeContext |
| struct | ClientParam |
| class | Connection |
| Object holding network & rpc state associated with either an incoming server connection, or an outgoing client connection. More... | |
| class | EventLoop |
| Event loop implementation. More... | |
| class | EventLoopRef |
| Event loop smart pointer automatically managing m_num_refs. More... | |
| struct | FunctionTraits |
| Function traits class used to get method parameter and result types, used in generated ProxyClient and ProxyServer classes produced by gen.cpp to get C++ method type information. More... | |
| struct | FunctionTraits< _Result(_Class::*const)(_Params...)> |
| Specialization of above extracting result and params types assuming the template argument is a pointer-to-method type, decltype(&ClassName::methodName) More... | |
| struct | GuardedRef |
| struct | InterruptException |
| Exception thrown from code executing an IPC call that is interrupted. More... | |
| struct | InvokeContext |
| struct | IterateFields |
| struct | IterateFieldsHelper |
| struct | Listener |
| struct | ListOutput |
| struct | ListOutput<::capnp::List< T, kind > > |
| class | Lock |
| class | Logger |
| class | LoggingErrorHandler |
| Handler for kj::TaskSet failed task events. More... | |
| struct | LogMessage |
| struct | LogOptions |
| struct | Priority |
| Function parameter type for prioritizing overloaded function calls that would otherwise be ambiguous. More... | |
| struct | Priority< 0 > |
| Specialization of above (base case) More... | |
| class | ProxyCallback |
| Wrapper around std::function for passing std::function objects between client and servers. More... | |
| class | ProxyCallback< std::function< Result(Args...)> > |
| Specialization of above to separate Result and Arg types. More... | |
| class | ProxyCallbackImpl |
| Adapter to convert ProxyCallback object call to function object call. More... | |
| struct | ProxyCallFn |
| struct | ProxyClient |
| Mapping from capnp interface type to proxy client implementation (specializations are generated by proxy-codegen.cpp). More... | |
| struct | ProxyClient< Thread > |
| class | ProxyClientBase |
| Base class for generated ProxyClient classes that implement a C++ interface and forward calls to a capnp interface. More... | |
| class | ProxyClientCustom |
| Customizable (through template specialization) base class used in generated ProxyClient implementations from proxy-codegen.cpp. More... | |
| struct | ProxyClientMethodTraits |
| Customizable (through template specialization) traits class used in generated ProxyClient implementations from proxy-codegen.cpp. More... | |
| struct | ProxyContext |
| Context data associated with proxy client and server classes. More... | |
| struct | ProxyMethod |
| Mapping from capnp method params type to method traits (specializations are generated by proxy-codegen.cpp). More... | |
| struct | ProxyMethodTraits |
| Traits class for a proxy method, providing the same Params/Result/Param/Fields described in the FunctionTraits class above, plus an additional invoke() method that calls the C++ method which is being proxied, forwarding any arguments. More... | |
| struct | ProxyMethodTraits< MethodParams, Require< decltype(ProxyMethod< MethodParams >::impl)> > |
| Specialization of above for proxy methods that have a ProxyMethod<InterfaceName::MethodNameParams>::impl pointer-to-method constant defined by generated code. More... | |
| struct | ProxyServer |
| Mapping from capnp interface type to proxy server implementation (specializations are generated by proxy-codegen.cpp). More... | |
| struct | ProxyServer< Thread > |
| struct | ProxyServer< ThreadMap > |
| struct | ProxyServerBase |
| Base class for generated ProxyServer classes that implement capnp server methods and forward calls to a wrapped c++ implementation class. More... | |
| struct | ProxyServerCustom |
| Customizable (through template specialization) base class which ProxyServer classes produced by generated code will inherit from. More... | |
| struct | ProxyServerMethodTraits |
| Customizable (through template specialization) traits class used in generated ProxyServer implementations from proxy-codegen.cpp. More... | |
| struct | ProxyStruct |
| Mapping from capnp struct type to struct traits (specializations are generated by proxy-codegen.cpp). More... | |
| struct | ProxyType |
| Mapping from local c++ type to capnp type and traits (specializations are generated by proxy-codegen.cpp). More... | |
| struct | ProxyTypeRegister |
| Map to convert client interface pointers to ProxyContext struct references at runtime using typeids. More... | |
| struct | PtrOrValue |
| Convenient wrapper around std::variant<T*, T> More... | |
| struct | ReadDestEmplace |
| struct | ReadDestUpdate |
| Destination parameter type that can be passed to ReadField function as an alternative to ReadDestEmplace. More... | |
| struct | ServerCall |
| struct | ServerDestroy |
| struct | ServerExcept |
| struct | ServerField |
| struct | ServerInvokeContext |
| struct | ServerRet |
| struct | ServerVatId |
| Vat id for server side of connection. More... | |
| struct | Split |
| Type helper splitting a TypeList into two halves at position index. More... | |
| struct | Split< 0, _Second, _First, true > |
| Specialization of above (base case) More... | |
| struct | Split< index, TypeList< Type, _Second... >, TypeList< _First... >, false > |
| Specialization of above (recursive case) More... | |
| struct | StructField |
| struct | ThreadContext |
| The thread_local ThreadContext struct (see CurrentThread()) provides information about individual threads and a way of communicating between them. More... | |
| struct | TypeList |
| Type holding a list of types. More... | |
| struct | UnlockGuard |
| Analog to std::lock_guard that unlocks instead of locks. More... | |
| class | ValueField |
| struct | Waiter |
| Single element task queue used to handle recursive capnp calls. More... | |
Concepts | |
| concept | IsSpanOf |
| concept | IsByteSpan |
| concept | FieldTypeIs |
| Concept satisfied when T's .get() method returns exactly type U. | |
| concept | 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). | |
Typedefs | |
| template<typename Interface , typename Params , typename Results > | |
| using | ServerContext = ServerInvokeContext< ProxyServer< Interface >, ::capnp::CallContext< Params, Results > > |
| using | LogFn = std::function< void(LogMessage)> |
| using | ConnThreads = std::map< Connection *, std::optional< ProxyClient< Thread > > > |
| Map from Connection to local or remote thread handle which will be used over that connection. | |
| using | ConnThread = ConnThreads::iterator |
| using | CleanupList = std::list< std::function< void()> > |
| using | CleanupIt = typename CleanupList::iterator |
| template<typename Callable > | |
| using | ResultOf = decltype(std::declval< Callable >()()) |
| Type helper giving return type of a callable type. | |
| template<typename T > | |
| using | RemoveCvRef = std::remove_cv_t< std::remove_reference_t< T > > |
| Substitutue for std::remove_cvref_t. | |
| template<typename T > | |
| using | Decay = std::decay_t< T > |
| Type helper abbreviating std::decay. | |
| template<typename SfinaeExpr , typename Result = void> | |
| using | 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 | Stream = kj::Own< kj::AsyncIoStream > |
| using | ProcessId = int |
| using | SocketId = int |
| using | SpawnConnectInfo = std::string |
| Information about parent process passed to child process as a command-line argument. | |
| using | SpawnConnectInfoToArgsFn = std::function< std::vector< std::string >(const SpawnConnectInfo &)> |
| Callback type used by SpawnProcess below. | |
Enumerations | |
| enum class | Log { Trace = 0 , Debug , Info , Warning , Error , Raise } |
| Log flags. Update stringify function if changed! More... | |
Functions | |
| template<typename LocalType , typename Value , typename Output > requires Serializable<LocalType, DataStream> && std::is_same_v<LocalType, std::remove_cv_t<std::remove_reference_t<LocalType>>> | |
| void | CustomBuildField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| Overload multiprocess library's CustomBuildField hook to allow any serializable object to be stored in a capnproto Data field or passed to a capnproto interface. | |
| template<typename LocalType , typename Input , typename ReadDest > requires Unserializable<LocalType, DataStream> && (!ipc::capnp::Deserializable<LocalType>) | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| Overload multiprocess library's CustomReadField hook to allow any object with an Unserialize method to be read from a capnproto Data field or returned from capnproto interface. | |
| template<typename LocalType , typename Input , typename ReadDest > requires ipc::capnp::Deserializable<LocalType> | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| Overload multiprocess library's CustomReadField hook to allow any object with a deserialize constructor to be read from a capnproto Data field or returned from capnproto interface. | |
| template<typename Value , typename Output > | |
| void | CustomBuildField (TypeList< UniValue >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| Overload CustomBuildField and CustomReadField to serialize UniValue parameters and return values as JSON strings. | |
| template<typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< UniValue >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Input > | |
| bool | CustomHasField (TypeList< CTransaction >, InvokeContext &invoke_context, const Input &input) |
| Interpret empty Data fields as null CTransactionRef values. | |
| kj::StringPtr | KJ_STRINGIFY (Log flags) |
| std::string | LongThreadName (const char *exe_name) |
| Stream | MakeStream (EventLoop &loop, SocketId socket) |
| Wrap a socket file descriptor as an async stream, taking ownership of the fd. | |
| std::tuple< ConnThread, bool > | SetThread (GuardedRef< ConnThreads > threads, Connection *connection, const std::function< Thread::Client()> &make_thread) |
| template<typename InitInterface > | |
| std::unique_ptr< ProxyClient< InitInterface > > | ConnectStream (EventLoop &loop, Stream stream, bool destroy_connection=true) |
| Given a stream, make a new ProxyClient object to send requests over it. | |
| template<typename InitInterface , typename InitImpl , typename OnDisconnect > | |
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > | _Serve (EventLoop &loop, kj::Own< kj::AsyncIoStream > &&stream, std::shared_ptr< InitImpl > init, OnDisconnect &&on_disconnect, bool destroy_connection=true) |
| Given stream and init objects, construct a new ProxyServer object that handles requests from the stream by calling the init object. | |
| template<typename InitInterface , typename InitImpl , typename OnDisconnect > | |
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > | _Serve (EventLoop &loop, kj::Own< kj::AsyncIoStream > &&stream, InitImpl &init, OnDisconnect &&on_disconnect, bool destroy_connection=true) |
| Overload of _Serve that takes a reference to the init object instead of a shared_ptr. | |
| template<typename InitInterface , typename InitImpl > | |
| void | _Listen (const std::shared_ptr< Listener > &listener, EventLoop &loop, InitImpl &init) |
| template<typename InitInterface , typename InitImpl > | |
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > | ServeStream (EventLoop &loop, Stream stream, InitImpl &&init, bool destroy_connection=true) |
| Given a stream and an init object, handle requests on the stream by calling methods on the Init object. | |
| template<typename InitInterface , typename InitImpl > | |
| void | ListenConnections (EventLoop &loop, SocketId fd, InitImpl &init, std::optional< size_t > max_connections=std::nullopt) |
| Given listening socket identifier and an init object, handle incoming connections and requests by calling methods on the Init object. | |
| ThreadContext & | CurrentThread () |
| Return the current thread's ThreadContext. | |
| template<typename LocalType > | |
| auto | ReadDestTemp () |
| Helper function to create a ReadDestEmplace object that constructs a temporary, ReadField can return. | |
| template<typename... LocalTypes, typename Input > | |
| bool | CustomHasField (TypeList< LocalTypes... >, InvokeContext &, const Input &input) |
| Return whether to read a C++ value from a Cap'n Proto field. | |
| template<typename... LocalTypes, typename Input , typename... Args> | |
| decltype(auto) | ReadField (TypeList< LocalTypes... >, InvokeContext &invoke_context, Input &&input, Args &&... args) |
| template<typename LocalType , typename Input > | |
| void | ThrowField (TypeList< LocalType >, InvokeContext &invoke_context, Input &&input) |
| template<typename Input > | |
| void | ThrowField (TypeList< std::exception >, InvokeContext &, Input &&input) |
| Special case for generic std::exception. | |
| template<typename... Values> | |
| bool | CustomHasValue (InvokeContext &, const Values &...) |
| Return whether to write a C++ value into a Cap'n Proto field. | |
| template<typename... LocalTypes, typename Context , typename... Values, typename Output > | |
| void | BuildField (TypeList< LocalTypes... >, Context &context, Output &&output, Values &&... values) |
| template<typename LocalType , typename Value , typename Output > | |
| void | BuildList (TypeList< LocalType >, InvokeContext &invoke_context, Output &&output, Value &&value) |
| template<typename LocalType , typename Input , typename ReadDest , typename InitFn , typename EmplaceFn > | |
| decltype(auto) | ReadList (TypeList< LocalType >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest, InitFn &&init, EmplaceFn &&emplace) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< LocalType >, Priority< 0 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename Accessor , typename LocalType , typename ServerContext , typename Fn , typename... Args> | |
| auto | PassField (Priority< 1 >, TypeList< LocalType & >, ServerContext &server_context, Fn &&fn, Args &&... args) -> Require< typename decltype(Accessor::get(server_context.call_context.getParams()))::Calls > |
| PassField override for callable interface reference arguments. | |
| template<typename... Args> | |
| void | MaybeBuildField (std::true_type, Args &&... args) |
| template<typename... Args> | |
| void | MaybeBuildField (std::false_type, Args &&...) |
| template<typename... Args> | |
| void | MaybeReadField (std::true_type, Args &&... args) |
| template<typename... Args> | |
| void | MaybeReadField (std::false_type, Args &&...) |
| template<typename LocalType , typename Value , typename Output > | |
| void | MaybeSetWant (TypeList< LocalType * >, Priority< 1 >, const Value &value, Output &&output) |
| template<typename LocalTypes , typename... Args> | |
| void | MaybeSetWant (LocalTypes, Priority< 0 >, const Args &...) |
| template<typename Accessor , typename LocalType , typename ServerContext , typename Fn , typename... Args> | |
| void | PassField (Priority< 0 >, TypeList< LocalType >, ServerContext &server_context, Fn &&fn, Args &&... args) |
| Default PassField implementation calling MaybeReadField/MaybeBuildField. | |
| template<typename Accessor , typename ServerContext , typename Fn , typename... Args> | |
| void | PassField (Priority< 0 >, TypeList<>, ServerContext &server_context, const Fn &fn, Args &&... args) |
| Default PassField implementation for count(0) arguments, calling ReadField/BuildField. | |
| template<typename Accessor , typename... Types> | |
| ClientParam< Accessor, Types... > | MakeClientParam (Types &&... values) |
| template<typename Accessor , typename Message > requires requires { Accessor::get(message); } | |
| decltype(auto) | MaybeGet (Message &&message) |
| Helper for CustomPassField below. | |
| template<typename Accessor > | |
| ::capnp::Void | MaybeGet (...) |
| template<class Accessor > | |
| void | CustomPassField () |
| template<typename Accessor , typename... Args> | |
| auto | PassField (Priority< 2 >, Args &&... args) -> decltype(CustomPassField< Accessor >(std::forward< Args >(args)...)) |
| PassField override calling CustomPassField function, if it exists. | |
| template<int argc, typename Accessor , typename Parent > | |
| ServerField< argc, Accessor, Parent > | MakeServerField (Parent parent) |
| template<typename Client > | |
| void | clientDestroy (Client &client) |
| Entry point called by all generated ProxyClient destructors. | |
| template<typename Server > | |
| void | serverDestroy (Server &server) |
| template<typename ProxyClient , typename GetRequest , typename... FieldObjs> | |
| void | clientInvoke (ProxyClient &proxy_client, const GetRequest &get_request, FieldObjs &&... fields) |
| Entry point called by generated client code that looks like: | |
| template<typename Fn , typename Ret > | |
| auto | ReplaceVoid (Fn &&fn, Ret &&ret) |
Invoke callable fn() that may return void. | |
| template<typename Server , typename CallContext , typename Fn > | |
| kj::Promise< void > | serverInvoke (Server &server, CallContext &call_context, Fn fn) |
| Entry point called by generated server code that looks like: | |
| void | CleanupRun (CleanupList &fns) |
| template<typename Output , size_t size> | |
| void | CustomBuildField (TypeList< const unsigned char * >, Priority< 3 >, InvokeContext &invoke_context, const unsigned char(&value)[size], Output &&output) |
| template<size_t size, typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< unsigned char[size]>, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<class Rep , class Period , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::chrono::duration< Rep, Period > >, Priority< 1 >, InvokeContext &, Value &&value, Output &&output) |
| Overload CustomBuildField and CustomReadField to serialize std::chrono parameters and return values as numbers. | |
| template<class Rep , class Period , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::chrono::duration< Rep, Period > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<class Clock , class Duration , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::chrono::time_point< Clock, Duration > >, Priority< 1 >, InvokeContext &, Value &&value, Output &&output) |
| Overload CustomBuildField and CustomReadField to serialize std::chrono::time_point parameters and return values as integer tick counts. | |
| template<class Clock , class Duration , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::chrono::time_point< Clock, Duration > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Output > requires FieldTypeIs<Output, Context::Builder> | |
| void | CustomBuildField (TypeList<>, Priority< 1 >, ClientInvokeContext &invoke_context, Output &&output) |
| template<typename Accessor , typename ServerContext , typename Fn , typename... Args> | |
| auto | PassField (Priority< 1 >, TypeList<>, ServerContext &server_context, const Fn &fn, Args &&... args) -> typename std::enable_if< std::is_same< decltype(Accessor::get(server_context.call_context.getParams())), Context::Reader >::value, kj::Promise< typename ServerContext::CallContext > >::type |
| PassField override for mp.Context arguments. | |
| template<typename LocalType , typename Value , typename Output > requires (std::is_same_v<decltype(output.get()), ::capnp::Data::Builder> && IsByteSpan<LocalType>) | |
| void | CustomBuildField (TypeList< LocalType >, Priority< 2 >, InvokeContext &, Value &&value, Output &&output) |
| Generic ::capnp::Data field builder for any C++ type that can be converted to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom blob types like uint256 or PKHash with data() and size() methods pointing to bytes. | |
| template<typename LocalType , typename Input , typename ReadDest > requires (std::is_same_v<decltype(input.get()), ::capnp::Data::Reader> && IsByteSpan<LocalType>) | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 2 >, InvokeContext &, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< LocalType & >, Priority< 0 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< LocalType && >, Priority< 0 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename Output > | |
| void | CustomBuildField (TypeList< std::exception >, Priority< 1 >, InvokeContext &invoke_context, const std::exception &value, Output &&output) |
| template<typename Value , typename FnR , typename... FnParams, typename Output > | |
| void | CustomBuildField (TypeList< std::function< FnR(FnParams...)> >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename FnR , typename... FnParams, typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::function< FnR(FnParams...)> > types, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Interface , typename Impl > | |
| kj::Own< typename Interface::Server > | MakeProxyServer (InvokeContext &context, std::shared_ptr< Impl > impl) |
| template<typename Interface , typename Impl > | |
| kj::Own< typename Interface::Server > | CustomMakeProxyServer (InvokeContext &context, std::shared_ptr< Impl > &&impl) |
| template<typename Impl , typename Value , typename Output > requires InterfaceField<Output> | |
| void | CustomBuildField (TypeList< std::unique_ptr< Impl > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename Impl , typename Value , typename Output > requires InterfaceField<Output> | |
| void | CustomBuildField (TypeList< std::shared_ptr< Impl > >, Priority< 2 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename Impl , typename Output > requires InterfaceField<Output> | |
| void | CustomBuildField (TypeList< Impl & >, Priority< 1 >, InvokeContext &invoke_context, Impl &value, Output &&output) |
| template<typename Interface , typename Impl > | |
| std::unique_ptr< Impl > | MakeProxyClient (InvokeContext &context, typename Interface::Client &&client) |
| template<typename Interface , typename Impl > | |
| std::unique_ptr< Impl > | CustomMakeProxyClient (InvokeContext &context, typename Interface::Client &&client) |
| template<typename LocalType , typename Input , typename ReadDest > requires InterfaceField<Input> | |
| decltype(auto) | CustomReadField (TypeList< std::unique_ptr< LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Input , typename ReadDest > requires InterfaceField<Input> | |
| decltype(auto) | CustomReadField (TypeList< std::shared_ptr< LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename KeyLocalType , typename ValueLocalType , typename Compare , typename Allocator , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::map< KeyLocalType, ValueLocalType, Compare, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<class Map , class Tuple1 , class Tuple2 > | |
| auto | EmplacePiecewiseSafe (Map &m, const std::piecewise_construct_t &, Tuple1 &&t1, Tuple2 &&t2) |
| template<typename KeyLocalType , typename ValueLocalType , typename Compare , typename Allocator , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::map< KeyLocalType, ValueLocalType, Compare, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Value , typename Output > requires requires { CustomBuildMessage(invoke_context, value, std::move(output.get())); } | |
| void | CustomBuildField (TypeList< LocalType >, Priority< 2 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| Overload CustomBuildField to serialize objects that have CustomBuildMessage overloads. | |
| template<typename LocalType , typename Input , typename ReadDest > requires requires { CustomReadMessage(invoke_context, input.get(), std::declval<LocalType&>()); } | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 2 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| Overload CustomReadField to serialize objects that have CustomReadMessage overloads. | |
| template<typename Accessor , typename Message > requires requires { Accessor::get(message); } | |
| decltype(auto) | MaybeInit (Message &&message) |
| Helper for CustomPassField below. | |
| template<typename Accessor > | |
| ::capnp::Void | MaybeInit (...) |
| template<typename Accessor , typename... LocalTypes, typename ServerContext , typename Fn , typename... Args> | |
| auto | CustomPassField (TypeList< LocalTypes... >, ServerContext &server_context, Fn &&fn, Args &&... args) -> decltype(CustomPassMessage(server_context, MaybeGet< Accessor >(server_context.call_context.getParams()), MaybeGet< Accessor >(server_context.call_context.getResults()), nullptr)) |
| Overload CustomPassField to serialize objects that have CustomPassMessage overloads. | |
| template<typename LocalType , typename Value > requires std::is_enum_v<Value> | |
| LocalType | BuildPrimitive (InvokeContext &, const Value &value, TypeList< LocalType >) |
| template<typename LocalType , typename Value > requires (std::is_integral_v<Value> && !std::is_same_v<std::remove_cv_t<Value>, bool>) | |
| LocalType | BuildPrimitive (InvokeContext &, const Value &value, TypeList< LocalType >) |
| template<typename LocalType > | |
| LocalType | BuildPrimitive (InvokeContext &, bool value, TypeList< LocalType >) |
| template<typename LocalType , typename Value > requires std::is_floating_point_v<Value> | |
| LocalType | BuildPrimitive (InvokeContext &, const Value &value, TypeList< LocalType >) |
| template<typename LocalType , typename Input , typename ReadDest > requires std::is_enum_v<LocalType> | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Input , typename ReadDest > requires std::is_integral_v<LocalType> | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Input , typename ReadDest > requires std::is_floating_point_v<LocalType> | |
| decltype(auto) | CustomReadField (TypeList< LocalType >, Priority< 1 >, InvokeContext &, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::optional< LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::optional< LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename KeyLocalType , typename ValueLocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::pair< KeyLocalType, ValueLocalType > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename KeyLocalType , typename ValueLocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::pair< KeyLocalType, ValueLocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< LocalType * >, Priority< 3 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::shared_ptr< LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< LocalType * >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::shared_ptr< LocalType > >, Priority< 0 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::shared_ptr< const LocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Accessor , typename LocalType , typename ServerContext , typename Fn , typename... Args> | |
| void | PassField (Priority< 1 >, TypeList< LocalType * >, ServerContext &server_context, const Fn &fn, Args &&... args) |
| PassField override for C++ pointer arguments. | |
| template<typename LocalType , typename Compare , typename Allocator , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::set< LocalType, Compare, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Compare , typename Allocator , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::set< LocalType, Compare, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::string >, Priority< 1 >, InvokeContext &, Value &&value, Output &&output) |
| template<typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::string >, Priority< 1 >, InvokeContext &, Input &&input, ReadDest &&read_dest) |
| template<size_t index, typename LocalType , typename Value , typename Output > requires (index < ProxyType<LocalType>::fields) | |
| void | BuildOne (TypeList< LocalType > param, InvokeContext &invoke_context, Output &&output, Value &&value) |
| template<size_t index, typename LocalType , typename Value , typename Output > requires (index == ProxyType<LocalType>::fields) | |
| void | BuildOne (TypeList< LocalType >, InvokeContext &, Output &&, Value &&) |
| template<typename LocalType , typename Value , typename Output > requires requires { typename ProxyType<LocalType>::Struct; } | |
| void | CustomBuildField (TypeList< LocalType > local_type, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<size_t index, typename LocalType , typename Input , typename Value > requires (index != ProxyType<LocalType>::fields) | |
| void | ReadOne (TypeList< LocalType > param, InvokeContext &invoke_context, Input &&input, Value &&value) |
| template<size_t index, typename LocalType , typename Input , typename Value > requires (index == ProxyType<LocalType>::fields) | |
| void | ReadOne (TypeList< LocalType >, InvokeContext &, Input &, Value &) |
| template<typename LocalType , typename Input , typename ReadDest > requires requires { typename ProxyType<LocalType>::Struct; } | |
| decltype(auto) | CustomReadField (TypeList< LocalType > param, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Output > requires FieldTypeIs<Output, ThreadMap::Client> | |
| void | CustomBuildField (TypeList<>, Priority< 1 >, InvokeContext &invoke_context, Output &&output) |
| template<typename Input > requires FieldTypeIs<Input, ThreadMap::Client> | |
| decltype(auto) | CustomReadField (TypeList<>, Priority< 1 >, InvokeContext &invoke_context, Input &&input) |
| template<typename KeyLocalType , typename ValueLocalType , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::tuple< KeyLocalType, ValueLocalType > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename KeyLocalType , typename ValueLocalType , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::tuple< KeyLocalType, ValueLocalType > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Hash , typename KeyEqual , typename Allocator , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::unordered_set< LocalType, Hash, KeyEqual, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| template<typename LocalType , typename Hash , typename KeyEqual , typename Allocator , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::unordered_set< LocalType, Hash, KeyEqual, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename LocalType , typename Allocator , typename Value , typename Output > | |
| void | CustomBuildField (TypeList< std::vector< LocalType, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output) |
| static bool | BuildPrimitive (InvokeContext &, std::vector< bool >::const_reference value, TypeList< bool >) |
| template<typename LocalType , typename Allocator , typename Input , typename ReadDest > | |
| decltype(auto) | CustomReadField (TypeList< std::vector< LocalType, Allocator > >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest) |
| template<typename Value > | |
| ::capnp::Void | BuildPrimitive (InvokeContext &invoke_context, Value &&, TypeList<::capnp::Void >) |
| template<typename LocalType , typename Output > | |
| void | CustomBuildField (TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, ::capnp::Void, Output &&output) |
| template<typename A , typename B > | |
| constexpr bool | safe_less_equal (A a, B b) |
| Generic utility functions used by capnp code. | |
| template<typename A , typename B > | |
| constexpr bool | safe_greater_equal (A a, B b) |
| template<template< typename... > class Class, typename... Types, typename... Args> | |
| Class< Types..., std::remove_reference_t< Args >... > | 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 * | TypeName () |
| Return capnp type name with filename prefix removed. | |
| class | MP_CAPABILITY ("mutex") Mutex |
| template<class U > | |
| GuardedRef (Mutex &, U &) -> GuardedRef< U > | |
| template<typename Lock , typename Callback > | |
| void | Unlock (Lock &lock, Callback &&callback) |
| template<typename Fn , typename After > | |
| decltype(auto) | TryFinally (Fn &&fn, After &&after) |
| Invoke a function and run a follow-up action before returning the original result. | |
| void | SetOsThreadName (const char *name) |
| Set the OS-level name of the current thread. | |
| std::string | ThreadName (const char *exe_name) |
| Format current thread name as "{exe_name}-{$pid}/{thread_name}-{$tid}". | |
| std::string | 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 > | SpawnProcess (SpawnConnectInfoToArgsFn &&connect_info_to_args) |
| Spawn a new process that communicates with the current process over a socket pair. | |
| SocketId | 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 > | SocketPair () |
| Create a socket pair that can be used to communicate within a process or between parent and child processes. | |
| ProcessId | StartProcess (const std::vector< std::string > &args) |
| Start a process and return its process id. | |
| int | WaitProcess (ProcessId pid) |
| Wait for a process to exit and return its exit code. | |
| char * | CharCast (char *c) |
| char * | CharCast (unsigned char *c) |
| const char * | CharCast (const char *c) |
| const char * | CharCast (const unsigned char *c) |
| std::string | _demangle (const char *m) |
| template<class T > | |
| std::string | CxxTypeName (const T &) |
| template<typename Input > | |
| bool | CustomHasField (TypeList< test::FooData >, InvokeContext &, const Input &input) |
| void | CustomBuildMessage (InvokeContext &invoke_context, const test::FooMessage &src, test::messages::FooMessage::Builder &&builder) |
| void | CustomReadMessage (InvokeContext &, const test::messages::FooMessage::Reader &reader, test::FooMessage &dest) |
| void | CustomBuildMessage (InvokeContext &, const test::FooMutable &src, test::messages::FooMutable::Builder &&builder) |
| void | CustomReadMessage (InvokeContext &, const test::messages::FooMutable::Reader &reader, test::FooMutable &dest) |
| void | CustomPassMessage (InvokeContext &, const test::messages::FooMutable::Reader &reader, test::messages::FooMutable::Builder builder, std::function< void(test::FooMutable &)> &&fn) |
| std::tuple< ProcessId, SocketId > | SpawnProcess (const std::function< std::vector< std::string >(std::string)> &spawn_argv) |
Variables | |
| thread_local ThreadContext | g_thread_context |
| std::atomic< int > | server_reqs {0} |
| static constexpr int | FIELD_IN = 1 |
| See Accessor::in. | |
| static constexpr int | FIELD_OUT = 2 |
| See Accessor::out. | |
| static constexpr int | FIELD_OPTIONAL = 4 |
| See Accessor::optional. | |
| static constexpr int | FIELD_REQUESTED = 8 |
| See Accessor::requested. | |
| static constexpr int | FIELD_BOXED = 16 |
| See Accessor::boxed. | |
| constexpr SocketId | SocketError {-1} |
Functions to serialize / deserialize common bitcoin types.
| using mp::CleanupList = typedef std::list<std::function<void()> > |
| using mp::ConnThread = typedef ConnThreads::iterator |
Definition at line 716 of file proxy-io.h.
| using mp::ConnThreads = typedef std::map<Connection*, std::optional<ProxyClient<Thread> >> |
Map from Connection to local or remote thread handle which will be used over that connection.
This map will typically only contain one entry, but can contain multiple if a single thread makes IPC calls over multiple connections. A std::optional value type is used to avoid the map needing to be locked while ProxyClient<Thread> objects are constructed, see ThreadContext "Synchronization note" below.
Definition at line 715 of file proxy-io.h.
| using mp::LogFn = typedef std::function<void(LogMessage)> |
Definition at line 153 of file proxy-io.h.
| using mp::Require = typedef typename _Require<SfinaeExpr, Result>::Result |
| using mp::ServerContext = typedef ServerInvokeContext<ProxyServer<Interface>, ::capnp::CallContext<Params, Results> > |
Definition at line 78 of file proxy-io.h.
| using mp::SpawnConnectInfo = typedef std::string |
| using mp::SpawnConnectInfoToArgsFn = typedef std::function<std::vector<std::string>(const SpawnConnectInfo&)> |
Log flags. Update stringify function if changed!
| Enumerator | |
|---|---|
| Trace | |
| Debug | |
| Info | |
| Warning | |
| Error | |
| Raise | |
Definition at line 133 of file proxy-io.h.
|
inline |
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > mp::_Serve | ( | EventLoop & | loop, |
| kj::Own< kj::AsyncIoStream > && | stream, | ||
| InitImpl & | init, | ||
| OnDisconnect && | on_disconnect, | ||
| bool | destroy_connection = true |
||
| ) |
Overload of _Serve that takes a reference to the init object instead of a shared_ptr.
ProxyServer objects use shared_ptr's internally to optionally take ownership of interfaces being served, and free them when clients are no longer using them. Some libmultiprocess callers take advantage of this and pass shared_ptr's directly. But other callers that do not give away ownership are not required to use shared_ptr, so this overload converts references they pass into shared_ptr's with empty deleters. This prevents the ProxyServer object from deleting the init object when the client is disconnected.
Definition at line 928 of file proxy-io.h.
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > mp::_Serve | ( | EventLoop & | loop, |
| kj::Own< kj::AsyncIoStream > && | stream, | ||
| std::shared_ptr< InitImpl > | init, | ||
| OnDisconnect && | on_disconnect, | ||
| bool | destroy_connection = true |
||
| ) |
Given stream and init objects, construct a new ProxyServer object that handles requests from the stream by calling the init object.
Embed the ProxyServer in a Connection object that is stored in loop.m_incoming_connections. This should be called from the event loop thread. Returns the new ProxyServer along with an iterator to its Connection.
If destroy_connection is false, the connection is not erased automatically when the peer disconnects, and the caller is responsible for erasing loop.m_incoming_connections at the returned iterator whenever it is done with the connection.
Definition at line 894 of file proxy-io.h.
| void mp::BuildField | ( | TypeList< LocalTypes... > | , |
| Context & | context, | ||
| Output && | output, | ||
| Values &&... | values | ||
| ) |
Definition at line 256 of file proxy-types.h.
| void mp::BuildList | ( | TypeList< LocalType > | , |
| InvokeContext & | invoke_context, | ||
| Output && | output, | ||
| Value && | value | ||
| ) |
Definition at line 290 of file proxy-types.h.
| void mp::BuildOne | ( | TypeList< LocalType > | , |
| InvokeContext & | , | ||
| Output && | , | ||
| Value && | |||
| ) |
Definition at line 29 of file type-struct.h.
| LocalType mp::BuildPrimitive | ( | InvokeContext & | , |
| bool | value, | ||
| TypeList< LocalType > | |||
| ) |
Definition at line 38 of file type-number.h.
| LocalType mp::BuildPrimitive | ( | InvokeContext & | , |
| const Value & | value, | ||
| TypeList< LocalType > | |||
| ) |
Definition at line 14 of file type-number.h.
| LocalType mp::BuildPrimitive | ( | InvokeContext & | , |
| const Value & | value, | ||
| TypeList< LocalType > | |||
| ) |
Definition at line 26 of file type-number.h.
| LocalType mp::BuildPrimitive | ( | InvokeContext & | , |
| const Value & | value, | ||
| TypeList< LocalType > | |||
| ) |
Definition at line 47 of file type-number.h.
|
inlinestatic |
Definition at line 22 of file type-vector.h.
| ::capnp::Void mp::BuildPrimitive | ( | InvokeContext & | invoke_context, |
| Value && | , | ||
| TypeList<::capnp::Void > | |||
| ) |
Definition at line 12 of file type-void.h.
|
inline |
Entry point called by all generated ProxyClient destructors.
This only logs the object destruction. The actual cleanup happens in the ProxyClient base destructor.
Definition at line 697 of file proxy-types.h.
| void mp::clientInvoke | ( | ProxyClient & | proxy_client, |
| const GetRequest & | get_request, | ||
| FieldObjs &&... | fields | ||
| ) |
Entry point called by generated client code that looks like:
ProxyClient<ClassName>::M0::Result ProxyClient<ClassName>::methodName(M0::Param<0> arg0, M0::Param<1> arg1) { typename M0::Result result; clientInvoke(*this, &InterfaceName::Client::methodNameRequest, MakeClientParam<...>(M0::Fwd<0>(arg0)), MakeClientParam<...>(M0::Fwd<1>(arg1)), MakeClientParam<...>(result)); return result; }
Ellipses above are where generated Accessor<> type declarations are inserted.
Definition at line 718 of file proxy-types.h.
| std::unique_ptr< ProxyClient< InitInterface > > mp::ConnectStream | ( | EventLoop & | loop, |
| Stream | stream, | ||
| bool | destroy_connection = true |
||
| ) |
Given a stream, make a new ProxyClient object to send requests over it.
Also create a new Connection object embedded in the client that is freed when the client is closed.
If the init interface declares a construct() method, creating the client calls it, so this function may block making an IPC call and may throw if the call fails.
If destroy_connection is false, the returned client does not take ownership of the connection, and the caller is responsible for disconnecting and freeing it (accessible as client->m_context.connection) whenever it is done with it.
Definition at line 871 of file proxy-io.h.
|
inline |
Return the current thread's ThreadContext.
Why per-thread state is needed at all: libmultiprocess has no control over which threads the C++ application uses to call ProxyClient methods after the proxy objects are returned to it. The thread-mapping model (see "Thread Mapping" in doc/design.md) gives each application thread making IPC calls a dedicated server-side thread that executes its requests, so thread-local state and recursive mutexes work as expected across the process boundary and callbacks from the server run on the originating client thread. The client-side handles for those dedicated server threads (the ProxyClient<Thread> objects returned by ThreadMap.makeThread, stored per connection in the request_threads / callback_threads maps below) are state that must be keyed implicitly by the calling thread, and must be released when the client thread exits so the corresponding server threads are freed. A thread_local object is the C++ mechanism that provides both of these: per-thread storage plus a destructor that runs at thread exit (the C equivalent would be a pthread key destructor). This is why ThreadContext is thread_local and why its destructor is nontrivial.
Definition at line 45 of file proxy.cpp.
| void mp::CustomBuildField | ( | TypeList< const unsigned char * > | , |
| Priority< 3 > | , | ||
| InvokeContext & | invoke_context, | ||
| const unsigned char(&) | value[size], | ||
| Output && | output | ||
| ) |
Definition at line 16 of file type-char.h.
| void mp::CustomBuildField | ( | TypeList< Impl & > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Impl & | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< LocalType > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| ::capnp::Void | , | ||
| Output && | output | ||
| ) |
Definition at line 18 of file type-void.h.
| void mp::CustomBuildField | ( | TypeList< LocalType > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Overload multiprocess library's CustomBuildField hook to allow any serializable object to be stored in a capnproto Data field or passed to a capnproto interface.
Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.
Definition at line 64 of file common-types.h.
| void mp::CustomBuildField | ( | TypeList< LocalType > | , |
| Priority< 2 > | , | ||
| InvokeContext & | , | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Generic ::capnp::Data field builder for any C++ type that can be converted to a span of bytes, like std::vector<char> or std::array<uint8_t>, or custom blob types like uint256 or PKHash with data() and size() methods pointing to bytes.
Definition at line 32 of file type-data.h.
| void mp::CustomBuildField | ( | TypeList< LocalType > | , |
| Priority< 2 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Overload CustomBuildField to serialize objects that have CustomBuildMessage overloads.
Defining a CustomBuildMessage overload is simpler than defining a CustomBuildField overload because it only requires defining a normal function, not a template function, but less flexible.
Definition at line 16 of file type-message.h.
| void mp::CustomBuildField | ( | TypeList< std::chrono::duration< Rep, Period > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | , | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Overload CustomBuildField and CustomReadField to serialize std::chrono parameters and return values as numbers.
Definition at line 16 of file type-chrono.h.
| void mp::CustomBuildField | ( | TypeList< std::chrono::time_point< Clock, Duration > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | , | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Overload CustomBuildField and CustomReadField to serialize std::chrono::time_point parameters and return values as integer tick counts.
The capnp field type must be an integer type with enough range to hold the time_since_epoch() count for the given Duration (e.g. Int64 for nanoseconds).
Definition at line 38 of file type-chrono.h.
| void mp::CustomBuildField | ( | TypeList< std::exception > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| const std::exception & | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::map< KeyLocalType, ValueLocalType, Compare, Allocator > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::pair< KeyLocalType, ValueLocalType > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::shared_ptr< Impl > > | , |
| Priority< 2 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::string > | , |
| Priority< 1 > | , | ||
| InvokeContext & | , | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Definition at line 14 of file type-string.h.
| void mp::CustomBuildField | ( | TypeList< std::tuple< KeyLocalType, ValueLocalType > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::unique_ptr< Impl > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< std::unordered_set< LocalType, Hash, KeyEqual, Allocator > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList< UniValue > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Value && | value, | ||
| Output && | output | ||
| ) |
Overload CustomBuildField and CustomReadField to serialize UniValue parameters and return values as JSON strings.
Definition at line 114 of file common-types.h.
| void mp::CustomBuildField | ( | TypeList<> | , |
| Priority< 1 > | , | ||
| ClientInvokeContext & | invoke_context, | ||
| Output && | output | ||
| ) |
| void mp::CustomBuildField | ( | TypeList<> | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Output && | output | ||
| ) |
|
inline |
|
inline |
Definition at line 75 of file foo-types.h.
| bool mp::CustomHasField | ( | TypeList< CTransaction > | , |
| InvokeContext & | invoke_context, | ||
| const Input & | input | ||
| ) |
Interpret empty Data fields as null CTransactionRef values.
This is safe to do because no CTransaction is ever serialized as empty Data, and it is convenient because this allows std::vector<CTransactionRef> to be passed as List(Data) even if the vector contains null values, and even though Cap'n Proto does not (currently) allow distinguishing between null and empty Data values in a List. Interpreting empty Data values as null CTransactionRef values works well for this purpose.
Definition at line 141 of file common-types.h.
| bool mp::CustomHasField | ( | TypeList< LocalTypes... > | , |
| InvokeContext & | , | ||
| const Input & | input | ||
| ) |
Return whether to read a C++ value from a Cap'n Proto field.
Returning false can be useful to interpret certain Cap'n Proto field values as null C++ values when initializing nullable C++ std::optional / std::unique_ptr / std::shared_ptr types.
For example, when reading from a List(Data) field into a std::vector<std::shared_ptr<const CTransaction>> value, it's useful to be able to interpret empty Data values as null pointers. This is useful because the Cap'n Proto C++ API does not currently provide a way to distinguish between null and empty Data values in a List[*], so we need to choose some Data value to represent null if we want to allow passing null pointers. Since no CTransaction is ever serialized as empty Data, it's safe to use empty Data values to represent null pointers.
[*] The Cap'n Proto wire format actually does distinguish between null and empty Data values inside Lists, and the C++ API does allow distinguishing between null and empty Data values in other contexts, just not the List context, so this limitation could be removed in the future.
Design note: CustomHasField() and CustomHasValue() are inverses of each other. CustomHasField() allows leaving Cap'n Proto fields unset when C++ types have certain values, and CustomHasValue() allows leaving C++ values unset when Cap'n Proto fields have certain values. But internally the functions get called in different ways. This is because in C++, unlike in Cap'n Proto not every C++ type is default constructible, and it may be impossible to leave certain C++ values unset. For example if a C++ method requires function parameters, there's no way to call the function without constructing values for each of the parameters. Similarly there's no way to add values to C++ vectors or maps without initializing those values. This is not the case in Cap'n Proto where all values are optional and it's possible to skip initializing parameters and list elements.
Because of this difference, CustomHasValue() works universally and can be used to disable BuildField() calls in every context, while CustomHasField() can only be used to disable ReadField() calls in certain contexts like std::optional and pointer contexts.
Definition at line 213 of file proxy-types.h.
| bool mp::CustomHasField | ( | TypeList< test::FooData > | , |
| InvokeContext & | , | ||
| const Input & | input | ||
| ) |
Definition at line 68 of file foo-types.h.
| bool mp::CustomHasValue | ( | InvokeContext & | , |
| const Values & | ... | ||
| ) |
Return whether to write a C++ value into a Cap'n Proto field.
Returning false can be useful to map certain C++ values to unset Cap'n Proto fields.
For example the bitcoin Coin class asserts false when a spent coin is serialized. But some C++ methods return these coins, so there needs to be a way to represent them in Cap'n Proto and a null Data field is a convenient representation.
Definition at line 250 of file proxy-types.h.
| std::unique_ptr< Impl > mp::CustomMakeProxyClient | ( | InvokeContext & | context, |
| typename Interface::Client && | client | ||
| ) |
| kj::Own< typename Interface::Server > mp::CustomMakeProxyServer | ( | InvokeContext & | context, |
| std::shared_ptr< Impl > && | impl | ||
| ) |
| auto mp::CustomPassField | ( | TypeList< LocalTypes... > | , |
| ServerContext & | server_context, | ||
| Fn && | fn, | ||
| Args &&... | args | ||
| ) | -> decltype(CustomPassMessage(server_context, MaybeGet<Accessor>(server_context.call_context.getParams()), MaybeGet<Accessor>(server_context.call_context.getResults()), nullptr)) |
Overload CustomPassField to serialize objects that have CustomPassMessage overloads.
Defining a CustomPassMessage overload is simpler than defining a CustomPassField overload because it only requires defining a normal function, not a template function, but less flexible.
Definition at line 54 of file type-message.h.
|
inline |
Definition at line 105 of file foo-types.h.
| decltype(auto) mp::CustomReadField | ( | TypeList< LocalType > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
Overload multiprocess library's CustomReadField hook to allow any object with an Unserialize method to be read from a capnproto Data field or returned from capnproto interface.
Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.
Definition at line 84 of file common-types.h.
| decltype(auto) mp::CustomReadField | ( | TypeList< LocalType > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
Overload multiprocess library's CustomReadField hook to allow any object with a deserialize constructor to be read from a capnproto Data field or returned from capnproto interface.
Use Priority<1> so this hook has medium priority, and higher priority hooks could take precedence over this one.
Definition at line 101 of file common-types.h.
| decltype(auto) mp::CustomReadField | ( | TypeList< LocalType > | , |
| Priority< 2 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
Overload CustomReadField to serialize objects that have CustomReadMessage overloads.
Defining a CustomReadMessage overload is simpler than defining a CustomReadField overload because it only requires defining a normal function, not a template function, but less flexible.
Definition at line 27 of file type-message.h.
| decltype(auto) mp::CustomReadField | ( | TypeList< std::map< KeyLocalType, ValueLocalType, Compare, Allocator > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
| decltype(auto) mp::CustomReadField | ( | TypeList< std::pair< KeyLocalType, ValueLocalType > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
| decltype(auto) mp::CustomReadField | ( | TypeList< std::tuple< KeyLocalType, ValueLocalType > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
| decltype(auto) mp::CustomReadField | ( | TypeList< std::unordered_set< LocalType, Hash, KeyEqual, Allocator > > | , |
| Priority< 1 > | , | ||
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest | ||
| ) |
|
inline |
|
inline |
Definition at line 98 of file foo-types.h.
| auto mp::EmplacePiecewiseSafe | ( | Map & | m, |
| const std::piecewise_construct_t & | , | ||
| Tuple1 && | t1, | ||
| Tuple2 && | t2 | ||
| ) |
Definition at line 36 of file type-map.h.
| mp::GuardedRef | ( | Mutex & | , |
| U & | |||
| ) | -> GuardedRef< U > |
| void mp::ListenConnections | ( | EventLoop & | loop, |
| SocketId | fd, | ||
| InitImpl & | init, | ||
| std::optional< size_t > | max_connections = std::nullopt |
||
| ) |
Given listening socket identifier and an init object, handle incoming connections and requests by calling methods on the Init object.
Definition at line 985 of file proxy-io.h.
| std::string mp::LogEscape | ( | const kj::StringTree & | string, |
| size_t | max_size | ||
| ) |
| std::string mp::LongThreadName | ( | const char * | exe_name | ) |
| 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.
Uses of this can go away with class template deduction in C++17 (https://en.cppreference.com/w/cpp/language/class_template_argument_deduction)
Example: Make<std::pair>(5, true) // Constructs std::pair<int, bool>(5, true);
Definition at line 70 of file util.h.
| ClientParam< Accessor, Types... > mp::MakeClientParam | ( | Types &&... | values | ) |
Definition at line 538 of file proxy-types.h.
| std::unique_ptr< Impl > mp::MakeProxyClient | ( | InvokeContext & | context, |
| typename Interface::Client && | client | ||
| ) |
Definition at line 67 of file type-interface.h.
| kj::Own< typename Interface::Server > mp::MakeProxyServer | ( | InvokeContext & | context, |
| std::shared_ptr< Impl > | impl | ||
| ) |
Definition at line 12 of file type-interface.h.
| ServerField< argc, Accessor, Parent > mp::MakeServerField | ( | Parent | parent | ) |
Definition at line 678 of file proxy-types.h.
| void mp::MaybeBuildField | ( | std::false_type | , |
| Args && | ... | ||
| ) |
Definition at line 364 of file proxy-types.h.
| void mp::MaybeBuildField | ( | std::true_type | , |
| Args &&... | args | ||
| ) |
Definition at line 359 of file proxy-types.h.
Definition at line 634 of file proxy-types.h.
Helper for CustomPassField below.
Call Accessor::get method if it has one, otherwise return capnp::Void.
Definition at line 627 of file proxy-types.h.
Definition at line 44 of file type-message.h.
Helper for CustomPassField below.
Call Accessor::init method if it has one, otherwise do nothing.
Definition at line 37 of file type-message.h.
| void mp::MaybeReadField | ( | std::false_type | , |
| Args && | ... | ||
| ) |
Definition at line 373 of file proxy-types.h.
| void mp::MaybeReadField | ( | std::true_type | , |
| Args &&... | args | ||
| ) |
Definition at line 368 of file proxy-types.h.
| void mp::MaybeSetWant | ( | LocalTypes | , |
| Priority< 0 > | , | ||
| const Args & | ... | ||
| ) |
Definition at line 386 of file proxy-types.h.
| class mp::MP_CAPABILITY | ( | "mutex" | ) |
| void mp::PassField | ( | Priority< 0 > | , |
| TypeList< LocalType > | , | ||
| ServerContext & | server_context, | ||
| Fn && | fn, | ||
| Args &&... | args | ||
| ) |
Default PassField implementation calling MaybeReadField/MaybeBuildField.
Definition at line 392 of file proxy-types.h.
| void mp::PassField | ( | Priority< 0 > | , |
| TypeList<> | , | ||
| ServerContext & | server_context, | ||
| const Fn & | fn, | ||
| Args &&... | args | ||
| ) |
Default PassField implementation for count(0) arguments, calling ReadField/BuildField.
Definition at line 416 of file proxy-types.h.
| auto mp::PassField | ( | Priority< 1 > | , |
| TypeList< LocalType & > | , | ||
| ServerContext & | server_context, | ||
| Fn && | fn, | ||
| Args &&... | args | ||
| ) | -> Require<typename decltype(Accessor::get(server_context.call_context.getParams()))::Calls> |
PassField override for callable interface reference arguments.
Definition at line 342 of file proxy-types.h.
| void mp::PassField | ( | Priority< 1 > | , |
| TypeList< LocalType * > | , | ||
| ServerContext & | server_context, | ||
| const Fn & | fn, | ||
| Args &&... | args | ||
| ) |
PassField override for C++ pointer arguments.
Definition at line 89 of file type-pointer.h.
| auto mp::PassField | ( | Priority< 1 > | , |
| TypeList<> | , | ||
| ServerContext & | server_context, | ||
| const Fn & | fn, | ||
| Args &&... | args | ||
| ) | -> typename std::enable_if< std::is_same<decltype(Accessor::get(server_context.call_context.getParams())), Context::Reader>::value, kj::Promise<typename ServerContext::CallContext>>::type |
PassField override for mp.Context arguments.
Return asynchronously and call function on other thread found in context.
Definition at line 59 of file type-context.h.
| auto mp::PassField | ( | Priority< 2 > | , |
| Args &&... | args | ||
| ) | -> decltype(CustomPassField<Accessor>(std::forward<Args>(args)...)) |
PassField override calling CustomPassField function, if it exists.
Defining a CustomPassField or CustomPassMessage overload is useful for input/output parameters. If an overload is not defined these parameters will just be deserialized on the server side with ReadField into a temporary variable, then the server method will be called passing the temporary variable as a parameter, then the temporary variable will be serialized and sent back to the client with BuildField. But if a PassField or PassMessage overload is defined, the overload is called with a callback to invoke and pass parameters to the server side function, and run arbitrary code before and after invoking the function.
Definition at line 653 of file proxy-types.h.
Helper function to create a ReadDestEmplace object that constructs a temporary, ReadField can return.
Definition at line 139 of file proxy-types.h.
| decltype(auto) mp::ReadField | ( | TypeList< LocalTypes... > | , |
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| Args &&... | args | ||
| ) |
Definition at line 219 of file proxy-types.h.
| decltype(auto) mp::ReadList | ( | TypeList< LocalType > | , |
| InvokeContext & | invoke_context, | ||
| Input && | input, | ||
| ReadDest && | read_dest, | ||
| InitFn && | init, | ||
| EmplaceFn && | emplace | ||
| ) |
Definition at line 320 of file proxy-types.h.
| void mp::ReadOne | ( | TypeList< LocalType > | , |
| InvokeContext & | , | ||
| Input & | , | ||
| Value & | |||
| ) |
Definition at line 66 of file type-struct.h.
Invoke callable fn() that may return void.
If it does return void, replace return value with value of ret(). This is useful for avoiding code duplication and branching in generic code that forwards calls to functions.
Definition at line 805 of file proxy-types.h.
| kj::Promise< void > mp::serverInvoke | ( | Server & | server, |
| CallContext & | call_context, | ||
| Fn | fn | ||
| ) |
Entry point called by generated server code that looks like:
kj::Promise<void> ProxyServer<InterfaceName>::methodName(CallContext call_context) { return serverInvoke(*this, call_context, MakeServerField<0, ...>(MakeServerField<1, ...>(Make<ServerRet, ...>(ServerCall())))); }
Ellipses above are where generated Accessor<> type declarations are inserted.
Definition at line 825 of file proxy-types.h.
| std::pair< ProxyServer< InitInterface > *, EventLoop::Connections::iterator > mp::ServeStream | ( | EventLoop & | loop, |
| Stream | stream, | ||
| InitImpl && | init, | ||
| bool | destroy_connection = true |
||
| ) |
Given a stream and an init object, handle requests on the stream by calling methods on the Init object.
See _Serve for details on the return value and the destroy_connection parameter.
Definition at line 976 of file proxy-io.h.
| std::tuple< ConnThread, bool > mp::SetThread | ( | GuardedRef< ConnThreads > | threads, |
| Connection * | connection, | ||
| const std::function< Thread::Client()> & | make_thread | ||
| ) |
|
inline |
| 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.
Calls connect_info_to_args callback with a connection string that needs to be passed to the child process, and executes the argv command line it returns. Returns child process id and socket id.
Definition at line 252 of file util.cpp.
| ProcessId mp::StartProcess | ( | const std::vector< std::string > & | args | ) |
|
inline |
| std::string mp::ThreadName | ( | const char * | exe_name | ) |
| void mp::ThrowField | ( | TypeList< LocalType > | , |
| InvokeContext & | invoke_context, | ||
| Input && | input | ||
| ) |
Definition at line 225 of file proxy-types.h.
| void mp::ThrowField | ( | TypeList< std::exception > | , |
| InvokeContext & | , | ||
| Input && | input | ||
| ) |
Special case for generic std::exception.
It's an abstract type so it can't be created directly. Rethrow as std::runtime_error so callers expecting it will still catch it.
Definition at line 236 of file proxy-types.h.
Invoke a function and run a follow-up action before returning the original result.
This can be used similarly to KJ_DEFER to run cleanup code, but works better if the cleanup function can throw because it avoids clang bug https://github.com/llvm/llvm-project/issues/12658 which skips calling destructors in that case and can lead to memory leaks. Also, if both functions throw, this lets one exception take precedence instead of terminating due to having two active exceptions.
Definition at line 260 of file util.h.
See Accessor::boxed.
See Accessor::in.
See Accessor::optional.
See Accessor::out.
See Accessor::requested.
| thread_local ThreadContext mp::g_thread_context |