src/cdrom/macosx/SDLOSXCAGuard.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 09 Mar 2006 06:33:21 +0000
changeset 1487 dc6b59e925a2
parent 1402 d910939febfa
child 1662 782fd950bd46
child 1895 c121d94672cb
child 4159 a1b03ba2fcd0
permissions -rw-r--r--
Cleaning up warnings on MacOS X
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2004 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Library General Public
     7     License as published by the Free Software Foundation; either
     8     version 2 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Library General Public License for more details.
    14 
    15     You should have received a copy of the GNU Library General Public
    16     License along with this library; if not, write to the Free
    17     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 /*  
    25     Note: This file hasn't been modified so technically we have to keep the disclaimer :-(
    26 
    27 
    28     Copyright:  © Copyright 2002 Apple Computer, Inc. All rights reserved.
    29 
    30     Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
    31             ("Apple") in consideration of your agreement to the following terms, and your
    32             use, installation, modification or redistribution of this Apple software
    33             constitutes acceptance of these terms.  If you do not agree with these terms,
    34             please do not use, install, modify or redistribute this Apple software.
    35 
    36             In consideration of your agreement to abide by the following terms, and subject
    37             to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
    38             copyrights in this original Apple software (the "Apple Software"), to use,
    39             reproduce, modify and redistribute the Apple Software, with or without
    40             modifications, in source and/or binary forms; provided that if you redistribute
    41             the Apple Software in its entirety and without modifications, you must retain
    42             this notice and the following text and disclaimers in all such redistributions of
    43             the Apple Software.  Neither the name, trademarks, service marks or logos of
    44             Apple Computer, Inc. may be used to endorse or promote products derived from the
    45             Apple Software without specific prior written permission from Apple.  Except as
    46             expressly stated in this notice, no other rights or licenses, express or implied,
    47             are granted by Apple herein, including but not limited to any patent rights that
    48             may be infringed by your derivative works or by other works in which the Apple
    49             Software may be incorporated.
    50 
    51             The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
    52             WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
    53             WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    54             PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
    55             COMBINATION WITH YOUR PRODUCTS.
    56 
    57             IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
    58             CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
    59             GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    60             ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
    61             OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
    62             (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
    63             ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    64 */
    65 /*=============================================================================
    66     CAGuard.h
    67 
    68 =============================================================================*/
    69 #if !defined(__CAGuard_h__)
    70 #define __CAGuard_h__
    71 
    72 /*=============================================================================
    73     Includes
    74   =============================================================================*/
    75 
    76 #include <CoreAudio/CoreAudioTypes.h>
    77 #include <pthread.h>
    78 
    79 
    80 /*=============================================================================
    81     CAGuard
    82   
    83     This is your typical mutex with signalling implemented via pthreads.
    84     Lock() will return true if and only if the guard is locked on that call.
    85     A thread that already has the guard will receive 'false' if it locks it
    86     again. Use of the stack-based CAGuard::Locker class is highly recommended
    87     to properly manage the recursive nesting. The Wait calls with timeouts
    88     will return true if and only if the timeout period expired. They will
    89     return false if they receive notification any other way.
    90   =============================================================================*/
    91 
    92 typedef struct S_SDLOSXCAGuard
    93 {
    94 
    95 /*  Construction/Destruction */
    96 /*public:*/
    97 /*  Actions */
    98 /*public:*/
    99     int     (*Lock)(struct S_SDLOSXCAGuard *cag);
   100     void    (*Unlock)(struct S_SDLOSXCAGuard *cag);
   101     int     (*Try)(struct S_SDLOSXCAGuard *cag, int *outWasLocked);    /* returns true if lock is free, false if not */
   102     void    (*Wait)(struct S_SDLOSXCAGuard *cag);
   103     void    (*Notify)(struct S_SDLOSXCAGuard *cag);
   104 
   105 /*  Implementation */
   106 /*protected:*/
   107     pthread_mutex_t mMutex;
   108     pthread_cond_t  mCondVar;
   109     pthread_t       mOwner;
   110 } SDLOSXCAGuard;
   111 
   112 SDLOSXCAGuard *new_SDLOSXCAGuard(void);
   113 void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag);
   114 
   115 #endif
   116