SUMO - Simulation of Urban MObility
MFXEventQue.cpp
Go to the documentation of this file.
00001 /****************************************************************************/
00007 // missing_desc
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This file is part of SUMO.
00014 //   SUMO is free software: you can redistribute it and/or modify
00015 //   it under the terms of the GNU General Public License as published by
00016 //   the Free Software Foundation, either version 3 of the License, or
00017 //   (at your option) any later version.
00018 //
00019 /****************************************************************************/
00020 
00021 
00022 // ===========================================================================
00023 // included modules
00024 // ===========================================================================
00025 #ifdef _MSC_VER
00026 #include <windows_config.h>
00027 #else
00028 #include <config.h>
00029 #endif
00030 
00031 #include "MFXEventQue.h"
00032 #include <cassert>
00033 
00034 #ifdef CHECK_MEMORY_LEAKS
00035 #include <foreign/nvwa/debug_new.h>
00036 #endif // CHECK_MEMORY_LEAKS
00037 
00038 void*
00039 MFXEventQue::top() {
00040     assert(size() != 0);
00041     myMutex.lock();
00042     void* ret = *(myEvents.begin());
00043     myMutex.unlock();
00044     return ret;
00045 }
00046 
00047 
00048 void
00049 MFXEventQue::pop() {
00050     myMutex.lock();
00051     myEvents.erase(myEvents.begin());
00052     myMutex.unlock();
00053 }
00054 
00055 
00056 void
00057 MFXEventQue::add(void* what) {
00058     myMutex.lock();
00059     myEvents.push_back(what);
00060     myMutex.unlock();
00061 }
00062 
00063 
00064 size_t
00065 MFXEventQue::size() {
00066     myMutex.lock();
00067     size_t msize = myEvents.size();
00068     myMutex.unlock();
00069     return msize;
00070 }
00071 
00072 
00073 bool
00074 MFXEventQue::empty() {
00075     myMutex.lock();
00076     bool ret = size() == 0;
00077     myMutex.unlock();
00078     return ret;
00079 }
00080 
00081 
00082 
00083 /****************************************************************************/
00084 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines