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.
|
||||||
+24
-19
@@ -54,23 +54,24 @@
|
|||||||
|
|
||||||
|
|
||||||
-record(s,
|
-record(s,
|
||||||
{wx = none :: none | wx:wx_object(),
|
{wx = none :: none | wx:wx_object(),
|
||||||
frame = none :: none | wx:wx_object(),
|
frame = none :: none | wx:wx_object(),
|
||||||
lang = en :: en | jp,
|
lang = en :: en | jp,
|
||||||
j = none :: none | fun(),
|
j = none :: none | fun(),
|
||||||
prefs = #{} :: map(),
|
prefs = #{} :: map(),
|
||||||
keys = #w{} :: #w{},
|
keys = #w{} :: #w{},
|
||||||
accs = [] :: [#wr{}],
|
accs = [] :: [#wr{}],
|
||||||
check = #w{} :: #w{},
|
rider = none :: none | pid(),
|
||||||
list = #w{} :: #w{},
|
check = #w{} :: #w{},
|
||||||
dl = #w{} :: #w{},
|
list = #w{} :: #w{},
|
||||||
dest = none :: none | wx:wx_object(),
|
dl = #w{} :: #w{},
|
||||||
ttl = none :: none | wx:wx_object(),
|
dest = none :: none | wx:wx_object(),
|
||||||
path = none :: none | wx:wx_object(),
|
ttl = none :: none | wx:wx_object(),
|
||||||
sign = none :: none | wx:wx_object(),
|
path = none :: none | wx:wx_object(),
|
||||||
size = none :: none | wx:wx_object(),
|
sign = none :: none | wx:wx_object(),
|
||||||
cost = none :: none | wx:wx_object(),
|
size = none :: none | wx:wx_object(),
|
||||||
ul = none :: none | wx:wx_object()}).
|
cost = none :: none | wx:wx_object(),
|
||||||
|
ul = none :: none | wx:wx_object()}).
|
||||||
|
|
||||||
%-record(mochila,
|
%-record(mochila,
|
||||||
% {tar = <<>> :: binary(),
|
% {tar = <<>> :: binary(),
|
||||||
@@ -306,8 +307,12 @@ do_accounts(State, Manifest) ->
|
|||||||
State.
|
State.
|
||||||
|
|
||||||
|
|
||||||
do_check(State) ->
|
do_check(State = #s{rider = none}) ->
|
||||||
ok = tell(info, "Would do_check."),
|
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.
|
State.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user