Sodeac multichainlist

A snapshotable and partable list

License

License

GroupId

GroupId

org.sodeac
ArtifactId

ArtifactId

org.sodeac.multichainlist
Last Version

Last Version

1.0.2
Release Date

Release Date

Type

Type

bundle
Description

Description

Sodeac multichainlist
A snapshotable and partable list
Project URL

Project URL

https://github.com/spalarus/java-sodeac-multichainlist
Source Code Management

Source Code Management

https://github.com/spalarus/java-sodeac-multichainlist.git

Download org.sodeac.multichainlist

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status

A snapshotable and partable list

To avoid misunderstandings, no class of this project implements java.util.List. The goal is to prevent a performance slump for very large snapshotable lists and provide capabilities to structure the elements inside. Unlike CopyOnWriteArrayList a multichainlist never creates a deep copy, neither when modifying, nor when reading.

Maven

<!-- requires java 8+ -->
<dependency>
  <groupId>org.sodeac</groupId>
  <artifactId>org.sodeac.multichainlist</artifactId>
  <version>1.0.1</version>
</dependency>

Getting Started

This simple example creates a list with two partitions (prio high and low) and two chains (Alice and Bob) and use it as task manager.

MultiChainList<Task> tasks = new MultiChainList<>("PRIO_HIGH","PRIO_LOW");

tasks.cachedLinkerBuilder().inPartition("PRIO_LOW").linkIntoChain("Bob")	.append(new Task("paint a picture"));
tasks.cachedLinkerBuilder().inPartition("PRIO_LOW").linkIntoChain("Alice")	.append(new Task("dance"));

tasks.cachedLinkerBuilder().inPartition("PRIO_HIGH").linkIntoChain("Bob")	.append(new Task("hug alice"));
tasks.cachedLinkerBuilder().inPartition("PRIO_HIGH").linkIntoChain("Alice")	.append(new Task("hug bob"));

tasks.cachedLinkerBuilder().inPartition("PRIO_LOW").linkIntoChain("Bob")	.append(new Task("dance"));
tasks.cachedLinkerBuilder().inPartition("PRIO_LOW").linkIntoChain("Alice")	.append(new Task("paint a picture"));

new Thread(() -> 
{ 
	try(Snapshot<Task> tasksAlice = tasks.createChainView(ALICE).createImmutableSnapshotPoll())
	{
		tasksAlice.forEach( t -> { t.takeOverTask().runBy(ALICE);});
	}
}).start();

new Thread(() -> 
{ 
	try(Snapshot<Task> tasksBob = tasks.createChainView(BOB).createImmutableSnapshotPoll())
	{
		tasksBob.forEach( t -> { t.takeOverTask().runBy(BOB);});
	}
}).start();

/* output:
Alice: hug bob
Bob: hug alice
Alice: dance
Bob: paint a picture
Alice: paint a picture
Bob: dance
*/

License

Eclipse Public License 2.0

Versions

Version
1.0.2
1.0.1
1.0.0