Create a foreign token for a callback.

Note that the passed ForeignCallback must be GC preserved while this token is being used by the foreign code. The user can pass the token around and use it to invoke the callback with the data by calling notify!.


A variant of Treiber stack that assumes single-consumer for simple (hopefully) correct implementation.

Safety notes: push! and unsafe_push! on SingleConsumerStack{T} can be called from multiple tasks/threads. unsafe_push! can be called from foreign threads without the Julia runtime. Only one Julia task is allowed to callpopall!` at any point. This simplifies the implementation and avoids the use of "counted pointer" (and hence 128 bit CAS) that would typically be required for general Treiber stack with manual memory management.