Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

cpp mutex

#include <mutex>
#include <vector>
std::mutex door;    // mutex declaration
std::vector<int> v; // shared data
door.lock();
/*-----------------------*/
/* This is a thread-safe zone: just one thread at the time allowed
 * 
 * Unique ownership of vector v guaranteed 
 */
/*-----------------------*/
door.unlock();
Source by medium.com #
 
PREVIOUS NEXT
Tagged: #cpp #mutex
ADD COMMENT
Topic
Name
9+5 =