public class PrefSemaphore
extends java.lang.Object
The semaphore can be started or stopped by means of the setOn()
and
setOff()
methods, respectively. They set the trigger
attribute.
Moreover, it records the number of locks performed between two consecutive
calls to the waitChanges()
method. This functionality is useful
to control that threads attending to clients perhaps a new woi has been added
to the history, then the woi to be prefetched should be recomputed.
Usage example in threads that attend clients:
lock
unlock
Usage example in the prefetching thread:
waitChanges
await
changes
Modifier and Type | Field and Description |
---|---|
private int |
numLocks
Number of locks between two consecutive calls to the
waitChanges()
method. |
private int |
numThreads
Indicates the number of threads that are blocking.
|
private boolean |
trigger |
Constructor and Description |
---|
PrefSemaphore()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
acquire() |
void |
await()
Waits until the resource is free.
|
boolean |
changes() |
void |
list(java.io.PrintStream out)
Prints this Proxy Pref Semaphore out to the specified output stream.
|
void |
release() |
void |
resumePrefetching()
Indicates the prefetching thread can continue its execution.
|
void |
setOff()
Sets the trigger to
false , which stops the semaphore. |
void |
setOn()
Sets the trigger to
true , which starts the semaphore. |
void |
suspendPrefetching()
Indicates that the prefetching thread must be suspended.
|
java.lang.String |
toString() |
void |
waitChanges() |
private int numThreads
private boolean trigger
private int numLocks
waitChanges()
method.public void await()
java.lang.InterruptedException
public void setOn()
true
, which starts the semaphore.public void setOff()
false
, which stops the semaphore.public void waitChanges()
public boolean changes()
public void suspendPrefetching()
public void resumePrefetching()
public void acquire()
public void release()
public java.lang.String toString()
toString
in class java.lang.Object
public void list(java.io.PrintStream out)
out
- an output stream.
CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Group on Interactive Coding of Images (GICI) (contact)