simplest code c++. only 3 steps
\nmutex mu[5];\nclass DiningPhilosophers {\npublic:\n    DiningPhilosophers() {\n        \n    }\n\n    void wantsToEat(int philosopher,\n                    fu
```\nmutex mu[5];\nclass DiningPhilosophers {\npublic:\n    DiningPhilosophers() {\n        \n    }\n\n    void wantsToEat(int philosopher,\n                    function<void()> pickLeftFork,\n                    function<void()> pickRightFork,\n                    function<void()> eat,\n                    function<void()> putLeftFork,\n                    function<void()> putRightFork) {\n        \n\t\t// philosopher i has access to fork i and (i+1)%5.\n\t\t\n\t\t//lock mutex for fork\n        std::lock(mu[philosopher], mu[(philosopher+1)%5]);\n\t\t\n\t\t// do task - order of left,right is not important\n        pickLeftFork(); pickRightFork(); eat(); putLeftFork(); putRightFork();\n\t\t\n\t\t//unlock mutex for fork\n        mu[philosopher].unlock(); mu[(philosopher+1)%5].unlock();\n    }\n};\n```
[]