async_patterns API review request

24 views
Skip to first unread message

Yifei Teng

unread,
Jun 2, 2023, 3:43:42 PM6/2/23
to api-council
Hi Council,

To move drivers out-of-tree, we'd like to publish the async_patterns and its testing libraries to the SDK. This is a C++ library for implementing the isolated state async pattern. It's used by quite a lot of drivers, especially in tests when they need to simultaneously wrangle synchronous and async logic while ensuring memory and thread safety.

Here are the public interfaces:

sdk/lib/async_patterns/cpp/dispatcher_bound.h: a wrapper that lets one object own another async object and asynchronously call it from arbitrary threads. The calls will be serialized.

sdk/lib/async_patterns/testing/cpp/dispatcher_bound.h: a wrapper that extends the former with support for synchronous calls from arbitrary threads.

sdk/lib/async_patterns/cpp/receiver.h: a hub for an owner object to asynchronously receive messages and calls from arbitrary threads. The calls will be serialized.

sdk/lib/async_patterns/cpp/callback.h: a weak callback that lets one object asynchronously call into another async object from an arbitrary thread, canceling if the receiving object is going away. Analogous to `fit::callback`.

sdk/lib/async_patterns/cpp/function.h: similar to the above but allows repeated calls. Analogous to `fit::function`.

sdk/lib/async_patterns/cpp/sendable.h: documentation on the constraints on objects sent between threads.

sdk/lib/async_patterns/cpp/task_scope.h: A task queue that cancels all pending tasks when the owner is going away.

The headers are pretty extensively documented but can be involved, so the RFC explains the background motivation.

Thanks!
Yifei

Yifei Teng

unread,
Jun 7, 2023, 4:00:25 PM6/7/23
to api-council, Yifei Teng, Novin Changizi
Just a gentle ping if this slipped by. This library is used by Novin's driver testing library so it would be on the dependency path to out-of-tree drivers. I'm happy to do either an in-person calibration or an asynchronous one, or explain more background materials. Would love to hear the council's advice.

Cheers,
Yifei

Hunter Freyer

unread,
Jun 7, 2023, 4:12:11 PM6/7/23
to Yifei Teng, api-council, Novin Changizi
Hey Yifei! No, this didn't slip by, I'm just an incorrigible procrastinator. Thanks for the ping.

I've booked some time for an in-person calibration next Tuesday. Would you mind preparing a CL that makes a trivial change to each of those files, so we have a place to leave comments? 

If you already have in mind some areas of the API that might make for particularly interesting discussion, it'd be helpful to prepare a doc beforehand listing the questions you may want to ask the group. Otherwise, we can just work from the CL.

Either way, send me the links so I can attach them to the invitation.

See you then!

Hunter

--
You received this message because you are subscribed to the Google Groups "api-council" group.
To unsubscribe from this group and stop receiving emails from it, send an email to api-council...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/api-council/9544ef57-8054-4b0c-92bd-c4d99db35c7en%40fuchsia.dev.

Yifei Teng

unread,
Jun 13, 2023, 2:16:05 PM6/13/23
to Hunter Freyer, api-council, Novin Changizi
On Wed, Jun 7, 2023 at 1:12 PM Hunter Freyer <hjfr...@google.com> wrote:
Hey Yifei! No, this didn't slip by, I'm just an incorrigible procrastinator. Thanks for the ping.

I've booked some time for an in-person calibration next Tuesday. Would you mind preparing a CL that makes a trivial change to each of those files, so we have a place to leave comments? 

Sure thing! Here is a CL with the changes: https://fuchsia-review.git.corp.google.com/c/fuchsia/+/869016
 

If you already have in mind some areas of the API that might make for particularly interesting discussion, it'd be helpful to prepare a doc beforehand listing the questions you may want to ask the group. Otherwise, we can just work from the CL.

I don't have a list of questions in particular. The library is born out of the isolated state async C++ RFC (which I still have to visit again to get over the finish line.. but have been reviewed by many people and without major unsolved questions) where the high level designs were discussed.

If people don't have time to review all the headers, I recommend starting/prioritizing DispatcherBound and TestDispatcherBound since they are the most used.

Christopher Anderson

unread,
Jun 13, 2023, 2:19:25 PM6/13/23
to Yifei Teng, Hunter Freyer, api-council, Novin Changizi
It seems this event has disappeared from my calendar.

Hunter Freyer

unread,
Jun 13, 2023, 2:22:49 PM6/13/23
to Christopher Anderson, Yifei Teng, api-council, Novin Changizi
Sorry, I've moved this to Thursday to (hopefully) better align with Wez's schedule. 
Reply all
Reply to author
Forward
0 new messages