Skip to content

Add CythonLibcoroTaskWrapperCallback type alias for the asyncio Future-resolving callback - #1040

Merged
rapids-bot[bot] merged 5 commits into
rapidsai:mainfrom
Matt711:imp/future-resolve-callback
Aug 26, 2026
Merged

Add CythonLibcoroTaskWrapperCallback type alias for the asyncio Future-resolving callback#1040
rapids-bot[bot] merged 5 commits into
rapidsai:mainfrom
Matt711:imp/future-resolve-callback

Conversation

@Matt711

@Matt711 Matt711 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Because function pointers are confusing to read. And this helps some.

@Matt711
Matt711 requested a review from a team as a code owner May 15, 2026 02:07
@Matt711 Matt711 added non-breaking Introduces a non-breaking change improvement Improves an existing functionality labels May 15, 2026
*/
coro::task<void> cython_libcoro_task_wrapper(
void (*cpp_set_py_future)(void*, const char *),
PyFutureCallback cpp_set_py_future,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe AsyncIOFutureCallback?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about cython_libcoro_task_wrapper_callback to avoid the name clash? Since this is in a .pxd, it will effectively be copy-pasted into all Cython files importing it.

Alternatively, we could wrap the whole thing in a namespace.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about cython_libcoro_task_wrapper_callback to avoid the name clash?

Is there a current name clash or are you thinking of protecting against another .pxd using the same name with a different type?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put the whole thing in an anonymous namespace I think.

Although then I would worry about ODR-use violations...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a current name clash or are you thinking of protecting against another .pxd using the same name with a different type?

There is no current name clash. This is mostly about avoiding a future one.

Since this lives under _detail, we can always rename it later without a
deprecation period. Still, I think it is good style to use a unique name because this is
declared in a .pxd and may be pulled into different generated C++ files.

I do not think an anonymous namespace helps here. A cdef extern from * block
is effectively copied into the generated C++ source of each module that imports
it. So if a .pyx file also defines or imports a PyFutureCallback with a
different type, the names can still collide within that generated translation
unit.

That is why I prefer a more specific name like cython_libcoro_task_wrapper_callback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CythonLibcoroTaskWrapperCallback or no 😄 ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, yeah I guess it should be CythonLibcoroTaskWrapperCallback :)
Since this is only used in one place, a large name is fine.

@Matt711
Matt711 force-pushed the imp/future-resolve-callback branch from 0acbfeb to 2edc16e Compare August 21, 2026 20:12
@Matt711 Matt711 changed the title Add PyFutureCallback type alias for the asyncio Future-resolving callback Add CythonLibcoroTaskWrapperCallback type alias for the asyncio Future-resolving callback Aug 21, 2026
@Matt711
Matt711 force-pushed the imp/future-resolve-callback branch from dfa86d7 to b34f2d3 Compare August 21, 2026 20:25
@Matt711
Matt711 force-pushed the imp/future-resolve-callback branch from 8de8c0d to 357c842 Compare August 22, 2026 14:15
@Matt711
Matt711 requested a review from a team as a code owner August 22, 2026 14:15
@Matt711
Matt711 requested a review from gforsyth August 22, 2026 14:15
@Matt711
Matt711 requested a review from madsbk August 22, 2026 17:39
@wence-
wence- removed request for a team and gforsyth August 26, 2026 17:25
@wence-

wence- commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 99bc047 into rapidsai:main Aug 26, 2026
59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants