On this page:
start-atomic
end-atomic
call-as-atomic
call-as-nonatomic

5.6 Atomic Execution

 (require ffi/unsafe/atomic)

Disables and enables context switches at the level of Racket threads. Calls to start-atomic and end-atomic can be nested.

Using call-as-atomic is somewhat safer, in that call-as-atomic correctly catches exceptions and re-raises them after exiting atomic mode. For simple uses, however, start-atomic and end-atomic are faster.

(call-as-atomic thunk)  any
  thunk : (-> any)
Calls thunk in atomic mode. If thunk raises and exception, the exception is caught and re-raised after exiting atomic mode.

When call-as-atomic is used in the dynamic extent of call-as-atomic, then thunk is simply called directly (as a tail call).

(call-as-nonatomic thunk)  any
  thunk : (-> any)
Within the dynamic extent of a call-as-atomic, calls thunk in non-atomic mode. Beware that the current thread maybe suspended or terminated by other threads during thunk, in which case the call never returns.

When used not in the dynamic extent of call-as-atomic, call-as-nonatomic raises exn:fail:contract.