Re: Idiom to fetch key and datum
John Cowan 07 Sep 2015 17:58 UTC
Takeshi Abe scripsit:
> Just a minor point, but can the idiom code be:
> (let ((key (ephemeron-key ephemeron)))
> (if (ephemeron-broken? ephemeron-broken)
> ... broken case ...
> (let ((datum (ephemeron-datum ephemeron)))
> ... code using key and datum ...)))
> in order to spare the useless access to datum when the ephemeron
> has already been broken?
Unfortunately the answer is no. In a system where GC runs in a separate
thread, the ephemeron may break after calling ephemeron-broken? and
before calling ephemeron-datum. You really do have to capture both
key and datum first.
--
John Cowan http://www.ccil.org/~cowan xxxxxx@ccil.org
I now introduce Professor Smullyan, who will prove to you that either
he doesn't exist or you don't exist, but you won't know which.
--Melvin Fitting