Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
R. Tyler Croy
committed
Jan 30, 2011
1 parent
130b955
commit d5c85b6
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- | ||
-- | ||
-- | ||
|
||
with Ada.Text_IO, Ada.Float_Text_IO; | ||
with Ada.Numerics.Float_Random; | ||
use Ada.Float_Text_IO, Ada.Text_IO; | ||
|
||
procedure TwoTasking is | ||
task type TenLooper (Id : Character) is | ||
end TenLooper; | ||
|
||
task body TenLooper is | ||
Seed : Ada.Numerics.Float_Random.Generator; | ||
begin | ||
Ada.Numerics.Float_Random.Reset (Seed, Character'Pos (Id)); | ||
for I in 1 .. 10 loop | ||
declare | ||
Offset : Duration := Duration (Ada.Numerics.Float_Random.Random (Seed)); | ||
begin | ||
Put_Line ("Derp: " & Id & " :: " & Integer'Image (I)); | ||
Put_Line ("Delaying: " & Duration'Image (Offset)); | ||
delay Offset; | ||
end; | ||
end loop; | ||
end TenLooper; | ||
|
||
Task_1 : TenLooper ('A'); | ||
Task_2 : TenLooper ('B'); | ||
begin | ||
Put_Line ("..waiting for tasks to complete"); | ||
end TwoTasking; |