Description
Adapts a one-shot structured blocking service to one supervised generation. The application retains a typed service object and operations; the adapter adds a generation owner that observes readiness and forwards cooperative shutdown while the service's blocking Run operation executes. This is suitable for Worker_Pools, IO.Structured_Servers, and application listener loops that already expose Run, Request_Shutdown, and Current-like readiness operations.
Application_Context
type Application_Context (<>) is limited private;
Application state kept alive by the enclosing supervisor Run scope.
Create
function Create (Context : not null access Application_Context) return Service
Construct a fresh limited service using generation-stable context.
Parameters
- Context
Context retained through service join
Return value
Fresh service object by limited build-in-place return
Generation_CPU
Generation_CPU : System.Multiprocessors.CPU_Range := System.Multiprocessors.Not_A_Specific_CPU;
CPU aspect applied to the service-owner task.
Generation_Model
Generation_Model : Flyology.Execution_Model;
Concrete execution model for the service-owner task.
Poll_Interval
Poll_Interval : Duration := 0.001;
Positive relative interval for readiness and stop observation.
Ready
function Ready (Item : Service) return Boolean
Report whether the service completed application initialization. This operation runs concurrently with Run_Service and must be task safe and nonblocking.
Parameters
- Item
Service to inspect
Return value
True only when dependents may use the service
Request_Shutdown
procedure Request_Shutdown (Item : in out Service)
Request idempotent nonblocking service shutdown. This operation runs concurrently with Run_Service and must provide its own synchronization.
Parameters
- Item
Live service to stop
Run
procedure Run
(Context : aliased in out Application_Context;
Control : aliased in out Generation_Control;
Result : out Generation_Result)
Construct one fresh service, run it in a dependent task, publish readiness only after Ready returns True, and forward generation stop to Request_Shutdown. The call joins the service task and never allows its object, context, or resources to outlive the generation. A service that ignores shutdown remains subject to the supervisor's ordinary stuck semantics; the adapter does not promise forced termination.
Parameters
- Context
Application state retained through service join
- Control
Fresh generation readiness and cancellation channel
- Result
Terminal result after the generation owner joins
Raised exceptions
- Program_Error
Adapter configuration or a service operation is invalid
- Tasking_Error
Service task activation failed
Run_Service
procedure Run_Service (Item : in out Service; Context : aliased in out Application_Context)
Execute the service's existing synchronous structured scope.
Parameters
- Item
Fresh service retained through the call
- Context
Application context retained through the call
Service
type Service (<>) is limited private;
Fresh one-shot structured service object constructed per generation.