[erlang-questions] multi-threaded woes
Tue Sep 19 10:14:01 CEST 2006
It's not in my nature to change direction until I understand why my current direction does not work. Last night it became painfully obvious what was wrong. Although ei is thread safe it's not itself threaded. In other words ei blocks on a number of operations such that it can't process any other requests regardless of what application thread they arrive on, therefore it can't be a client and server in the same node. This is a shame because everything else works great. I'm not even sure it could handle multiple connects, in fact I'm pretty sure it couldn't as that requires doing an accept for each connection in a separate thread and sitting on a read for each. I tried coming off the read by using the timeout calls so giving things a chance to get through but it worked very intermittantly making me think that any call made while it was blocked was ditched. Given these limitations I can't use ei for the connection management unless I adopt some kind of polling architecture. This pretty much rules out C nodes. I think I have to redesign around erlang nodes and where necessary C ports.
From: Vlad Dumitrescu [mailto:]
Sent: 19 September 2006 07:49
To: Bob Cowdery
Cc: Erlang-Questions (E-mail)
Subject: Re: [erlang-questions] multi-threaded woes
On 9/18/06, Bob Cowdery <> wrote:
>I am having some trouble getting two C nodes which are both clients
>to connect both ways and not sure of the rules here. They both start listen
>threads and sit on accept. Node 1 does a connect on node 2 which is successful
>and sends it a message which it receives. Node 2 does a connect on Node 1 as
>Node 1 is now guaranteed to be up, which is successful from the connect side
>except Node 1 never comes off the accept so it never sees it.
IMHO erl_interface provides great support for building a
single-threaded C node. If you want it to be multithreaded, then
you're on your own (i.e. just as much as with any C application).
I never tried to do a double connect like you do. It is sufficient to
connect from one side and then you can send messages both ways.
Another possible issue might be that C nodes are primarily meant to
talk to Erlang nodes, not between themselves. So I'm not sure how well
a network of C nodes will function together. Maybe someone who tried
it can tell.
Checking out gtkNode seems a very good idea, especially if it covers
much of what your own gui nodes need to do.
More information about the erlang-questions