Annotation of embedaddon/strongswan/src/libstrongswan/threading/mutex.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2008-2009 Tobias Brunner
        !             3:  * Copyright (C) 2008 Martin Willi
        !             4:  * HSR Hochschule fuer Technik Rapperswil
        !             5:  *
        !             6:  * This program is free software; you can redistribute it and/or modify it
        !             7:  * under the terms of the GNU General Public License as published by the
        !             8:  * Free Software Foundation; either version 2 of the License, or (at your
        !             9:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !            10:  *
        !            11:  * This program is distributed in the hope that it will be useful, but
        !            12:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            13:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            14:  * for more details.
        !            15:  */
        !            16: 
        !            17: /**
        !            18:  * @defgroup mutex mutex
        !            19:  * @{ @ingroup threading
        !            20:  */
        !            21: 
        !            22: #ifndef THREADING_MUTEX_H_
        !            23: #define THREADING_MUTEX_H_
        !            24: 
        !            25: typedef struct mutex_t mutex_t;
        !            26: typedef enum mutex_type_t mutex_type_t;
        !            27: 
        !            28: /**
        !            29:  * Type of mutex.
        !            30:  */
        !            31: enum mutex_type_t {
        !            32:        /** default mutex */
        !            33:        MUTEX_TYPE_DEFAULT      = 0,
        !            34:        /** allow recursive locking of the mutex */
        !            35:        MUTEX_TYPE_RECURSIVE    = 1,
        !            36: };
        !            37: 
        !            38: /**
        !            39:  * Mutex wrapper implements simple, portable and advanced mutex functions.
        !            40:  */
        !            41: struct mutex_t {
        !            42: 
        !            43:        /**
        !            44:         * Acquire the lock to the mutex.
        !            45:         */
        !            46:        void (*lock)(mutex_t *this);
        !            47: 
        !            48:        /**
        !            49:         * Release the lock on the mutex.
        !            50:         */
        !            51:        void (*unlock)(mutex_t *this);
        !            52: 
        !            53:        /**
        !            54:         * Destroy a mutex instance.
        !            55:         */
        !            56:        void (*destroy)(mutex_t *this);
        !            57: };
        !            58: 
        !            59: /**
        !            60:  * Create a mutex instance.
        !            61:  *
        !            62:  * @param type         type of mutex to create
        !            63:  * @return                     unlocked mutex instance
        !            64:  */
        !            65: mutex_t *mutex_create(mutex_type_t type);
        !            66: 
        !            67: #endif /** THREADING_MUTEX_H_ @} */
        !            68: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>