File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,28 @@ std::string LongThreadName(const char* exe_name);
129
129
130
130
// ! Event loop implementation.
131
131
// !
132
+ // ! Cap'n Proto threading model is very simple: all I/O operations are
133
+ // ! asynchronous and must be performed on a single thread. This includes:
134
+ // !
135
+ // ! - Code starting an asynchronous operation (calling a function that returns a
136
+ // ! promise object)
137
+ // ! - Code notifying that an asynchronous operation is complete (code using a
138
+ // ! fulfiller object)
139
+ // ! - Code handling a completed operation (code chaining or waiting for a promise)
140
+ // !
141
+ // ! All of this code needs to access shared state, and there is no mutex that
142
+ // ! can be acquired to lock this state because Cap'n Proto
143
+ // ! assumes it will only be accessed from one thread. So all this code needs to
144
+ // ! actually run on one thread, and the EventLoop::loop() method is the entry point for
145
+ // ! this thread. ProxyClient and ProxyServer objects that use other threads and
146
+ // ! need to perform I/O operations post to this thread using EventLoop::post()
147
+ // ! and EventLoop::sync() methods.
148
+ // !
149
+ // ! Specifically, because ProxyClient methods can be called from arbitrary
150
+ // ! threads, and ProxyServer methods can run on arbitrary threads, ProxyClient
151
+ // ! methods use the EventLoop thread to send requests, and ProxyServer methods
152
+ // ! use the thread to return results.
153
+ // !
132
154
// ! Based on https://groups.google.com/d/msg/capnproto/TuQFF1eH2-M/g81sHaTAAQAJ
133
155
class EventLoop
134
156
{
You can’t perform that action at this time.
0 commit comments