[erlang-questions] pid to integer and back

Torben Hoffmann torben.lehoff@REDACTED
Wed Oct 8 21:04:50 CEST 2008


On Wed, Oct 8, 2008 at 6:01 PM, Joel Reymont <joelr1@REDACTED> wrote:

> Is there a safe and efficient way to convert pid to integer and back?
>
> I'm assigning each running poker game an integer id. I store this id
> into every outgoing packet so there's no database lookup.
>
> I use the id to lookup the game process for every incoming packet,
> though. This is proving to be extremely inefficient, even with dirty
> mnesia reads.
>
> I actually repeat the above for every player, so there's twice the
> overhead. Is there a way to avoid it?
>
> This would only apply to running games and connected players so this
> would be a temporary integer, valid while the process is alive.
>
>        Thanks, Joel
>
> --
> wagerlabs.com
>
> Hi Joel.

I haven't - shame on me - looked at your code for the poker server, so this
may be a stupid question...

Could you try to step one step back and explain a bit about the scenario and
the requirements you have for the routing of messages. I presume that you
have local clients that all connect to your server and the trick is to pass
actions around to all players at a table, but how that matches up with
Erlang entities is beyond me at this stage.

Off the top of my head things like AMQP or IP multicast could be a neat way
of solving your problem, but it depends on how your architecture is and
exactly how your routing requirements are. I have practical experience with
IP multicast and I am sure that the RabbitMQ guys could help out with
guidance on using AMQP.... if those things match your needs.

It might very well be that the pid conversion is a problem you do not need
to solve!

Cheers,
Torben




> _____________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081008/4eca80bd/attachment.htm>


More information about the erlang-questions mailing list