Changes

Jump to: navigation, search

IPDL/Five minute example

1,817 bytes added, 00:25, 18 July 2009
Broadly understand IPDL's C++ environment
== Broadly understand IPDL's C++ environment ==
 
IPDL "describes" the communication of two threads, whether in the same process or not. For two threads to communicate using IPDL, at least two things are required
# two threads
# an OS-level communication mechanism (transport layer)
Ramping these up in C++ is a rather complicated process, and is likely to be uncommon. If you really do need this, see the guide [[IPDL/Low level setup]]. This "five minute example" will assume that you can glom onto an existing IPDL environment.
 
Not coincidentally, we provide a bare-bones IPDL environment in the directory <code>ipc/test-harness</code>. This guide will assume that you're using this environment. The test-harness environment is set up for "inter-process communication" --- the parent and child actors' threads live in different address spaces. It contains the following classes
* <code>TestProcessParent</code>: represents the "child" from inside the "parent" process. Akin to <code>nsIProcess</code>. TestProcessParent also holds the raw socket fd over which IPDL messages are sent.
* <code>TestThreadChild</code>: the "main thread" of the child process. Holds the other end of the raw socket over which IPDL messages are sent.
* <code>TestParent</code>: the "parent actor" --- concrete C++ implementation of the IPDL parent actor abstract class.
* <code>TestChild</code>: the "child actor" --- concrete C++ implementation of the IPDL child actor abstract class. Its code executes on the TestThreadChild thread in the subprocess.
All the necessary code to create the subprocess, set up the communication socket, etc. is already implemented for you. After all the setup code is run, whatever code you write will be invoked through the method <code>ParentActor::DoStuff</code>. You can think of this as the test-harness's <code>main()</code> function.
== Write the IPDL "Hello, world" protocol ==
Confirm
699
edits

Navigation menu