Sodeac multichainlist

A snapshotable and partable list

Лицензия

Лицензия

Группа

Группа

org.sodeac
Идентификатор

Идентификатор

org.sodeac.multichainlist
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

bundle
Описание

Описание

Sodeac multichainlist
A snapshotable and partable list
Ссылка на сайт

Ссылка на сайт

https://github.com/spalarus/java-sodeac-multichainlist
Система контроля версий

Система контроля версий

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

Скачать org.sodeac.multichainlist

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

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

Версии библиотеки

Версия
1.0.2
1.0.1
1.0.0