From 9b2fe74e8386bc9c8ed7726c4746d991210c3d9c Mon Sep 17 00:00:00 2001 From: Craig Everett Date: Mon, 18 May 2026 13:31:59 +0900 Subject: [PATCH] Add rider --- src/gd_n_express.erl | 22 ----------------- src/gd_n_rider.erl | 56 ++++++++++++++++++++++++++++++++++++++++++++ src/gd_v_express.erl | 43 +++++++++++++++++++--------------- 3 files changed, 80 insertions(+), 41 deletions(-) delete mode 100644 src/gd_n_express.erl create mode 100644 src/gd_n_rider.erl diff --git a/src/gd_n_express.erl b/src/gd_n_express.erl deleted file mode 100644 index 7114337..0000000 --- a/src/gd_n_express.erl +++ /dev/null @@ -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 "). --copyright("QPQ AG "). --license("GPL-3.0-or-later"). - --export([init/1]). --export(). - - diff --git a/src/gd_n_rider.erl b/src/gd_n_rider.erl new file mode 100644 index 0000000..86c84ed --- /dev/null +++ b/src/gd_n_rider.erl @@ -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 "). +-copyright("QPQ AG "). +-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. diff --git a/src/gd_v_express.erl b/src/gd_v_express.erl index 72cacbf..76705f6 100644 --- a/src/gd_v_express.erl +++ b/src/gd_v_express.erl @@ -54,23 +54,24 @@ -record(s, - {wx = none :: none | wx:wx_object(), - frame = none :: none | wx:wx_object(), - lang = en :: en | jp, - j = none :: none | fun(), - prefs = #{} :: map(), - keys = #w{} :: #w{}, - accs = [] :: [#wr{}], - check = #w{} :: #w{}, - list = #w{} :: #w{}, - dl = #w{} :: #w{}, - dest = none :: none | wx:wx_object(), - ttl = none :: none | wx:wx_object(), - path = none :: none | wx:wx_object(), - sign = none :: none | wx:wx_object(), - size = none :: none | wx:wx_object(), - cost = none :: none | wx:wx_object(), - ul = none :: none | wx:wx_object()}). + {wx = none :: none | wx:wx_object(), + frame = none :: none | wx:wx_object(), + lang = en :: en | jp, + j = none :: none | fun(), + prefs = #{} :: map(), + keys = #w{} :: #w{}, + accs = [] :: [#wr{}], + rider = none :: none | pid(), + check = #w{} :: #w{}, + list = #w{} :: #w{}, + dl = #w{} :: #w{}, + dest = none :: none | wx:wx_object(), + ttl = none :: none | wx:wx_object(), + path = none :: none | wx:wx_object(), + sign = none :: none | wx:wx_object(), + size = none :: none | wx:wx_object(), + cost = none :: none | wx:wx_object(), + ul = none :: none | wx:wx_object()}). %-record(mochila, % {tar = <<>> :: binary(), @@ -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.