A multithreaded pizza restaurant simulation in C++ using std::thread, std::mutex, and std::condition_variable.
The program simulates a pizza restaurant with multiple roles working in parallel:
- Waiters — receive orders from customers
- Chefs — cook pizzas
- Delivery Drivers — deliver finished pizzas
All processes are synchronized through queues and condition variables.
- ✅ 7+ parallel threads (2 waiters, 3 chefs, 2 delivery drivers)
- ✅ Synchronization via
std::condition_variable - ✅ Thread-safe queues with
std::mutex - ✅ Atomic order counter (
std::atomic) - ✅ Time measurement with
std::chrono - ✅ Detailed statistics after shutdown
- ✅ Colored terminal output (ANSI codes)
- C++11/14 (thread, mutex, condition_variable, atomic, chrono)
- ANSI Escape Codes for colored output
- Producer-Consumer Pattern for queues
After completion, the program displays:
- Number of received/cooked/delivered orders
- Average cooking and delivery time
- Productivity of each chef
- Popularity of pizza types
Open the project in Visual Studio and press F5 (Run).
pizza-restaurant/
├── manager.cpp # Main file
├── Order.h # Order structure
├── OrderQueue.h/cpp # Thread-safe queue
├── Waiter.h/cpp # Waiters
├── Chef.h/cpp # Chefs
├── Delivery.h/cpp # Delivery drivers
├── Statistics.h/cpp # Statistics collection
├── Colors.h # ANSI codes for colors
├── README.md # Documentation
└── screenshots/
└── demo1.png/demo2.png # Screenshots
- Working with
std::threadand thread lifecycle management - Synchronization using
std::mutexandstd::condition_variable - Avoiding race conditions and deadlocks
- Producer-Consumer pattern implementation
- Using
std::atomicfor thread-safe operations - Time measurement with
std::chrono
MIT License — free to use and modify.
Oleksandr Kopii — https://github.com/SamuraiSanch

