Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] lib design questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Richard Nyberg <rnyberg@i...>
Subject: [Caml-list] lib design questions
Hello ocaml demi gods :)

I'm trying to write a library for a network protocol (xmpp).
I thought I could do it with a network of threads and the Event
system that ocaml has. The design I have now is like this:
[Thread 3] is always running and is kind of a message distribution
hub. [Thread 1] and [Thread 2] is created for every connection and
are there to read data from the connection and giving full protocol
messages to [Thread 3].

[Thread 1]
reads data from network
send data on ch_1to2

[Thread 2]
receive data on ch_1to2 until we have parsed a protocol message
send message on ch_2to3

[Thread 3]
  receive protocol messages on ch_2to3
  receive servers request on req_ch
  send protocol messages on some channels

Question 1:
Sometimes it is necessary to replace [Thread 1] and [Thread 2]
with a new pair of thread for a connection (startssl and sasl).
How can I do that? Is it always safe do do Thread.kill on them?

Question 2:
Is this design totally idiotic? Do you have design patterns
for asynchronous message protocols?

Happy hacking!

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: