main.adb

来自「Ada 2005 Training Notes.」· ADB 代码 · 共 51 行

ADB
51
字号
with Protected_Variables;with Ada.Text_IO;	use Ada.Text_IO;with Semaphores; use Semaphores;procedure Main is   I: Protected_Variables.Item := Protected_Variables.Red;   S: Semaphore(Start_Count => 10);   type Cell;   type Cell_Ptr is access Cell;   type Cell is record      I: Integer;   end record;   L: Cell_Ptr := new Cell'(I=>37);   N: Cell_Ptr := new Cell'(I=>56);begin   Put_Line(Protected_Variables.Item'Image(I));   Protected_Variables.Protected_Variable.Write(I);   Put_Line(Protected_Variables.Item'Image(I));   Protected_Variables.Protected_Variable.Read(I);   I := Protected_Variables.Green;   Put_Line(Protected_Variables.Item'Image(I));   Protected_Variables.Protected_Variable.Write(I);   I := Protected_Variables.Blue;   Protected_Variables.Protected_Variable.Read(I);   Put_Line(Protected_Variables.Item'Image(I));   -- Semaphore Locks   for I in Integer Range 1..10 loop      S.Secure;   end loop;   for I in Integer Range 1..10 loop      S.Release;   end loop;   L := N;   Put_Line(Integer'Image(L.I));   Put_Line(Integer'Image(N.I));end Main;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?