How to assert if a std::mutex is locked?

Strictly speaking, the question was about checking the lockedness of std::mutex directly. However, if encapsulating it in a new class is allowed, it’s very easy to do so: class mutex : public std::mutex { public: #ifndef NDEBUG void lock() { std::mutex::lock(); m_holder = std::this_thread::get_id(); } #endif // #ifndef NDEBUG #ifndef NDEBUG void unlock() { m_holder … Read more

OpenGL without X.org in linux

Update (Sep. 17, 2017): NVIDIA recently published an article detailing how to use OpenGL on headless systems, which is a very similar use case as the question describes. In summary: Link to libOpenGL.so and libEGL.so instead of libGL.so. (Your linker options should therefore be -lOpenGL -lEGL Call eglGetDisplay, then eglInitialize to initialize EGL. Call eglChooseConfig … Read more

Ruby 1.9.2 and Rails 3 cannot open rails console

Apparently ubuntu and ruby don’t always catch dependencies like they should. From the first google hit (yeah, I clicked on this stack-overflow in place #2 before checking out the first result.) Navigate to the Ruby source and enter: sudo apt-get install libreadline5-dev cd ext/readline ruby extconf.rb make sudo make install So, if you’re on another … Read more