001: /*
002: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: * [See end of file]
004: */
005:
006: /**
007: * A model lock.
008: * Critical section support for multithreaed access to a model
009: * within a single JVM. See also transactions support.
010: *
011: * Examples if application code:
012: * <pre>
013: * try {
014: * model.enterCriticalSection(ModelLock.READ) ;
015: * ...
016: * } finally { model.leaveCriticalSection() ; }
017: * </pre>
018: *
019: * Nested locks are provided for:
020: * <pre>
021: * try {
022: * model.enterCriticalSection(ModelLock.WRITE) ;
023: * libraryCall() ;
024: * ...
025: * } finally { model.leaveCriticalSection() ; }
026: *
027: * void libraryCall()
028: * {
029: * try {
030: * model.enterCriticalSection(ModelLock.READ) ;
031: * ... do library stuff ...
032: * } finally { model.leaveCriticalSection() ; }
033: * }
034: * </pre>
035: * Iterators should be used inside a critical section and not passed outside
036: * the concurrency controlled block.
037: * <pre>
038: * try {
039: * model.enterCriticalSection(ModelLock.READ) ;
040: * StmtIterator sIter = ... ;
041: * for ( ; sIter.next; )
042: * {
043: * ...
044: * }
045: * sIter.close() ;
046: * } finally { model.leaveCriticalSection() ; }
047: * </pre>
048: *
049: * Note that if a library operation needs a write lock, the application must either have no
050: * locks or a write lock when calling. Lock promotion is not supported - it can lead to
051: * deadlock.
052: *
053: * The hard work of locking is done by the
054: * <a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html">util.concurrent</a>.
055: * This is a convenience wrapper that provides nested locks, a special case of reentrant locks,
056: * that does some checking.
057: *
058: * @author Andy Seaborne
059: * @version $Id: ModelLock.java,v 1.8 2008/01/02 12:05:47 andy_seaborne Exp $
060: */package com.hp.hpl.jena.rdf.model;
061:
062: import com.hp.hpl.jena.shared.Lock;
063:
064: /**
065: * @deprecated For naming compatibility - use Lock interface instead
066: */
067:
068: public interface ModelLock extends Lock {
069: /** Descriptive name for lock requests - read lock */
070: public static final boolean READ = Lock.READ;
071:
072: /** Descriptive name for lock requests - write lock */
073: public static final boolean WRITE = Lock.WRITE;
074: }
075:
076: /*
077: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
078: * All rights reserved.
079: *
080: * Redistribution and use in source and binary forms, with or without
081: * modification, are permitted provided that the following conditions
082: * are met:
083: * 1. Redistributions of source code must retain the above copyright
084: * notice, this list of conditions and the following disclaimer.
085: * 2. Redistributions in binary form must reproduce the above copyright
086: * notice, this list of conditions and the following disclaimer in the
087: * documentation and/or other materials provided with the distribution.
088: * 3. The name of the author may not be used to endorse or promote products
089: * derived from this software without specific prior written permission.
090: *
091: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
092: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
093: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
094: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
095: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
096: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
097: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
098: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
099: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
100: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101: */
|