async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Question: Can WakerSet be Send+Sync?

Open jbr opened this issue 3 years ago • 3 comments

WakerSet implements its own atomic locking mechanism but is not Send or Sync. The use of it in async-std is accompanied by unsafe impl Send and Sync for containing types, but that seems like it would be more appropriate to put on the type that provides the locking mechanism for locality of reference. Is there a reason that WakerSet isn't Send + Sync but Condvar is?

I'd happily open a PR to move the unsafe impl Send and Sync to WakerSet unless I've misunderstood something about the safety of this type

jbr avatar Mar 22 '21 20:03 jbr

Is the crate still maintained? Seems like a long time since the code was submitted?

zhuxiujia avatar Mar 24 '21 09:03 zhuxiujia

The last commit was a month ago. Yes, async-std is still maintained

jbr avatar Mar 24 '21 15:03 jbr

@jbr I believe you're right that there's nothing inherent to WakerSet that would prevent it from being Send. UnsafeCell is !Sync though, which we are using in WakerSet.

I'm not familiar enough with the access patterns of UnsafeCell and WakerSet to definitely answer whether we can move the Sync bound from CondVar to WakerSet. But moving the Send bound seems like it should be fine.

yoshuawuyts avatar Apr 02 '21 11:04 yoshuawuyts