Mutex extension.

Rework of the #568.