PrevUpHomeNext

esv::mutex0~9


Be a good friend of animals.

esv::mutex0~9

esv::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 esv::mutexes save us lots of jobs.

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

c++ example

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

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

See Also

esv::async

esv::deferred

esv::ydzs

esv::print


PrevUpHomeNext

E