-- The Completions package provides the Completion object, which notifies
-- threads when a pending operation is complete.
package Completions is
pragma Preelaborate;
-- A protected state object useful for notifying threads when an operation
-- is complete.
protected type Completion is
-- Notifies the object that the state is complete. This will unblock
-- all threads blocked on the Wait entry.
procedure Notify_Complete;
-- Checks the state of the object without waiting for it to be complete.
function Is_Complete return Boolean;
-- Blocks the caller until the state becomes complete.
entry Wait;
private
complete : Boolean := False; -- complete?
end Completion;
type A_Completion is access all Completion;
-- Deletes the Completion.
procedure Delete( obj : in out A_Completion );
pragma Postcondition( obj = null );
end Completions;