Annotation of XNU/iokit/Kernel/IOSyncer.cpp, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: /* IOSyncer.cpp created by wgulland on 2000-02-02 */
        !            23: 
        !            24: #include <IOKit/IOLib.h>
        !            25: #include <IOKit/IOSyncer.h>
        !            26: 
        !            27: OSDefineMetaClassAndStructors(IOSyncer, OSObject)
        !            28: 
        !            29: IOSyncer * IOSyncer::create(bool twoRetains)
        !            30: {
        !            31:     IOSyncer * me = new IOSyncer;
        !            32: 
        !            33:     if (me && !me->init(twoRetains)) {
        !            34:         me->release();
        !            35:         return 0;
        !            36:     }
        !            37: 
        !            38:     return me;
        !            39: }
        !            40: 
        !            41: bool IOSyncer::init(bool twoRetains)
        !            42: {
        !            43:     if (!OSObject::init())
        !            44:         return false;
        !            45: 
        !            46:     fLock = lock_alloc(true, NULL, NULL);
        !            47: 
        !            48:     if(!fLock)
        !            49:        return false;
        !            50: 
        !            51:     lock_write(fLock);
        !            52:     if(twoRetains)
        !            53:        retain();
        !            54: 
        !            55:     return true;
        !            56: }
        !            57: 
        !            58: void IOSyncer::reinit()
        !            59: {
        !            60:     lock_write(fLock);
        !            61: }
        !            62: 
        !            63: void IOSyncer::free()
        !            64: {
        !            65:     if(fLock)
        !            66:        lock_free(fLock);
        !            67:     OSObject::free();
        !            68: }
        !            69: 
        !            70: IOReturn IOSyncer::wait(bool autoRelease = true)
        !            71: {
        !            72:     IOReturn result;
        !            73:     lock_write(fLock);
        !            74:     lock_done(fLock);
        !            75:     result = fResult;  // Pick up before auto deleting!
        !            76:     if(autoRelease)
        !            77:        release();
        !            78:     return result;
        !            79: }
        !            80: 
        !            81: void IOSyncer::signal(IOReturn res = kIOReturnSuccess,
        !            82:                                        bool autoRelease = true)
        !            83: {
        !            84:     fResult = res;
        !            85:     lock_done(fLock);
        !            86:     if(autoRelease)
        !            87:        release();
        !            88: }
        !            89: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.