[jboss-cvs] JBossCache/src/org/jboss/cache/util ...
Vladmir Blagojevic
vladimir.blagojevic at jboss.com
Mon Jul 30 10:53:08 EDT 2007
User: vblagojevic
Date: 07/07/30 10:53:08
Added: src/org/jboss/cache/util ThreadGate.java
Log:
block dispatcher during FLUSH
Revision Changes Path
1.1 date: 2007/07/30 14:53:08; author: vblagojevic; state: Exp;JBossCache/src/org/jboss/cache/util/ThreadGate.java
Index: ThreadGate.java
===================================================================
package org.jboss.cache.util;
/**
* Copyright (c) 2005 Brian Goetz and Tim Peierls
* Released under the Creative Commons Attribution License
* (http://creativecommons.org/licenses/by/2.5)
* Official home: http://www.jcip.net
*
* ThreadGate <p/> Recloseable gate using wait and notifyAll
*
* @author Brian Goetz and Tim Peierls
*/
public class ThreadGate {
// CONDITION-PREDICATE: opened-since(n) (isOpen || generation>n)
private boolean isOpen;
private int generation;
public synchronized void close()
{
isOpen = false;
}
public synchronized void open()
{
++generation;
isOpen = true;
notifyAll();
}
// BLOCKS-UNTIL: opened-since(generation on entry)
public synchronized void await() throws InterruptedException
{
int arrivalGeneration = generation;
while(!isOpen && arrivalGeneration == generation)
wait();
}
// BLOCKS-UNTIL: opened-since(generation on entry)
public synchronized void await(long timeout) throws InterruptedException
{
int arrivalGeneration = generation;
while(!isOpen && arrivalGeneration == generation)
wait(timeout);
}
}
More information about the jboss-cvs-commits
mailing list