[Vm-dev] Can we invert logic of critical section primitives (186,
dionisiydk at gmail.com
Mon Jan 11 16:35:19 UTC 2016
Current logic is:
- primitiveEnterCriticalSection returns true if section is already entered
inside same Process (when recursive call happens). It returns false when
new lock on critical section acquired
- primitiveTestAndSetOwnershipOfCriticalSection returns true if section is
already entered inside same Process (when recursive call happens). It
returns false when new lock on critical section acquired. It returns nil
when section locked by other process.
Users of this code must handle process termination carefully which required
local variable which track current lock state:
[lockState := section primitiveEnterCriticalSection.
ensure: ["condition around lockState" section
With current logic of primitives it is not easy to give this variable
intuitive name. You can't name it exitRequired or sectionEnteredHere
because primitive returns opposite value.
Can we invert this primitive return values? It will make users code cleaner
and easy to understand.
This primitives are not used in Pharo or Squeak yet. I push change for
Pharo. But now I have thoughts that it is better to change primitives
before we will start use it.
What you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev