Skip to content

Instantly share code, notes, and snippets.

View Totsugekitai's full-sized avatar
😅
!

Totsugekitai Totsugekitai

😅
!
  • Tokyo
  • 13:06 (UTC +09:00)
View GitHub Profile
@aras-p
aras-p / preprocessor_fun.h
Last active June 21, 2024 12:20
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@yohhoy
yohhoy / ticket_fair_mutex.cpp
Last active July 4, 2021 13:19
ticket-based fair mutex implementation
#include <condition_variable>
#include <mutex>
#include <thread>
class fair_mutex {
std::mutex mtx_;
std::condition_variable cv_;
unsigned int next_, curr_;
public: