mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-14 07:40:38 +01:00
- [RPC] moved request enqueue macros to the GUI loop package;
- [GUI] ensured the gui events loop thread is terminated before quitting the server and the program.
This commit is contained in:
parent
8ad6b368ec
commit
377f42fa5c
@ -72,20 +72,6 @@
|
||||
(error (e)
|
||||
(notify-request-error e))))
|
||||
|
||||
(defmacro with-enqueue-request ((method-name id &rest args) &body on-error)
|
||||
`(ev:with-enqueued-process-and-unblock ()
|
||||
(handler-case
|
||||
(comm:make-request ,method-name ,id ,@args)
|
||||
(error (the-error) ; anaphora
|
||||
(declare (ignorable the-error))
|
||||
,@on-error))))
|
||||
|
||||
(defun enqueue-request-and-wait-results (method-name id priority &rest args)
|
||||
(ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args))
|
||||
:push-event-fn #'ev:push-event-unblock
|
||||
:priority priority))
|
||||
|
||||
|
||||
(defun slurp-gemini-stream (iri &key
|
||||
(use-cache t)
|
||||
(process-function #'identity)
|
||||
|
@ -13,6 +13,6 @@
|
||||
(gui:pack editor :fill :both)))))
|
||||
|
||||
(defun quit ()
|
||||
(comm:close-server)
|
||||
(gui:break-mainloop)
|
||||
(client-events:stop-events-loop)
|
||||
(gui:break-mainloop))
|
||||
(comm:close-server))
|
||||
|
@ -4,18 +4,41 @@
|
||||
|
||||
(defparameter *events-loop-lock* (bt:make-lock "events-loop-lock"))
|
||||
|
||||
(defparameter *events-loop-thread* nil)
|
||||
|
||||
(defun events-loop-running-p ()
|
||||
(misc:with-lock (*events-loop-lock*)
|
||||
(not *stop-events-loop*)))
|
||||
|
||||
(defun stop-events-loop ()
|
||||
(misc:with-lock (*events-loop-lock*)
|
||||
(setf *stop-events-loop* t)))
|
||||
(setf *stop-events-loop* t))
|
||||
#+debug-mode (misc:dbg "Stopping gui event thread")
|
||||
(ev:with-enqueued-process-and-unblock ()
|
||||
#+debug-mode (misc:dbg "Stopping dummy event"))
|
||||
#+debug-mode (misc:dbg "Stopped gui event thread"))
|
||||
|
||||
(defun start-events-loop ()
|
||||
(misc:with-lock (*events-loop-lock*)
|
||||
(setf *stop-events-loop* nil))
|
||||
(bt:make-thread (lambda ()
|
||||
(loop while (events-loop-running-p) do
|
||||
(when (not (ev:stop-event-dispatching-p))
|
||||
(ev:dispatch-program-events-or-wait))))))
|
||||
(setf *events-loop-thread*
|
||||
(bt:make-thread (lambda ()
|
||||
(loop while (events-loop-running-p) do
|
||||
(misc:dbg "event loop!")
|
||||
(ev:dispatch-program-events-or-wait)
|
||||
(misc:dbg "dipacth event loop! ~a run
|
||||
~a " *stop-events-loop* (events-loop-running-p)))
|
||||
(misc:dbg "event loop fine! ~a" *stop-events-loop*)))))
|
||||
|
||||
(defmacro with-enqueue-request ((method-name id &rest args) &body on-error)
|
||||
`(ev:with-enqueued-process-and-unblock ()
|
||||
(handler-case
|
||||
(comm:make-request ,method-name ,id ,@args)
|
||||
(error (the-error) ; anaphora
|
||||
(declare (ignorable the-error))
|
||||
,@on-error))))
|
||||
|
||||
(defun enqueue-request-and-wait-results (method-name id priority &rest args)
|
||||
(ev:push-function-and-wait-results (lambda () (apply #'comm:make-request method-name id args))
|
||||
:push-event-fn #'ev:push-event-unblock
|
||||
:priority priority))
|
||||
|
@ -3253,9 +3253,10 @@
|
||||
:constants
|
||||
:text-utils
|
||||
:misc-utils)
|
||||
(:local-nicknames (:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:ev :program-events))
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:ev :program-events))
|
||||
(:export
|
||||
:events-loop-running-p
|
||||
:stop-events-loop
|
||||
@ -3267,11 +3268,11 @@
|
||||
:constants
|
||||
:misc
|
||||
:text-utils)
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:gui :nodgui)
|
||||
(:gui-utils :nodgui.utils))
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:gui :nodgui)
|
||||
(:gui-utils :nodgui.utils))
|
||||
(:export
|
||||
:+icon-dir+
|
||||
:load-icons
|
||||
@ -3287,11 +3288,11 @@
|
||||
:cl
|
||||
:config
|
||||
:constants)
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:gui :nodgui)
|
||||
(:gui-utils :nodgui.utils))
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:gui :nodgui)
|
||||
(:gui-utils :nodgui.utils))
|
||||
(:export
|
||||
:validator
|
||||
:regexp-validator
|
||||
@ -3333,6 +3334,7 @@
|
||||
:text-utils
|
||||
:misc-utils)
|
||||
(:local-nicknames (:comm :json-rpc-communication)
|
||||
(:ev :program-events)
|
||||
(:re :cl-ppcre)
|
||||
(:a :alexandria)
|
||||
(:gui :nodgui)
|
||||
|
Loading…
x
Reference in New Issue
Block a user