| 221 | } |
| 222 | |
| 223 | void QuickJSRuntime::dispatch_resource_sink(MaaResource* handle, const char* message, const char* details_json) |
| 224 | { |
| 225 | std::promise<void> promise; |
| 226 | std::future<void> future = promise.get_future(); |
| 227 | d_->push_task([&promise, handle, message, details_json, &sinks = d_->plugin_resource_sinks](JSContext*) { |
| 228 | // TODO: 这里实际上在串行执行所有sink,逻辑上用Promise.all并行会更好,但是复用的sink函数已经阻塞了。 |
| 229 | for (const auto& sink : sinks) { |
| 230 | sink(handle, message, details_json); |
| 231 | } |
| 232 | promise.set_value(); |
| 233 | }); |
| 234 | return future.get(); |
| 235 | } |
| 236 | |
| 237 | void QuickJSRuntime::dispatch_controller_sink(MaaController* handle, const char* message, const char* details_json) |
| 238 | { |
no test coverage detected