Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Queue (Using Tasking)
--GNAT 4.9.3 with Ada.Text_IO; use Ada.Text_IO; with ada.exceptions; procedure Hello is task type queue(len : integer) is entry push(num : integer); entry pop(num : out integer); end queue; task body queue is data : array(1..len) of integer; idx, idx1 : integer := 0; queue_full, queue_empty : exception; begin loop select accept push(num : integer) do idx := idx + 1; data(idx) := num; exception when e : constraint_error => raise queue_full with ada.exceptions.exception_message(e); end push; or accept pop(num : out integer) do idx1 := idx1 + 1; num := data(idx1); exception when e : constraint_error => raise queue_empty with ada.exceptions.exception_message(e); end pop; or terminate; end select; end loop; end queue; myq : queue(10); num : integer; begin for i in 1..myq.len loop myq.push(i); end loop; for i in 1..myq.len loop myq.pop(num); Put_Line (num'img); end loop; end Hello;
run
|
edit
|
history
|
help
1
Ada Dimentional System
Memory Alignment
ordenar.adb
susuma_dos_enteros.adb
macro-like function
Ada nested lexical scope
Ada Dimentional System
es_perfecto.adb
function calling using pointers
suma_enteros_ppal.adb