All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.neo4j.util.concurrent.Work Maven / Gradle / Ivy

There is a newer version: 5.26.0
Show newest version
/*
 * Copyright (c) "Neo4j"
 * Neo4j Sweden AB [https://neo4j.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j 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 3 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.neo4j.util.concurrent;

/**
 * 

* A unit of work that can be applied to the given type of material, or combined with other like-typed units of * work. *

*

* These types of work must exhibit a number of properties, for their use in the WorkSync to be correct: *

*
    *
  • * Commutativity
    * The order of operands must not matter: * a.combine(b) = b.combine(a) *
  • *
  • * Associativity
    * The order of operations must not matter: * a.combine(b.combine(c)) = a.combine(b).combine(c) *
  • *
  • * Effect Transitivity
    * Work-combining must not change work outcome: * a.combine(b).apply(m) = { a.apply(m) ; b.apply(m) } *
  • *
* * @param The type of material to work with. * @param The concrete type of work being performed. * @see WorkSync */ public interface Work> { /** *

* Combine this unit of work with the given unit of work, and produce a unit of work that represents the * aggregate of the work. *

*

* It is perfectly fine for a unit to build up internal state that aggregates the work it is combined with, * and then return itself. This is perhaps useful for reducing the allocation rate a little. *

*/ W combine(W work); /** * Apply this unit of work to the given material. */ void apply(Material material) throws Exception; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy