/home/runner/work/pgec/pgec/_site/ct/ct_run.ct_pgec@fv-az651-965.2023-12-04_14.30.54/pgec_statem.COVER.html

1 %% Copyright (c) 2022 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15
16 -module(pgec_statem).
17
18
19 -export([cancel_generic_timeout/1]).
20 -export([generic_timeout/1]).
21 -export([generic_timeout/2]).
22 -export([nei/1]).
23 -export([send_request/1]).
24
25
26 -type request_id() :: gen_statem:request_id().
27 -type request_id_collection() :: gen_statem:request_id_collection().
28 -type server_ref() :: gen_statem:server_ref().
29
30 -type collection_req() :: #{server_ref := server_ref(),
31 request := any(),
32 label := any(),
33 requests := request_id_collection()}.
34
35 -type id_req() :: #{server_ref := server_ref(),
36 request := any()}.
37
38 -spec send_request(collection_req()) -> request_id_collection();
39 (id_req()) -> request_id().
40
41 send_request(#{server_ref := ServerRef,
42 request := Request,
43 label := Label,
44 requests := Requests}) ->
45 62 gen_statem:send_request(ServerRef, Request, Label, Requests);
46
47 send_request(#{requests := _} = Arg) ->
48
:-(
error(badarg, [Arg]);
49
50 send_request(#{server_ref := ServerRef, request := Request}) ->
51 32 gen_statem:send_request(ServerRef, Request).
52
53
54 -spec nei(any()) -> {next_event, internal, any()}.
55
56 nei(Event) ->
57 7306 {next_event, internal, Event}.
58
59
60 generic_timeout(Name) ->
61
:-(
?FUNCTION_NAME(Name, pgec_config:timeout(Name)).
62
63
64 cancel_generic_timeout(Name) ->
65
:-(
generic_timeout(Name, infinity).
66
67
68 generic_timeout(Name, Timeout) ->
69
:-(
{{timeout, Name}, Timeout, Name}.
Line Hits Source