Skip to content

support uthread on windows with msvc#467

Merged
ChuanqiXu9 merged 2 commits intoalibaba:mainfrom
c8ef:uthread-win
Apr 8, 2026
Merged

support uthread on windows with msvc#467
ChuanqiXu9 merged 2 commits intoalibaba:mainfrom
c8ef:uthread-win

Conversation

@c8ef
Copy link
Copy Markdown
Collaborator

@c8ef c8ef commented Apr 4, 2026

Why

related: #451

What is changing

Example

@c8ef c8ef marked this pull request as ready for review April 4, 2026 15:05
@c8ef c8ef requested review from ChuanqiXu9 and poor-circle April 4, 2026 15:06
auto f = [&taskEx, &taskNotify]() mutable {
Latch latch(1u);
taskNotify.schedule([latchPtr = &latch]() mutable {
std::this_thread::sleep_for(1us);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

std::this_thread::sleep_for with durations less than one millisecond on Windows gets rounded up to the system timer tick, which is typically around 1ms to 15.6ms, causing tests to run slower on Windows.

// needed here.
#else
#warning "Backtracing from uthreads may be broken"
#error "Backtracing from uthreads may be broken"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

warning is fine. Uthread is not a necessary part of the library.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Unfortunately, #warning is standardized in C++23, so it cannot be used in MSVC with C++20 : (
And I believe this line is unreachable for all platforms that support uthread.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If it is unreachable, let's remove it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps we could change it to assert(false, "...")?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It is the same thing with #error here. Let's land it, I don't want nitpicking

@ChuanqiXu9 ChuanqiXu9 merged commit 911b3c8 into alibaba:main Apr 8, 2026
16 checks passed
@c8ef c8ef deleted the uthread-win branch April 8, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants