[thread.stoptoken.intro] (original) (raw)

32 Concurrency support library [thread]

32.3 Stop tokens [thread.stoptoken]

32.3.1 Introduction [thread.stoptoken.intro]

Subclause [thread.stoptoken] describes components that can be used to asynchronously request that an operation stops execution in a timely manner, typically because the result is no longer required.

Such a request is called a stop request.

An object of a type that models stoppable_tokencan be passed to an operation that can either

Once a stop request has been made it cannot be withdrawn (a subsequent stop request has no effect).

The types stop_source and stop_token and the class template stop_callback implement the semantics of shared ownership of a stop state.

The last remaining owner of the stop state automatically releases the resources associated with the stop state.

An object of type inplace_stop_sourceis the sole owner of its stop state.

An object of type inplace_stop_token or of a specialization of the class template inplace_stop_callbackdoes not participate in ownership of its associated stop state.

[Note 1:

They are for use when all uses of the associated token and callback objects are known to nest within the lifetime of the inplace_stop_source object.

— _end note_]