not running

Dependencies:   TextLCD MQTT

Intersection.cpp

Committer:
hyan99
Date:
2019-12-11
Revision:
2:16b3bd337db2
Parent:
0:3b4906b8a747

File content as of revision 2:16b3bd337db2:

#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;
}