mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 04:43:41 +00:00
feat: make desktop FFI invocation asynchronous
This commit is contained in:
1 parent
8f3cf35162
commit
d12122ea86
13 files changed
+574
-141
No files matched your search
@@ -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
@@ -29,7 +29,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
runtimeMu sync.Mutex
|
||||
runtimeMu sync.RWMutex
|
||||
|
||||
Downloader *download.Downloader
|
||||
APIService *goapi.Service
|
||||
|
||||
Reference in new issue
Block a user