T
- The generic type of the thread-local object.public abstract class ThreadLocalBufferFactory<T extends IBuffer<E>,E> extends Object
Note: This implementation uses a true thread local buffers managed by a
ConcurrentHashMap
. This approach has approximately 3x higher
concurrency than striped locks. The advantage of striped locks is that you
can directly manage the #of buffers when when the threads using those buffers
is unbounded. However, doing so could lead to deadlock since two threads can
be hashed onto the same buffer object.
Modifier | Constructor and Description |
---|---|
protected |
ThreadLocalBufferFactory() |
protected |
ThreadLocalBufferFactory(int initialCapacity,
float loadFactor,
int concurrencyLevel) |
Modifier and Type | Method and Description |
---|---|
void |
add(E e)
Add the element to the thread-local buffer.
|
void |
flush()
Flush each of the unsynchronized buffers onto their backing synchronized
buffer.
|
T |
get()
Return a thread-local buffer
|
protected abstract void |
halted()
Test to see if the process has been halted.
|
protected abstract T |
initialValue()
Create and return a new object.
|
void |
reset()
Reset each of the synchronized buffers, discarding their buffered writes.
|
int |
size()
Return the #of thread-local objects.
|
protected ThreadLocalBufferFactory()
protected ThreadLocalBufferFactory(int initialCapacity, float loadFactor, int concurrencyLevel)
public final int size()
public void add(E e)
e
- An element.IllegalStateException
- if the factory is asynchronously closed.public final T get()
RuntimeException
- if the join is halted.public void flush()
RuntimeException
- if the join is halted.public void reset()
Note: This method is used during error processing, therefore it DOES NOT
check JoinTask.halt
.
protected abstract T initialValue()
protected abstract void halted()
Haltable.halted()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.