swiftlang / swift-corelibs-libdispatch

The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware
swift.org
Apache License 2.0
2.47k stars 460 forks source link

Use proper atomics and ref counting #807

Open AreaZR opened 10 months ago

AreaZR commented 10 months ago

Prefer __atomic_compare_exchange_n over __sync_bool_compare_and_swap.

I chose weak because we are looping and reading the value of old_value constantly anyway, so it would be better to have it weak.

Otherwise, it is equivalent to what it was before.

ktoso commented 10 months ago

@swift-ci please test

AreaZR commented 10 months ago

@ktoso My bad! It compiled and ran fine on my machine but I found the mistake and fixed it.

Can we please try one more time?

AreaZR commented 10 months ago

@compnerd Can we please do a test?

compnerd commented 10 months ago

I'm not sure that this is valuable enough to do really.

rjmccall commented 10 months ago

I'm not sure what the point of the atomics change is. The control flow change is non-obvious and totally unexplained in either comments or in the PR summary.