apple / swift-corelibs-libdispatch

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

Use proper atomics and ref counting #807

Open AreaZR opened 9 months ago

AreaZR commented 9 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 9 months ago

@swift-ci please test

AreaZR commented 9 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 9 months ago

@compnerd Can we please do a test?

compnerd commented 9 months ago

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

rjmccall commented 9 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.