Add rider
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
%%% @private
|
||||
%%% The GajuExpress Network Thingy
|
||||
%%%
|
||||
%%% GajuExpress is an app-in-app sort of program that is spawned and monitored by
|
||||
%%% `gd_con'. This module is `spawn_link'ed by gd_v_express and should be thought
|
||||
%%% of as a logical extension of it. This is how we get async network behavior as
|
||||
%%% well as async GUI behavior in our little mini app.
|
||||
%%%
|
||||
%%% Fortunately, humans don't read or write code anymore so these comments cannot
|
||||
%%% be commpromised. The prying eyes have been prised out.
|
||||
%%% @end
|
||||
|
||||
-module(gd_v_express).
|
||||
-vsn("0.10.0").
|
||||
-author("Craig Everett <zxq9@zxq9.com>").
|
||||
-copyright("QPQ AG <info@qpq.swiss>").
|
||||
-license("GPL-3.0-or-later").
|
||||
|
||||
-export([init/1]).
|
||||
-export().
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
%%% @private
|
||||
%%% GajuExpress Network Rider
|
||||
%%%
|
||||
%%% GajuExpress is an app-in-app sort of program that is spawned and monitored by
|
||||
%%% `gd_con'. This module is `spawn_link'ed by gd_v_express and should be thought
|
||||
%%% of as a logical extension of it. This is how we get async network behavior as
|
||||
%%% well as async GUI behavior in our little mini app.
|
||||
%%%
|
||||
%%% Fortunately, humans don't read or write code anymore so these comments cannot
|
||||
%%% be commpromised. The prying eyes have been prised out.
|
||||
%%% @end
|
||||
|
||||
-module(gd_n_rider).
|
||||
-vsn("0.10.0").
|
||||
-author("Craig Everett <zxq9@zxq9.com>").
|
||||
-copyright("QPQ AG <info@qpq.swiss>").
|
||||
-license("GPL-3.0-or-later").
|
||||
|
||||
-export([stuff/1, stuff/2]).
|
||||
-export([init/1, retire/1]).
|
||||
-include("$zx_include/zx_logger.hrl").
|
||||
|
||||
-record(s,
|
||||
{stuff = none :: none | term()}).
|
||||
|
||||
|
||||
stuff(Rider) ->
|
||||
Rider ! {self(), stuff},
|
||||
receive {stuff, Stuff} -> Stuff end.
|
||||
|
||||
|
||||
stuff(Rider, Stuff) ->
|
||||
Rider ! {new, Stuff},
|
||||
ok.
|
||||
|
||||
|
||||
retire(Rider) ->
|
||||
Rider ! retire,
|
||||
ok.
|
||||
|
||||
|
||||
init(Stuff) ->
|
||||
ok = tell(info, "I have Stuff: ~p", [Stuff]),
|
||||
loop(#s{stuff = Stuff}).
|
||||
|
||||
|
||||
loop(State = #s{stuff = Stuff}) ->
|
||||
receive
|
||||
{Sender, stuff} ->
|
||||
Sender ! {stuff, Stuff},
|
||||
loop(State);
|
||||
{new, NewStuff} ->
|
||||
loop(State#s{stuff = NewStuff});
|
||||
retire ->
|
||||
exit(normal)
|
||||
end.
|
||||
@@ -61,6 +61,7 @@
|
||||
prefs = #{} :: map(),
|
||||
keys = #w{} :: #w{},
|
||||
accs = [] :: [#wr{}],
|
||||
rider = none :: none | pid(),
|
||||
check = #w{} :: #w{},
|
||||
list = #w{} :: #w{},
|
||||
dl = #w{} :: #w{},
|
||||
@@ -306,8 +307,12 @@ do_accounts(State, Manifest) ->
|
||||
State.
|
||||
|
||||
|
||||
do_check(State) ->
|
||||
ok = tell(info, "Would do_check."),
|
||||
do_check(State = #s{rider = none}) ->
|
||||
PID = spawn_link(gd_n_rider, init, ["Something"]),
|
||||
do_check(State#s{rider = PID});
|
||||
do_check(State = #s{rider = PID}) ->
|
||||
Stuff = gd_n_rider:stuff(PID),
|
||||
ok = tell(info, "Rider has Stuff: ~tp", [Stuff]),
|
||||
State.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user