From 5c3926e203a75d3d73b979b356f2df1a95a126f8 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Thu, 16 Apr 2026 11:10:33 -0500 Subject: [PATCH] Tweak tweak --- lib/worker.rb | 2 + lib/worker/api.rb | 69 +++++++++++++++++++++++ lib/worker/task.rb | 4 ++ lib/worker/tasks/install_application.rb | 0 lib/worker/tasks/repair_application.rb | 0 lib/worker/tasks/uninstall_application.rb | 0 lib/worker/tasks/update_application.rb | 0 lib/worker/w3dhub_api.rb | 0 w3d_hub_linux_launcher.rb | 22 ++++++-- 9 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 lib/worker/task.rb create mode 100644 lib/worker/tasks/install_application.rb create mode 100644 lib/worker/tasks/repair_application.rb create mode 100644 lib/worker/tasks/uninstall_application.rb create mode 100644 lib/worker/tasks/update_application.rb create mode 100644 lib/worker/w3dhub_api.rb diff --git a/lib/worker.rb b/lib/worker.rb index 972fcc2..2f8c152 100644 --- a/lib/worker.rb +++ b/lib/worker.rb @@ -10,6 +10,8 @@ module W3DHubLauncher # connect to and monitor Backend web service @threads << Thread.new { backend_websocket } + Ractor.main.send({ message: "3 o'clock 'nd all's well!" }) + listener.join end diff --git a/lib/worker/api.rb b/lib/worker/api.rb index e5efb85..0cc21d1 100644 --- a/lib/worker/api.rb +++ b/lib/worker/api.rb @@ -1,9 +1,78 @@ +# Helper for launcher frontend to safely communicate with ractor (prevent deadlocks and concurrent access errors) + module W3DHubLauncher class Worker class Api Request = Data.define(:coming_soon) def initialize + @requests = [] + end + + # downloads requested resource, returns raw string + def fetch_url + end + + # downloads requested resource, periodically reporting progress until completion, returning path for file on disk + def download_url + end + + # returns user account data + # + # automatically handles signing in / refreshing token (DOES NOT remove account data if failed to refresh token due to network timeout) + def account + end + + # returns launcher settings + def settings + end + + # write updated launcher settings + def update_settings + end + + # returns list of available applications + # + # if updated list is requested, return cached version immediately and then the updated list later. + def applications + end + + # returns current list of servers as reported from GSH / cache + def servers + end + + # returns news for application + def news + end + + # request installation of application + # + # periodically reports progress until completion + def install_application + end + + # request update of application + # + # periodically reports progress until completion + def update_application + end + + # request repair of application + # + # periodically reports progress until completion + def repair_application + end + + # request relocation of application + # + # periodically reports progress until completion + def move_application + end + + # request removal of application + # + # periodically reports progress until completion + def uninstall_application end end end diff --git a/lib/worker/task.rb b/lib/worker/task.rb new file mode 100644 index 0000000..9f16fa5 --- /dev/null +++ b/lib/worker/task.rb @@ -0,0 +1,4 @@ +module W3DHubLauncher + class Task + end +end diff --git a/lib/worker/tasks/install_application.rb b/lib/worker/tasks/install_application.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/worker/tasks/repair_application.rb b/lib/worker/tasks/repair_application.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/worker/tasks/uninstall_application.rb b/lib/worker/tasks/uninstall_application.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/worker/tasks/update_application.rb b/lib/worker/tasks/update_application.rb new file mode 100644 index 0000000..e69de29 diff --git a/lib/worker/w3dhub_api.rb b/lib/worker/w3dhub_api.rb new file mode 100644 index 0000000..e69de29 diff --git a/w3d_hub_linux_launcher.rb b/w3d_hub_linux_launcher.rb index 1fb484d..636ec5c 100644 --- a/w3d_hub_linux_launcher.rb +++ b/w3d_hub_linux_launcher.rb @@ -13,13 +13,23 @@ require_relative "lib/worker" require_relative "lib/worker/api" module W3DHubLauncher - WORKER = Ractor.new { W3DHubLauncher::Worker.new } + WORKER = Ractor.new(name: "Parallel Worker") { W3DHubLauncher::Worker.new } end -W3DHubLauncher::WORKER.send({ type: :fetch, cache: true, uri: "https://github.com" }) +# Hello, I exist because there presently exists no way to ask if there are pending +# messages in our ractors mailbox without making a blocking call which is a big no no +# for a GUI application. :| +# +# Keep an eye on: https://bugs.ruby-lang.org/issues/21930: "Add Ractor#empty? method to check for pending messages without blocking" +# +# NOTE: May need to mangle Window#update to do ruby-land sleep so thread gets time to process :( +Thread.new do + loop do + message = Ractor.receive + pp message + end +end -# window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true) -window = W3DHubLauncher::Window.new(width: 1920, height: 1080, resizable: true) +window = W3DHubLauncher::Window.new(width: 1280, height: 800, resizable: true) +# window = W3DHubLauncher::Window.new(width: 1920, height: 1080, resizable: true) window.show - -puts "HELO"