diff options
Diffstat (limited to 'SDL_Core/src/components/Utils/include/Utils/MultithreadingMap.h')
-rw-r--r-- | SDL_Core/src/components/Utils/include/Utils/MultithreadingMap.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/SDL_Core/src/components/Utils/include/Utils/MultithreadingMap.h b/SDL_Core/src/components/Utils/include/Utils/MultithreadingMap.h new file mode 100644 index 000000000..5a0f76a66 --- /dev/null +++ b/SDL_Core/src/components/Utils/include/Utils/MultithreadingMap.h @@ -0,0 +1,43 @@ +#ifndef MULTITHREADED_MAP_CLASS +#define MULTITHREADED_MAP_CLASS + +#include <map> + +template <typename T, typename K> class MultithreadingMap +{ +public: + MultithreadingMap(); + ~MultithreadingMap(); + + int size() const; + + bool empty() const; + + void insert( const std::pair<const T,K> & element ); + + K & find( const T & key ); + +private: + std::multimap<T,K> mMap; + + /** + *\brief Mutex for queue locking. + */ + mutable pthread_mutex_t mMutex; + +}; + +template <typename T, typename K> MultithreadingMap<T,K>::MultithreadingMap() : +mMutex( PTHREAD_MUTEX_INITIALIZER ) +{ + pthread_mutex_init( &mMutex, NULL ); +} + +template <typename T, typename K> MultithreadingMap<T,K>::~MultithreadingMap() +{ + pthread_mutex_destroy( &mMutex ); +} + + + +#endif // MULTITHREADED_MAP_CLASS
\ No newline at end of file |