Category : mutex

In this piece of code, where it is defined a class called Monitor that protects the data captured by a sensor: #include <iostream> #include <thread> #include <mutex> #include <condition_variable> #include <chrono> #include <cstdlib> #define SIZE_LOOP 1000 class Monitor { private: std::mutex m_mutex; std::condition_variable m_conditionVariable; bool m_isReady; public: Monitor() { init(); }; ~Monitor() { }; void ..

Read more

I would like in c++ to share a list between two processes. I would like very simple not by taking FIFO or Shared memory so i just use mutex and locks. I tried this way and its working : #include <string.h> #include <mutex> #include <iostream> #include <thread> #include <list> std::list<int> myList; std::mutex list_mutex; void client(){ ..

Read more