There’s this command called mutex, what does it do? I don’t see it used anywhere, at all.
That has to be used in cunjunction with command parallel
.
In a command pipeline that is run in parallel, this allows to ensure that only a single thread has access to a resource that could be shared otherwise, and that could cause problem if accessed in parallel, like writing a file on the disk for instance.
It then implements a system of Mutual Exclusion.
This is an example of use:
foo :
com_bad="sp ? o. tmp.png rm."
com_good="mutex 1 sp ? o. tmp.png rm. mutex 1,0"
# com=$com_bad # Bad: possibly multiple threads trying to output file at the same time
com=$com_good # Good : Locked mutex ensure threads write output file sequentially
parallel $com,$com,$com,$com
Thinking about this: I find mutex
actually quite useless as it is.
As you said, it’s used nowhere in the stdlib, and my guess is that it could be replaced by the use of critical()
function inside the math parser.
I really wonder if it needs to be kept.
It’s nowhere on gmic-community, nor examples either. The reason I brought this up is the possibility of a upgrade to my interactive filters, but I already have things like apply_parallel and parallel to perform tasks on parallel. I just did apply_parallel recently.
I would vote no, but if I need it, I will raise the issue back anyway. It’s not that hard to find copies if the needs arise.