Are*_*ski 2 concurrency ada syntax-error task
这段代码有什么问题?编译器说两件事,没有Run条目和Run接受与条目不匹配(两者似乎都是错误的),并且单独表示Train在声明之前不能使用(但它已经被声明).请向我解释发生了什么.
我对显示整个代码犹豫不决,但可以这样做.
type ItineraryType is array (0..255) of Integer;
type Train is record
Label : Integer;
Capacity : Integer;
Maxspeed : Integer;
Starts : Integer;
Itinerary : ItineraryType;
Stops : Integer;
lock : access Mutex;
end record;
task type TrainThread is
entry Run (train1:Train);
end;
task body TrainThread is
train : Train;
begin
accept Run (train1:Train) do
train := train1;
end;
end;
-- part of main
train1 := new TrainThread;
train1.Run(trains(i));
Run Code Online (Sandbox Code Playgroud)
main.adb:51:05: warning: no accept for entry "Run"
main.adb:52:17: object "Train" cannot be used before end of its declaration
main.adb:54:09: no entry declaration matches accept statement
gnatmake: "main.adb" compilation error
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
765 次 |
| 最近记录: |