1 /*! ========================================================================
2 ** Extended Template and Library
3 ** Mutex Abstraction Class Implementation
6 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
7 ** Copyright (c) 2008 Chris Moore
9 ** This package is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU General Public License as
11 ** published by the Free Software Foundation; either version 2 of
12 ** the License, or (at your option) any later version.
14 ** This package is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** General Public License for more details.
19 ** === N O T E S ===========================================================
21 ** This is an internal header file, included by other ETL headers.
22 ** You should not attempt to use it directly.
24 ** ========================================================================= */
26 /* === S T A R T =========================================================== */
28 #ifndef __ETL__MUTEX_PTHREADS_SIMPLE_H_
29 #define __ETL__MUTEX_PTHREADS_SIMPLE_H_
31 /* === H E A D E R S ======================================================= */
35 /* === M A C R O S ========================================================= */
37 /* === C L A S S E S & S T R U C T S ======================================= */
45 mutex() { pthread_mutex_init(&mtx,NULL); }
46 ~mutex() { pthread_mutex_destroy(&mtx); }
47 void lock_mutex() { pthread_mutex_lock(&mtx); }
48 void unlock_mutex() { pthread_mutex_unlock(&mtx); }
50 //! Exception-safe mutex lock class
55 lock(mutex &x):_mtx(&x) { _mtx->lock_mutex(); }
56 ~lock() { _mtx->unlock_mutex(); }
62 /* === E N D =============================================================== */