// Example program
#include <iostream>
#include <string>
#include <mutex>
#include <map>
#include <thread>

struct sObjectInfo {
    std::mutex mut;
};

std::map<int, sObjectInfo*> mymap;

void foo() {
    std::unique_lock<std::mutex> ulock(mymap[0]->mut, std::defer_lock);
    if (ulock.try_lock()) {
        std::cout << "locked.." << std::endl;
    }
    else {
        std::cout << "cant lock" << std::endl;
    }
}

int main()
{
  sObjectInfo* s1 = new sObjectInfo();
  sObjectInfo* s2 = new sObjectInfo();
  
  mymap[0] = s1;
  mymap[1] = s2;
  
  std::thread t1(foo);
  t1.join();
}
