How to do table lookups? (fwd)
Edmund Dengler
edmundd@REDACTED
Wed Mar 3 22:18:09 CET 2004
Hi all!
On Wed, 3 Mar 2004, Vance Shipley wrote:
> } Actually, I was looking at the gen_server, and was having an issue with
> } regards to the receives not seeming to be able to have a guard. I have a
> } couple of programs where I do synchronization based on guard expressions
> } to implement bounded queues. While I could rewrite to not do this, it
> } would definitely not be as clean.
>
> I'm not sure I follow you. You can implement guards as:
>
> handle_cast({Foo, Bar}, State) when is_integer(Bar),
> Bar < 10 ->
Actually, I have no real issue with the low level handling of the receives
myself (most of the apps have been fairly straight forward). I find using
the guards to block reception of messages in the receive queue quite
useful as a model. As far as I understand, the above does not block
inbound messages that would fail the test (or does it?). Ie, I would still
receive the next message in the queue, and if it is not the one I want, I
still have to put it someplace for processing later.
>
> If you want to control the number of messages in your mailbox than
> you'll just need to become an expert and implement everything you
> need. If you're new to Erlang/OTP and you find you need to do this
> level of hackery again you should assume you are doing soomething
> wrong.
>
> } Back to this being somebody else's program, and so do not have an option
> } of ei.
>
> You could alwaysd write a wrapper in C using ei.
Then I would need to do all the binary parsing in C, and then convert to
appropriate Erlang components. Not sure if this would be the route I would
like.
>
> } Nope, OpenBSD/Linux. The program does not detect that the listening
> } program has closed the file descriptors, and so hangs on full pipes
> } without dying.
>
> Your wrapper could solve this.
I was originally hoping for some kind of port parameter of the "kill this
program if the current Erlang process dies" kind. I could try to rig up
some form of link with a kill process. I have to see if there is a way to
extract the process id from the data returned by open_port/2.
>
> -Vance
>
Regards!
Ed
More information about the erlang-questions
mailing list