Futures BiLock vs std Mutex

#1

What makes a futures::sync::BiLock “not as generic as a full-blown mutex”? What prevents me from just putting a BiLock<T> in an Arc and sharing it between tasks?

#2

Reading the code will give the answer.
https://docs.rs/futures/0.1.25/src/futures/sync/bilock.rs.html#92
A first task that uses poll_lock will not get notification if second task also makes the call.

Also don’t trust code comments to be completely correct.
https://docs.rs/futures/0.1.25/src/futures/sync/bilock.rs.html#117
This could be triggered. Two executors on two threads could get here. (a third thread with the other half needed too.) The panic like all would be a denial of service but safe from further exploitation.

#3

Wow, thanks, ok, I think that should’ve been more clear from the documentation…