Finalization and synchronization

This commit is contained in:
2026-04-20 18:19:20 +02:00
parent f13ce53b71
commit 95936abdce
2 changed files with 17 additions and 5 deletions

View File

@@ -316,7 +316,7 @@
;RKTWEBVIEW_QT_EXPORT void rkt_webview_register_evt_callback(void (*f)(int));
(define-rktwebview rkt_webview_register_evt_callback
(_fun (_fun #:async-apply evt-apply #:atomic? #t
_int -> _void) -> _void))
_int -> _void) -> _int))
;RKTWEBVIEW_QT_EXPORT void rkt_webview_init(const char *from);
(define-rktwebview rkt_webview_init
@@ -526,7 +526,10 @@
(define (event-callback num)
(os-async-channel-put events-channel num))
(rkt_webview_register_evt_callback event-callback)
(void
(while (= (rkt_webview_register_evt_callback event-callback) 0)
(sleep 0.1)
))
;(set! quiet-call (start-event-processing))
(define evt-cb-hash (make-hash))
@@ -593,7 +596,10 @@
(if polling
(begin
(sleep 0.01)
(os-async-channel-try-get events-channel))
(let ((w (os-async-channel-try-get events-channel)))
(if (eq? w #f)
0
w)))
(sync events-channel))))
)
(letrec
@@ -867,9 +873,14 @@
(dbg-webview "Start event polling instead of using an event callback")
(dbg-webview "To make sure the library does not get stuck on a dangling callback")
(event-callback evt-start-polling)
(rkt_webview_register_evt_callback #f)
; Set callback to null, but as an event can be in progress,
; we need to check if the mutex lock could be aquired.
; otherwise we wait.
(while (= (rkt_webview_register_evt_callback #f) 0)
(sleep 0.1))
(while (eq? event-processing-kind 'sync)
(sleep 0.01))
(sleep 0.1))
(sync-log-webview)
; When asked to, close all windows