PrevUpHomeNext

utx::mutex0~9


utx::mutex0~9

utx::mutex0~9 are ten std::mutex objects, which are used as pre-created mutexes directly, then users do not have to declare mutexes any more. These utx::mutexes save us lots of jobs.

To guard same resources against different threads, the same mutex should be used.

c++ example

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

int main()
{
	auto f1 = utx::async(
		[]
		{
			for (utx::ix32 i=0; i<10; ++i)
			{
				std::unique_lock lock{utx::mutex0};
				utx::print("i is ", i);
			}
		}
	);
	auto f2 = utx::async(
		[]
		{
			for (char i='A'; i<='G'; ++i)
			{
				std::unique_lock lock{utx::mutex0};
				utx::print("char i is ", i);
			}
		}
	);
}

See Also

utx::async

utx::deferred

utx::ydzs

utx::print


PrevUpHomeNext

utx::print

esv::print