Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The consumer maintains a stack of access keys so that invocations from a callback within a callback are possible. The top of the stack corresponds to the most recent invocation. An empty stack means that the consumer was not yet invoked.

draw.io Diagram
bordertrue
diagramNameConsumer invoked from callback
simpleViewerfalse
width
linksauto
tbstyletop
lboxtrue
diagramWidth402
revision1
draw.io Diagram
bordertrue
diagramNameConsumer invoked from callback, other thread
simpleViewerfalse
width
linksauto
tbstyletop
lboxtrue
diagramWidth561
revision2

When acquire  is invoked, we first check if access is restricted. It is restricted when the access-key stack is not empty. If it is not empty, the thread-local variable must be equal to the value on the top of the stack. If it is empty, any thread may continue. After this check, we generate a new access-key that can be used inside callbacks. This new access key is pushed on the stack and also stored in the thread-local variable.

...