Annotation of embedaddon/strongswan/src/libstrongswan/threading/rwlock.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 rwlock rwlock
        !            19:  * @{ @ingroup threading
        !            20:  */
        !            21: 
        !            22: #ifndef THREADING_RWLOCK_H_
        !            23: #define THREADING_RWLOCK_H_
        !            24: 
        !            25: typedef struct rwlock_t rwlock_t;
        !            26: typedef enum rwlock_type_t rwlock_type_t;
        !            27: 
        !            28: /**
        !            29:  * Type of read-write lock.
        !            30:  */
        !            31: enum rwlock_type_t {
        !            32:        /** default condvar */
        !            33:        RWLOCK_TYPE_DEFAULT = 0,
        !            34: };
        !            35: 
        !            36: /**
        !            37:  * Read-Write lock wrapper.
        !            38:  */
        !            39: struct rwlock_t {
        !            40: 
        !            41:        /**
        !            42:         * Acquire the read lock.
        !            43:         */
        !            44:        void (*read_lock)(rwlock_t *this);
        !            45: 
        !            46:        /**
        !            47:         * Acquire the write lock.
        !            48:         */
        !            49:        void (*write_lock)(rwlock_t *this);
        !            50: 
        !            51:        /**
        !            52:         * Try to acquire the write lock.
        !            53:         *
        !            54:         * Never blocks, but returns FALSE if the lock was already occupied.
        !            55:         *
        !            56:         * @return              TRUE if lock acquired
        !            57:         */
        !            58:        bool (*try_write_lock)(rwlock_t *this);
        !            59: 
        !            60:        /**
        !            61:         * Release any acquired lock.
        !            62:         */
        !            63:        void (*unlock)(rwlock_t *this);
        !            64: 
        !            65:        /**
        !            66:         * Destroy the read-write lock.
        !            67:         */
        !            68:        void (*destroy)(rwlock_t *this);
        !            69: };
        !            70: 
        !            71: /**
        !            72:  * Create a read-write lock instance.
        !            73:  *
        !            74:  * @param type         type of rwlock to create
        !            75:  * @return                     unlocked rwlock instance
        !            76:  */
        !            77: rwlock_t *rwlock_create(rwlock_type_t type);
        !            78: 
        !            79: #endif /** THREADING_RWLOCK_H_ @} */
        !            80: 

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