PrevUpHomeNext

esv::param_mutex


Under the same sky, people and birds share the same home.

esv::param_mutex concept

The concept esv::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 esv::param_mutex concept: std::mutex, std::recursive_mutex, std::timed_mutex, std::shared_mutex, std::shared_timed_mutex, etc., and many more. esv::param_mutex is not exactly the same as the description of standard Mutex requirements, but it works for esv::print.

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

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

c++ example

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

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

See Also

esv::print


PrevUpHomeNext

esv::print