Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Queue (Using Tasking)
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
--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;
Show compiler warnings
[
+
]
Show input
Compilation time: 0.59 sec, absolute running time: 0.08 sec, cpu time: 0.02 sec, memory peak: 3 Mb, absolute service time: 0,75 sec
edit mode
|
history
|
discussion
1 2 3 4 5 6 7 8 9 10