[erlang-questions] Passing a digraph between processes on the same node
Steve Davis
steven.charles.davis@REDACTED
Wed Jun 10 03:10:58 CEST 2015
Ouch. OK, I totally see it.
tysm Mr. V!
> On Jun 9, 2015, at 7:55 PM, Steve Vinoski <vinoski@REDACTED> wrote:
>
>
> On Tue, Jun 9, 2015 at 7:55 PM, Steve Davis <steven.charles.davis@REDACTED <mailto:steven.charles.davis@REDACTED>> wrote:
> Hi,
>
> Somehow I’m not seeing why the following fails:
>
> -module(gtest).
>
> -export([test/0]).
>
> test() ->
> Test = self(),
> spawn(fun() -> graph(Test) end),
> receive
> {ok, G} ->
> digraph:vertices(G)
> after 5000 ->
> timeout
> end.
>
> graph(Pid) ->
> G = digraph:new(),
> digraph:add_vertex(G),
> Pid ! {ok, G}.
>
> …since the backing ets table is “protected" by default, shouldn’t the calling process be able to read the values set by the process that builds the digraph?
>
> The process running graph/1 is the owner of the ets tables. It dies as soon as the graph/1 function completes and it takes the ets tables down with it.
>
> Add two calls to ets:i/0, one right after receiving {ok,G} and the other right after the digraph:new/0 call, then run gtest:test/0 from the shell and you'll see that the digraph-related ets tables disappear by the time the receive handles the message.
>
> --steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150609/5d3fe353/attachment.htm>
More information about the erlang-questions
mailing list