This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
runnable closure limitation
- From: thomas kirk <tk at research dot att dot com>
- To: kawa at sourceware dot org
- Date: Mon, 16 May 2011 11:10:26 -0400
- Subject: runnable closure limitation
- Reply-to: tk at research dot att dot com
At one time, Kawa's implementation of runnable closures included
an explicit reference to its environment. In the current
implementation, it relies on the affinity between threads and
environments to associate the runnable with the environment.
This is fine for one-shot runnables, but it's a problem if the
runnable is executed repeatedly by, say, a ThreadPoolExecutor,
where the environment can change from one execution to the next
(but then it's hardly a closure). I don't want to call this a bug
since taking the environment ref out of RunnableClosure was
clearly intentional (but why?), and I may have missed something.
If this is the intended behavior of runnable, the documentation
should make this limitation clear. Unfortunately it's not a
fail-fast scenario, as things may appear to work properly for
a long time if the executor uses the same task thread most of the
time (which is often the case).