README.md
1 How to use this library
2 -----------------------
3 There are three options to use this library:
4
5 ## Option 1) Fully in-process
6 In this mode Producer, Consumers and the Service are hosted in the same process.
7 This is not too interesting other than tests and particular cases of nesting
8 tracing instances coming from different libraries within the same process
9 (concrete example v8, skia and webrtc in Chrome).
10 In this configuration, the client is expected to at least:
11 - Create a TracingService instance via TracingService::CreateInstance
12 (see `core/tracing_service.h`)
13 - Subclass Producer (`core/producer.h`) and connect it to the service.
14 - Provide a TaskRunner implementation (see `test/test_task_runner.h`)
15 - Provide a trivial SharedMemory implementation (`core/shared_memory.h`) which
16 is simply backed by a malloc() buffer.
17
18 ## Option 2) Using the provided UNIX RPC transport
19 The `include/unix_rpc` provides the building blocks necessary to implement a RPC
20 mechanism that allows Producer(s), Consumer(s) and Service to be hosted on
21 different processes on the same machine and talk over a UNIX domain socket.
22 - Producer(s) are expected to get a service proxy via
23 `UnixServiceConnection::ConnectAsProducer()`.
24 - The `Service` must be instantiated via `UnixServiceHost::CreateInstance()`. The
25 returned instance encapsulates the `Service` and exposes two UNIX sockets (one
26 for Producer(s), one for Consumer(s)) on the current process.
27
28 ## Option 3) Providing a custom RPC transport
29 Similar to Option 2, but the client creates its own transport mechanism,
30 defining how methods are proxies between instances and providing a SharedMemory
31 implementation that can be transferred through RPC. Concrete example of this is
32 Chrome implementing this library over a Mojo transport.
33
34
35 Directory layout
36 ----------------
37
38 `include/`
39 Is the public API that clients of this library are allowed to depend on.
40 Headers inside include/ cannot depend on anything else.
41
42 `src/`
43 Is the actual implementation that clients can link but not expected to access
44 at a source-code level.
45
46
47 **Both have the following sub-structure**:
48
49 `{include,src}/core/`
50 "Core" is the pure c++11 tracing machinery that deals with bookkeeping,
51 ring-buffering, partitioning and multiplexing but knows nothing about
52 platform-specific things like implementation of shared memory and RPC mechanism.
53
54 `{include,src}/unix_rpc/`
55 A concrete implementation of the transport layer based on unix domain sockets
56 and posix shared memory.
57