R
- the type of the requestpublic class ViewHandler<R> extends Object
Modifier and Type | Field and Description |
---|---|
protected AtomicInteger |
count |
protected GMS |
gms |
protected BoundedList<String> |
history |
protected Lock |
lock |
protected boolean |
processing |
protected Condition |
processing_done |
protected BiPredicate<R,R> |
req_matcher |
protected Consumer<Collection<R>> |
req_processor |
protected Collection<R> |
requests |
protected AtomicBoolean |
suspended |
Constructor and Description |
---|
ViewHandler(GMS gms,
Consumer<Collection<R>> req_processor,
BiPredicate<R,R> req_matcher)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
_add(R... reqs) |
protected boolean |
_add(R req) |
ViewHandler<R> |
add(R... reqs) |
ViewHandler<R> |
add(R req) |
String |
dumpHistory() |
String |
dumpQueue() |
protected Log |
log() |
protected void |
process(Collection<R> requests)
We're guaranteed that only one thread will be called with this method at any time
|
protected void |
removeAndProcess(Collection<R> requests)
Removes requests as long as they match - breaks at the first non-matching request or when requests is empty
This method must catch all exceptions; or else process() might return without setting processing to true again!
|
void |
resume() |
protected boolean |
setProcessing(boolean flag) |
int |
size() |
void |
suspend()
Clears the queue and discards new requests from now on
|
boolean |
suspended() |
String |
toString() |
void |
waitUntilComplete()
Blocks the caller until the current set of requests being processed have been completed.
|
void |
waitUntilComplete(long timeout)
Blocks the caller until the current set of requests being processed have been completed, or the timeout
elapsed.
Returns immediately if no requests are currently being processed |
protected final Collection<R> requests
protected final Lock lock
protected final AtomicInteger count
protected final AtomicBoolean suspended
protected boolean processing
protected final Condition processing_done
protected final GMS gms
protected final Consumer<Collection<R>> req_processor
protected final BiPredicate<R,R> req_matcher
protected final BoundedList<String> history
public ViewHandler(GMS gms, Consumer<Collection<R>> req_processor, BiPredicate<R,R> req_matcher)
gms
- The ref to GMSreq_processor
- A request processor which processes a list of requestsreq_matcher
- The matcher which determines whether any given 2 requests can be processed togetherpublic boolean suspended()
public int size()
public ViewHandler<R> add(R req)
public ViewHandler<R> add(R... reqs)
public void suspend()
public void resume()
public void waitUntilComplete()
public void waitUntilComplete(long timeout)
timeout
- Max time to wait in millisecondspublic String dumpQueue()
public String dumpHistory()
protected Log log()
protected boolean setProcessing(boolean flag)
protected boolean _add(R req)
protected boolean _add(R... reqs)
protected void process(Collection<R> requests)
protected void removeAndProcess(Collection<R> requests)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.