This is project Stage2
Bsed on project stage1, this project add functions, which comunicates between vehicles and intersection to ensure one intersection pass one vehicle one time.
- cmake >= 2.8
- All OSes: click here for installation instructions
- make >= 4.1 (Linux, Mac), 3.81 (Windows)
- Linux: make is installed by default on most Linux distros
- Mac: install Xcode command line tools to get make
- Windows: Click here for installation instructions
- OpenCV >= 4.1
- The OpenCV 4.1.0 source code can be found here
- gcc/g++ >= 5.4
- Linux: gcc / g++ is installed by default on most Linux distros
- Mac: same deal as make - install Xcode command line tools
- Windows: recommend using MinGW
Windows: recommend using MinGW
make
build
director in top location of project file, then domake.. && make
, after build completed using command./traffic_simulation
to run.
- Clone this repo.
- Make a build directory in the top level directory:
mkdir build && cd build
- Compile:
cmake .. && make
- Run it:
./traffic_simulation
.
-
Task L2.1 : In method
Vehicle::drive()
, start up a task usingstd::async
which takes a reference to the methodIntersection::addVehicleToQueue
, the object_currDestination
and a shared pointer to this using theget_shared_this()
function. Then, wait for the data to be available before proceeding to slow down. -
Task L2.2 : In method
Intersection::addVehicleToQueue()
, add the new vehicle to the waiting line by creating a promise, a corresponding future and then adding both to_waitingVehicles
. Then wait until the vehicle has been granted entry. -
Task L2.3 : In method
WaitingVehicles::permitEntryToFirstInQueue()
, get the entries from the front of_promises
and_vehicles
. Then, fulfill promise and send signal back that permission to enter has been granted. Finally, remove the front elements from both queues.