> Actually, I don't quite like all the 2-threads
solutions for sake of
> efficiency. Suppose I have to response some incoming
query averagely once
per
> hour, the threads will have to switch all the time.
Yes, but is probably not a big deal, performance wise. This
is especially
true in Ocaml where there is context switching going on all
the time anyway,
the addition of another thread is small potatoes.
> The way I'd like is some
system-signal-upon-data-arrive functionality,
however
> it can only be provided by the OCaml VM if I'm not
making mistakes. I'm
quite
> curious about the following problems:
>- What is the typical way to handle that in other
languages. It's only the
> OCaml that doesn't provide such kind of signal or
it's the same for all
> languages?
This is often handled using a Reactor or Proactor pattern
(at least in OOP
languages). Ocaml does not
provide a basic implementation of these patterns, but the
Event module
includes 'channels' that you could implement such a
pattern with. You can
google for these patters, you can also check out the ACE
framework, they
have a good Reactor implementation in C++ and Java, and the
docs discuss
this kind of solution to the problem you are describing.
Other than that, the Event module is the way to go for
implementing Ocaml
native signaling and information transport. You can also
check out epoll and
the like, depending on your OS. I doubt anyone has created
ocaml bindings
for Microsoft Message Queue, but if you were on Windows that
would also be a
good solution, I would imagine.
> For programs like windows-based interactive
applications where real-time
is
> necessary all the time, are there always more than
one thread running
behind?
Yes, there are often many threads running behind to handle
actions in your
average windows application.
-jbs
[Non-text portions of this message have been removed]
Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http:/
/groups.yahoo.com/group/ocaml_beginners/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
ht
tp://groups.yahoo.com/group/ocaml_beginners/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:ocaml_beginners-digest@yahoogroups.com
mailto:ocaml_beginners-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
ocaml_beginners-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|