[webkit-dev] WebSocket threading design

Fumitoshi Ukai (鵜飼文敏) ukai at chromium.org
Tue Dec 8 23:25:25 PST 2009

Right now, WebSocket uses WebSocketChannel and SocketStreamHandle directly,
but this might not work well if the WebSocket is running on another thread
(i.e. worker threads).
SocketStreamHandleCFNet is expected to run on loader process/main thread, so
attachment 44393 in bug 32214 won't work well on Mac.
Also, we'll want to share global data to maintain current opening channel to
limit the number of opening channel to each destination in WebSocketChannel

So, I propose to set thread boundary on the WebSocketChannel interface.
I introduce ThreadableWebSocketChannel, which is abstract interface for
WebSocketChannel, and ThreadableWebSocketChannelClientWrapper, which is
ThreadSafeShared class to wrap WebSocketChannelClient.

ThreadableWebSocketChannel::create() will create WebSocketChannel on the
main thread, or create WorkerThreadableWebSocketChannel on the worker

WorkerThreadableWebSocketChannel has a bridge between the worker thread and
the main thread.  It uses WorkerLoaderProxy to communicate between the

WebSocketChannel and SocketStreamHandle always runs on the main thread.


Is there anything else I should be careful about?
Any comments are welcome.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091209/a6cdac1d/attachment.html>

More information about the webkit-dev mailing list