Browse thread
[Caml-list] lib design questions
- Richard Nyberg
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ 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]
Select
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!
-Richard
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners