feat: make desktop FFI invocation asynchronous

This commit is contained in:
Levi committed 2026-09-06 11:23:27 +08:00
1 parent 8f3cf35162
commit d12122ea86
13 files changed
+574 -141

No files matched your search

+4
View File
@@ -16,6 +16,8 @@ const (
// Invoke dispatches a Core API request without using an HTTP listener. It is
// the shared entry point for Desktop FFI and gomobile bindings.
func Invoke(method, path, rawQuery, body string) string {
runtimeMu.RLock()
defer runtimeMu.RUnlock()
service := APIService
if service == nil {
return marshalInvokeResult(model.NewErrorResult("service not started"))
@@ -29,6 +31,8 @@ func Invoke(method, path, rawQuery, body string) string {
}
func SubscribeTaskEvents(mask uint64, listener func(payload string)) {
runtimeMu.RLock()
defer runtimeMu.RUnlock()
if APIService == nil {
return
}
+1 -1
View File
@@ -29,7 +29,7 @@ import (
)
var (
runtimeMu sync.Mutex
runtimeMu sync.RWMutex
Downloader *download.Downloader
APIService *goapi.Service