PrevUpHomeNext

utx::param_mutex


utx::param_mutex concept

The concept utx::param_mutex is used to constrain and match a lockable mutex, to require a type of a mutex satisfy basic standard Mutex requirements. These types satisfy utx::param_mutex concept: std::mutex, std::recursive_mutex, std::timed_mutex, std::shared_mutex, std::shared_timed_mutex, etc., and many more. utx::param_mutex is not exactly the same as the description of standard Mutex requirements, but it works for utx::print.

utx::param_mutex is designed for utx::print at first, but it can be used for other multithread programming too.

By passing a mutex object to utx::print, that mutex will be locked and unlocked inside utx::print, so make sure the mutex status is unlock when calling utx::print with the mutex, unless it is a Recursive-Mutex, otherwise it's deadlock.

c++ example

#include <utxcpp/core.hpp>
#include <utxcpp/thread.hpp>

int main()
{
	std::mutex mutex;
	auto f1 = utx::async(
		[&mutex]
		{
			// mutex type is constrained by utx::param_mutex of operator() of utx::print.
			utx::print(mutex, "Hell", "World!", 3.3);
		}
	);
}

See Also

utx::print


PrevUpHomeNext

utx::print