parking_lot icon indicating copy to clipboard operation
parking_lot copied to clipboard

Mutex hold and wait for other mutex

Open Nokel81 opened this issue 5 years ago • 5 comments

Monitors are thread safe structs and they generally have some way of "yielding" to threads trying to get into the struct instance. These are generally done at the function level but don't necessarily. What would be very useful is the ability, while owning a RAII guard for a Mutex or a ReentrantMutex to give a list of the same.

With that list, the current thread would then wait until ONE thread has entered any of the mutexes listed (priority of the order given) and then exited. With guarantees that after that other thread exits this thread is the next to run.

This would panic if a mutex that is currently in this waiting state is in a provided list.

Nokel81 avatar Sep 25 '18 18:09 Nokel81