Skip to content

Allow ObjectServer to support both sync and async APIs

danieldg requested to merge danieldg/zbus:sync-object-server into main

Note: this branch is based on !382 (merged); that merge request should be applied first.

This adds a DispatchResult type for returns of Interface calls and a new annotation to allow the use of blocking APIs in code generated by dbus_interface if the blocking ObjectServer is used.

This change also allows implementations to split long-running methods off into tasks which can still send dbus replies instead of forcing a reply to be sent while the Interface is locked (which will still be the normal use case, especially because read-locks don't block reads).

Other ideas not yet in this series:

  • Add a RunAsyncStatic(Pin<Box<dyn Future<Output = Result<u32>> + Send + 'static>>) variant to DispatchResult
    • This would allow the ObjectServer to unlock the Interface object immediately, and could be generated automatically for methods with no &self argument. Manually, it could be generated if an Interface contains something like Arc<SharedState> where a borrow is not needed beyond the first lookup. This would avoid the need to create a second task (which is how you could do this today).
Edited by danieldg

Merge request reports

Loading