[erlang-bugs] erl_driver documentation confusing
Thu Jul 17 19:04:54 CEST 2008
Yes, that's essentially what I ended up doing. That documentation change
will save the next person some time, I imagine :)
Re: other suggestions, it's too dangerous to propose actually changing the
behaviour, maybe somebody in the bowels of some linked-in driver is
counting on it. So I'm fine with just the documentation change.
On Thu, 17 Jul 2008, Sverker Eriksson wrote:
> Hi Paul
> I agree the example is a bit misleading. I guess this is what you want
> to do:
> unsigned key = (unsigned) myPort;
> r = driver_async(myPort, &key, myData, myFunc);
> Using the port identifier is just a way to select a "random" thread. And
> it's enough to initialize 'key' once, in the start function of
> erl_drv_entry for example.
> The only reason for driver_async to assign to *key (that I can see) is
> that, after the call to driver_async(), *key will uniquely identify the
> used thread. I don't see how that would be very useful though.
> I will change the documentation according to my example above, unless
> you have any other suggestion.
> /Sverker, Erlang/OTP Ericsson
> Paul Mineiro wrote:
> > the documentation for erl_driver says that to ensure that the same thread
> > is used for all calls to your driver you should do:
> > r = driver_async(myPort, (unsigned int*)&myPort, myData, myFunc);
> > well this caused me lots of troubles because inside the implementation to
> > driver_async in erts/emulator/beam/erl_async.c there is a line
> > *key = qix;
> > where key is the 2nd argument to driver_async. this caused some
> > segmentation faults in my code until i realized this was happening (since
> > I continued to use myPort as a valid port).
> > -- p
> > p.z. is there a reason *key is assigned at all?
> > _______________________________________________
> > erlang-bugs mailing list
> > http://www.erlang.org/mailman/listinfo/erlang-bugs
In an artificial world, only extremists live naturally.
-- Paul Graham
More information about the erlang-bugs