← udacity portfolio
cpp nd · systems cpp · March 2020

Concurrent Traffic Light Simulator

Multi-threaded traffic-intersection simulator in C++17 — the C++ nanodegree's capstone on concurrency, futures, and message queues.

What it did

Capstone of the C++ nanodegree’s concurrency module. Simulate a city where each vehicle is a thread, each intersection is a thread, each traffic light is a thread, and they coordinate via a templated MessageQueue<T> blocking on std::condition_variable. Render the simulation in real-time via OpenCV’s window API.

The architecture

What was actually tricky

What I’d do differently with hindsight

What it taught me

Concurrency in C++ is mostly about contracts: which thread owns which data, who can read what when. The actual mutex and condition_variable are mechanical once the ownership graph is clear. Get the ownership wrong and you’ll spend hours chasing races no debugger can catch. Hours which I did, in fact, spend.


Source archive: Shivam-Bhardwaj/traffic-light-simulator (archived)
Writeup last touched: 2026-05-22