[Prev][Next][Index][Thread]
Re: Passing parameters to threads
Roman Budzianowski wrote:
[...]
> > > On Thu, 13 Apr 2000, Dustin Voss wrote:
> > > > What is the best practice to pass a parameter to a thread? The thread
> > > > function passed to make(<thread>) looks like it takes no parameters.
[...]
> It may simpler to just define a thread variable like:
> define thread variable *thread-state* = #f;
>
> and then use the with-dynamic-binding macro (I hope I got the name right):
> with-dynamic-binding(*thread-state* = get-my-state())
> ...
>
> end;
I may not understand exactly what you are trying to achieve, but
I do not see why this would be simpler.
Are you proposing the following ?
make(<thread>,
function: method () => ();
dynamic-bind(*thread-state* = get-my-state());
...
end;
end method);
I fail to see what this adds to:
make(<thread>,
function: method () => ();
let my-state = get-my-state();
...
end method);
And the initial problem was to get the some state to the thread,
so get-my-state() is the non-trivial function here.
If you are proposing something else, make sure your solution
complies with Hugh's warning about thread-local bindings.
*thread-state* will be #f at the start of the new thread,
and so cannot be relied upon to pass any value to the
new thread, even if captured in a closure.
Regards - Eric
--
Eric Gouriou eric_gouriou@pobox.com
References: