Files
bitcoin/doc/usage.md
Ryan Ofsky 0f01e1577f Squashed 'src/ipc/libmultiprocess/' changes from 47d79db8a552..a4f929696490
a4f929696490 Merge bitcoin-core/libmultiprocess#224: doc: fix typos
f4344ae87da0 Merge bitcoin-core/libmultiprocess#222: test, ci: Fix threadsanitizer errors in mptest
1434642b3804 doc: fix typos
73d22ba2e930 test: Fix tsan race in thread busy test
b74e1bba014d ci: Use tsan-instrumented cap'n proto in sanitizers job
c332774409ad test: Fix failing exception check in new thread busy test
ca3c05d56709 test: Use KJ_LOG instead of std::cout for logging
7eb1da120ab6 ci: Use tsan-instrumented libcxx in sanitizers job
ec86e4336e98 Merge bitcoin-core/libmultiprocess#220: Add log levels and advertise them to users via logging callback
515ce93ad349 Logging: Pass LogData struct to logging callback
213574ccc43d Logging: reclassify remaining log messages
e4de0412b430 Logging: Break out expensive log messages and classify them as Trace
408874a78fdc Logging: Use new logging macros
67b092d835cd Logging: Disable logging if messsage level is less than the requested level
d0a1ba7ebf21 Logging: add log levels to mirror Core's
463a8296d188 Logging: Disable moving or copying Logger
83a2e10c0b03 Logging: Add an EventLoop constructor to allow for user-specified log options
58cf47a7fc8c Merge bitcoin-core/libmultiprocess#221: test default PassField impl handles output parameters
db03a663f514 Merge bitcoin-core/libmultiprocess#214: Fix crash on simultaneous IPC calls using the same thread
afcc40b0f1e8 Merge bitcoin-core/libmultiprocess#213: util+doc: Clearer errors when attempting to run examples + polished docs
6db669628387 test In|Out parameter
29cf2ada75ea test default PassField impl handles output parameters
1238170f68e8 test: simultaneous IPC calls using same thread
eb069ab75d83 Fix crash on simultaneous IPC calls using the same thread
ec03a9639ab5 doc: Precision and typos
2b4348193551 doc: Where possible, remove links to ryanofsky/bitcoin/
286fe469c9c9 util: Add helpful error message when failing to execute file

git-subtree-dir: src/ipc/libmultiprocess
git-subtree-split: a4f92969649018ca70f949a09148bccfeaecd99a
2025-10-07 10:12:08 -04:00

3.1 KiB

libmultiprocess Usage

Overview

libmultiprocess is a library and code generator that allows calling C++ class interfaces across different processes. For an interface to be available from other processes, it needs two definitions:

The *.capnp data definition files are consumed by the libmultiprocess code generator and each X.capnp file generates X.capnp.c++, X.capnp.h, X.capnp.proxy-client.c++, X.capnp.proxy-server.c++, X.capnp.proxy-types.c++, X.capnp.proxy-types.h, and X.capnp.proxy.h output files. The generated files include mp::ProxyClient<Interface> and mp::ProxyServer<Interface> class specializations for all the interfaces in the .capnp files. These allow methods on C++ objects in one process to be called from other processes over IPC sockets.

The ProxyServer objects help translate IPC requests from a socket to method calls on a local object. The ProxyServer objects are just used internally by the mp::ServeStream(loop, socket, wrapped_object) and mp::ListenConnections(loop, socket, wrapped_object) functions, and aren't exposed externally. The ProxyClient classes are exposed, and returned from the mp::ConnectStream(loop, socket) function and meant to be used directly. The classes implement methods described in .capnp definitions, and whenever any method is called, a request with the method arguments is sent over the associated IPC connection, and the corresponding wrapped_object method on the other end of the connection is called, with the ProxyClient method blocking until it returns and forwarding back any return value to the ProxyClient method caller.

Example

A simple interface description can be found at test/mp/test/foo.capnp, implementation in test/mp/test/foo.h, and usage in test/mp/test/test.cpp.

A more complete example can be found in example and run with:

mkdir build
cd build
cmake ..
make mpexamples
example/mpexample