[Pharo-project] [squeak-dev] Re: Process-specific state broken and uncomplete
leves at elte.hu
Tue Nov 9 05:42:59 CET 2010
On Tue, 9 Nov 2010, Igor Stasenko wrote:
> No, you can't. I feel sorry for you :)
> A #useSession:during: using ensure, and of course it will work
> correctly, because you not accessing session via
> process-specific storage. This is illustrated by my "good fork" example.
Erm, no. In both of your examples the session wasn't aquired by the forked
process. It was available via a variable. If you aquire the session _in_
the forked process _from_ the session store, then the #ensure: block in
the session store will be able to retrieve it.
> now replace #doSomething with this:
> [ 1 year asDelay wait ] ensure: [
> self assert: (Processor activeProcess environmentAt: #session) notNil ]
> and then terminate a process which running your fork.
Replaced (in theory) and terminated. What will happen? This assertion in
this #ensure: block will fail, but the session will be retrieved properly
by the session store's unwind block.
So you can use process local variables, but you shouldn't access them
during unwinding (#ensure:, #ifCurtailed:, whatever). This is possible as
I showed it in my example.
> In attachment you'll find a test, which shows the problem (i using
> tests from Pharo image).
The test fails, because you're accessing a process local variable in an
unwind block, which you shouldn't do.
> Best regards,
> Igor Stasenko AKA sig.
More information about the Pharo-project