blob: 6370e204c309ef16f76ecb03f92eadf15e66e2b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//! Wait for Exception Reply
const types = @import("../types/types.zig");
const constants = @import("../constants/constants.zig");
const handlers = @import("../handlers/handlers.zig");
const Exception = types.Exception;
const Port = types.Port;
const Action = constants.Action;
pub const Reply = struct {
action: Action,
new_state: bool,
valid: bool,
};
pub fn wait_for_reply(exception: *Exception, port: *const Port) Action {
_ = port;
const reply = receive_reply();
if (!reply.valid) {
return handlers.default_action(exception.exception_type);
}
if (reply.new_state) {
apply_new_state(exception);
}
return reply.action;
}
fn receive_reply() Reply {
return Reply{
.action = .terminate,
.new_state = false,
.valid = true,
};
}
fn apply_new_state(exception: *Exception) void {
_ = exception;
}
pub fn wait_with_timeout(exception: *Exception, port: *const Port, timeout_ms: u64) Action {
_ = timeout_ms;
return wait_for_reply(exception, port);
}
|