
not running
Diff: Intersection.cpp
- Revision:
- 0:3b4906b8a747
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Intersection.cpp Tue Dec 10 22:29:09 2019 +0000 @@ -0,0 +1,24 @@ +#include "Intersection.h" + +void Intersection::add_to_q(AccCar* car) { + qmutex.lock(); + crossQ.push(car); + qmutex.unlock(); +} + +void Intersection::remove_from_q() { + qmutex.lock(); + crossQ.pop(); + qmutex.unlock(); +} + +bool Intersection::can_cross(AccCar* car) { + // FCFS + qmutex.lock(); + if(crossQ.front() == car) { + qmutex.unlock(); + return true; + } + qmutex.unlock(); + return false; +}