C++ | zero semaphore with comments
\n#include<semaphore.h>\nclass Foo {\npublic:\n    sem_t sem1;\n    sem_t sem2;\n    Foo() {\n        sem_init(&sem1,0,0);\n        sem_init(&sem2,0,0);\n      
```\n#include<semaphore.h>\nclass Foo {\npublic:\n    sem_t sem1;\n    sem_t sem2;\n    Foo() {\n        sem_init(&sem1,0,0);\n        sem_init(&sem2,0,0);\n        \n    }\n\n    void first(function<void()> printFirst) {\n        \n        printFirst();\n        sem_post(&sem1);// increased the value to 1 so now two can be executed\n    }\n\n    void second(function<void()> printSecond) {\n        \n        sem_wait(&sem1);//see  if the value of the semaphore is > 0 or not if it is then one already was printed\n        printSecond();\n        sem_post(&sem2);// printed two so now increased the value of the semaphore sem2\n    }\n\n    void third(function<void()> printThird) {\n        \n        sem_wait(&sem2);// if the value of the sem2 > 0 them two was already printed \n        printThird();\n    }\n};\n```
[]