Skip to content

MeetTak/flowQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlowQ — Concurrent Task Queue (Java)

Architecture

Producer -> RateLimiter -> BoundedTaskQueue -> Worker threads -> MetricsCollector

Design Decisions

  • ReentrantLock + Condition used for precise control and explicit signaling; avoids implicit locking of synchronized and allows multiple conditions (notEmpty / notFull).
  • PriorityQueue + explicit lock chosen over PriorityBlockingQueue to demonstrate explicit concurrency control and backpressure behavior when bounded.
  • RetryPolicy: FIXED vs LINEAR vs EXPONENTIAL tradeoffs — FIXED is simple and predictable; LINEAR spaces retries linearly to reduce retry storms; EXPONENTIAL rapidly increases backoff to avoid thundering retries at scale (capped to 30s here).
  • Shutdown: shutdown() marks queue as closed and signals all waiting conditions; dequeue() returns null when shutdown and empty so workers can exit cleanly; WorkerPool.shutdown() requests workers stop and joins threads.

Usage

See src/main/java/dev/meettak/flowq/demo/Demo.java for a runnable example. Typical facade usage:

FlowQ q = new FlowQ(100, 4, new TokenBucketRateLimiter(10,10)); q.start(); q.submit(new Task("name", () -> {/* work */}, 5, 0, 3)); q.shutdown();

Benchmark Notes

  • Benchmarking outputs are produced to the console by LiveDashboard while running the demo.

About

concurrent Task Queue

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages