<-E 1114> Print in Order
class Foo {
public:
Foo() {
pthread_mutex_lock(&m_second);
pthread_mutex_lock(&m_third);
}
~Foo() {
pthread_mutex_destroy(&m_second);
pthread_mutex_destroy(&m_third);
}
void first(function<void()> printFirst) {
// printFirst() outputs "first". Do not change or remove this line.
printFirst();
pthread_mutex_unlock(&m_second);
}
void second(function<void()> printSecond) {
// printSecond() outputs "second". Do not change or remove this line.
pthread_mutex_lock(&m_second);
printSecond();
pthread_mutex_unlock(&m_third);
}
void third(function<void()> printThird) {
// printThird() outputs "third". Do not change or remove this line.
pthread_mutex_lock(&m_third);
printThird();
}
private:
pthread_mutex_t m_second = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t m_third = PTHREAD_MUTEX_INITIALIZER;
};