Lockable.cc revision f3aaec0a97c3584095582719a0149d5e94c06ea2
6a67d144095c31bbafed93cec1619590157335eajvergara * CDDL HEADER START
6a67d144095c31bbafed93cec1619590157335eajvergara * The contents of this file are subject to the terms of the
6a67d144095c31bbafed93cec1619590157335eajvergara * Common Development and Distribution License (the "License").
6a67d144095c31bbafed93cec1619590157335eajvergara * You may not use this file except in compliance with the License.
6a67d144095c31bbafed93cec1619590157335eajvergara * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6a67d144095c31bbafed93cec1619590157335eajvergara * See the License for the specific language governing permissions
6a67d144095c31bbafed93cec1619590157335eajvergara * and limitations under the License.
6a67d144095c31bbafed93cec1619590157335eajvergara * When distributing Covered Code, include this CDDL HEADER in each
6a67d144095c31bbafed93cec1619590157335eajvergara * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6a67d144095c31bbafed93cec1619590157335eajvergara * If applicable, add the following below this CDDL HEADER, with the
6a67d144095c31bbafed93cec1619590157335eajvergara * fields enclosed by brackets "[]" replaced with your own identifying
6a67d144095c31bbafed93cec1619590157335eajvergara * information: Portions Copyright [yyyy] [name of copyright owner]
6a67d144095c31bbafed93cec1619590157335eajvergara * CDDL HEADER END
6a67d144095c31bbafed93cec1619590157335eajvergara * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
6a67d144095c31bbafed93cec1619590157335eajvergara * Use is subject to license terms.
6a67d144095c31bbafed93cec1619590157335eajvergarausing namespace std;
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Create a lockable instance and initialize internal locks
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Free up a lockable instance
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Unlock the instance
6a67d144095c31bbafed93cec1619590157335eajvergara * @precondition This thread must have locked the instance
6a67d144095c31bbafed93cec1619590157335eajvergara * @postcondition The instance will be unlocked
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Unlock a given mutex lock
6a67d144095c31bbafed93cec1619590157335eajvergara * @precondition The lock must be held by this thread
6a67d144095c31bbafed93cec1619590157335eajvergara * @postcondition The lock will be released
6a67d144095c31bbafed93cec1619590157335eajvergara * @param myMutex The lock to unlock
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Lock the instance
6a67d144095c31bbafed93cec1619590157335eajvergara * @postcondition The lock will be held by this thread.
6a67d144095c31bbafed93cec1619590157335eajvergara * @memo Lock the given mutex lock
6a67d144095c31bbafed93cec1619590157335eajvergara * @postcondition The lock will be held by this thread
6a67d144095c31bbafed93cec1619590157335eajvergara * @param myMutex The mutex lock to take
6a67d144095c31bbafed93cec1619590157335eajvergara cerr << "Lock failed: " <<strerror(status) << endl;
6a67d144095c31bbafed93cec1619590157335eajvergara break; // Lock taken succesfully