Re: initialize a mutex into locked state?

From: Arjan van de Ven
Date: Fri Jun 17 2016 - 10:59:31 EST


On 6/17/2016 7:54 AM, Oleg Drokin wrote:

Yes, we can add all sorts of checks that have various impacts on code readability,
we can also move code around that also have code readability and CPU impact.

But in my discussion with Arjan he said this is a new use case that was not met before
and suggested to mail it to the list.

I'm all in favor of having "end code" be as clear as possible wrt intent.
(and I will admit this is an curious use case, but not an insane silly one)

one other option is to make a wrapper

mutex_init_locked( )
{
mutex_init()
mutex_trylock()
}

that way the wrapper can be an inline in a header, but doesn't need to touch a wide
berth of stuff... while keeping the end code clear wrt intent