3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
31 #ifndef __MsgThdSafeQ_H__
32 #define __MsgThdSafeQ_H__
38 template <typename T> class MsgThdSafeQ
44 void push_front(T const & input);
45 void push_back(T const & input);
55 mx variable guarantees atomic operation in multi-threaded environment.
56 For example, when a thread is executing Pop(), other threads
57 trying to execute one of Pop, Push, Size, Empty are locked.
60 template <typename T> void MsgThdSafeQ<T>::pop_front()
63 if( q.empty() ) return;
68 template <typename T> bool MsgThdSafeQ<T>::front(T* qItem)
71 if( qItem == NULL || q.empty() )
74 *qItem = q.front(); // copy
76 return true; // Success
80 template <typename T> void MsgThdSafeQ<T>::push_back(T const & qItem)
86 template <typename T> void MsgThdSafeQ<T>::push_front(T const & qItem)
93 template <typename T> int MsgThdSafeQ<T>::size()
99 template <typename T> bool MsgThdSafeQ<T>::empty()
101 MutexLocker lock(mx);
105 template <typename T> void MsgThdSafeQ<T>::clear()
107 MutexLocker lock(mx);
111 #endif // __MsgThdSafeQ_H__