wvwwvwwv / scalable-concurrent-containers

High performance containers and utilities for concurrent and asynchronous programming
Apache License 2.0
285 stars 14 forks source link

Question: What's the purpose of the async API / sync API behaviour across await points? #143

Closed wbogocki closed 2 months ago

wbogocki commented 2 months ago

Hi. I've been scanning through the docs trying to figure out how this crate behaves around await points, specifically HashMap and IndexMap. I can see that there's an async API, which I think yields if accessing an entry would lock. Reasoning from this, it seems to me that the sync API could be made to deadlock if an entry was held across an await point. Is this the case?

I'm asking this in context of a similar situation in the dashmap crate which does deadlock.

A clarification in the docs on this and the purpose of the async API could perhaps be useful.

Thanks :)

wvwwvwwv commented 2 months ago

Hi!

Yes, async methods yield when they could not immediately acquire locks, and entries held across awaits may cause deadlock if sync methods are used elsewhere. I'll update the doc to clearly state the purpose of async methods!

wbogocki commented 2 months ago

Got it. Thanks.