fork download
  1. #include <mutex>
  2. #include <vector>
  3.  
  4. std::mutex protectBuffer;
  5. std::vector<int> somevector;
  6.  
  7. void myfunction(int data)
  8. {
  9. (void) (std::lock_guard<std::mutex> (protectBuffer));
  10. somevector.push_back(data);
  11. }
  12.  
  13. int main()
  14. {
  15. myfunction(3);
  16. }
  17.  
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty