public class WorkSync<Material,W extends Work<Material,W>> extends Object
The technique used here is inspired in part both by the Flat Combining concept from Hendler, Incze, Shavit & Tzafrir, and in part by the wait-free linked queue design by Vyukov.
In a sense, this turns many small, presumably concurrent, pieces of work into fewer, larger batches of work, that is then applied to the material under synchronisation.
Obviously this only makes sense for work that a) can be combined, and b) where the performance improvements from batching effects is large enough to overcome the overhead of collecting and batching up the work units.
Work| Constructor and Description |
|---|
WorkSync(Material material)
Create a new WorkSync that will synchronize the application of work to
the given material.
|
| Modifier and Type | Method and Description |
|---|---|
void |
apply(W work)
Apply the given work to the material in a thread-safe way, possibly by
combining it with other work.
|
public WorkSync(Material material)
material - The material we want to apply work to, in a thread-safe
way.public void apply(W work) throws ExecutionException
work - The work to be done.ExecutionException - if this thread ends up performing the piled up work,
and any work unit in the pile throws an exception. Thus the current thread is not
guaranteed to observe any exception its unit of work might throw, since the
exception will be thrown in whichever thread that ends up actually performing the work.Copyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.