https://github.com/dopsun/mimodispatcher
Dispatches tasks from multiple sources into multiple executors with guaranteed order and synchronisations.
https://github.com/dopsun/mimodispatcher
Last synced: 5 months ago
JSON representation
Dispatches tasks from multiple sources into multiple executors with guaranteed order and synchronisations.
- Host: GitHub
- URL: https://github.com/dopsun/mimodispatcher
- Owner: dopsun
- License: apache-2.0
- Created: 2017-09-03T07:21:47.000Z (almost 9 years ago)
- Default Branch: develop
- Last Pushed: 2017-09-11T14:41:18.000Z (almost 9 years ago)
- Last Synced: 2025-07-11T20:14:37.378Z (12 months ago)
- Language: Java
- Size: 104 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MimoDispatcher
[](https://travis-ci.org/dopsun/mimodispatcher)
Dispatches tasks from multiple sources into multiple executors with guaranteed order and synchronizations.
# Terms
* Task: unit of work Dispatcher dispatches to Executor to run.
* Task could have zero, one or more synchronizers.
* Dispatcher: a dedicated thread to dispatch incoming tasks to Executors.
* Executor: threads to execute task.
# Execution order guarantee:
* All tasks with shared synchronizer will be executed with its incoming order.
* Tasks without shared synchronizers, including tasks without synchronizer, can be executed in any order.
For example:
* If task T1 has synchronizer S1, and T2 has synchronizer S2, then T2 could be executed before T1.
* If task T1 has synchronizer S1, and T2 has synchronizer S1 as well, then T2 is guaranteed to be executed after T1 finished since both have synchronizer "S1".
* If task T1 has synchronizer S1 and S2, and T2 has synchronizer of S1 and S3, then T2 is guaranteed to be executed after T1 finished since both have synchronizer "S1".
# Benchmark
## Single input and single output
A single thread as producer and there is a single thread for consumer. And for different tasks:
| Category | Task Duration | Throughput |
| -------- | -------------- | ---: |
| MimoDispatcher | n.a. | 34,343.918 |
| MimoDispatcher | Thread.sleep(0) | 26,965.111 |
| MimoDispatcher | Thread.sleep(1) | **14.691** |
| MimoDispatcher | Thread.sleep(10) | 1.474 |
| Executor | n.a. | 85,970.706 |
| Executor | Thread.sleep(0) | 45,649.100 |
| Executor | Thread.sleep(1) | **14.518** |
| Executor | Thread.sleep(10) | 1.473 |
* When there is reasonable task duration, for example 1ms or 10ms per task, throughput are very close between ``MimoDispatcher`` and ``Executor``.