Tutorial by Examples

with Ada.Containers.Synchronized_Queue_Interfaces; with Ada.Containers.Unbounded_Synchronized_Queues; with Ada.Text_IO; procedure Producer_Consumer_V1 is type Work_Item is range 1 .. 100; package Work_Item_Queue_Interfaces is new Ada.Containers.Synchronized_Queue_Interfaces ...
A synchronous producer-consumer solution ensures that the consumer reads every data item written by the producer exactly one time. Asynchronous solutions allow the consumer to sample the output of the producer. Either the consumer consumes the data faster than it is produced, or the consumer consume...
This example uses the main procedure as the producer task. In Ada the main procedure always runs in a task separate from all other tasks in the program, see minimal example. ------------------------------------------------------------------ -- Sampling Consumer -- --------------------------------...
This example shows multiple producers and consumers sharing the same buffer. Protected entries in Ada implement a queue to handle waiting tasks. The default queuing policy is First In First Out. ------------------------------------------------------------------ -- Multiple producers and consumers ...

Page 1 of 1