not running

Dependencies:   TextLCD MQTT

Committer:
hyan99
Date:
Tue Dec 10 22:29:09 2019 +0000
Revision:
0:3b4906b8a747
error

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hyan99 0:3b4906b8a747 1 #include "Intersection.h"
hyan99 0:3b4906b8a747 2
hyan99 0:3b4906b8a747 3 void Intersection::add_to_q(AccCar* car) {
hyan99 0:3b4906b8a747 4 qmutex.lock();
hyan99 0:3b4906b8a747 5 crossQ.push(car);
hyan99 0:3b4906b8a747 6 qmutex.unlock();
hyan99 0:3b4906b8a747 7 }
hyan99 0:3b4906b8a747 8
hyan99 0:3b4906b8a747 9 void Intersection::remove_from_q() {
hyan99 0:3b4906b8a747 10 qmutex.lock();
hyan99 0:3b4906b8a747 11 crossQ.pop();
hyan99 0:3b4906b8a747 12 qmutex.unlock();
hyan99 0:3b4906b8a747 13 }
hyan99 0:3b4906b8a747 14
hyan99 0:3b4906b8a747 15 bool Intersection::can_cross(AccCar* car) {
hyan99 0:3b4906b8a747 16 // FCFS
hyan99 0:3b4906b8a747 17 qmutex.lock();
hyan99 0:3b4906b8a747 18 if(crossQ.front() == car) {
hyan99 0:3b4906b8a747 19 qmutex.unlock();
hyan99 0:3b4906b8a747 20 return true;
hyan99 0:3b4906b8a747 21 }
hyan99 0:3b4906b8a747 22 qmutex.unlock();
hyan99 0:3b4906b8a747 23 return false;
hyan99 0:3b4906b8a747 24 }