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 __MSG_MUTEX_H__
32 #define __MSG_MUTEX_H__
34 /*==================================================================================================
36 ==================================================================================================*/
45 void WaitMsgReady(int sec);
50 Mutex(){ pthread_mutex_init(&m, 0); }
51 void lock(){ pthread_mutex_lock(&m); }
52 void unlock(){ pthread_mutex_unlock(&m); }
53 pthread_mutex_t* pMutex() { return &m; }
62 MutexLocker(Mutex& mx)
80 CndVar(){ pthread_cond_init(&c, 0); }
81 void wait(pthread_mutex_t* m) { pthread_cond_wait(&c, m); }
82 int timedwait(pthread_mutex_t* m, int sec)
84 struct timeval now = {0};
85 struct timespec timeout = {0};
86 gettimeofday(&now, NULL);
87 timeout.tv_sec = now.tv_sec+sec;
88 timeout.tv_nsec = now.tv_usec;
89 int retcode = pthread_cond_timedwait(&c, m, &timeout);
92 void signal(){ pthread_cond_signal(&c); }
93 void broadcast(){ pthread_cond_broadcast(&c); }