so898 / concurrency-java

Dispatch queues (akin to Grand Central Dispatch), Promises and Cocoa Operations implemented in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Advanced Java Concurrency Primitives

Build Status codecov.io

Dispatch Queues

Features

  • Functionally equivalent interface to GCD
  • Global Dispatch Queues (High, Medium, Low, Main & UI)
  • Concurrent Dispatch Queues
  • Serial Dispatch Queues
  • Dispatch Queue Groups
  • Dispatch Barriers
  • Android Support (currently requires retrolambda)

Implementation

All dispatch queues are implemented in 100% pure java using the standard Java 7 concurrency primitives. Global & Concurrent dispatch queues are implemented using a common priority based thread pool. Serial dispatch queues are implemented on top of an existing dispatch queue.

Availability

Maven (snapshots in oss.jfrog.org & oss.sonatype.org)

  <dependency>
      <groupId>io.retxt.concurrency</groupId>
      <artifactId>dispatch</artifactId>
      <version>${version}</version>
  </dependency>
  <!-- Optional Android support -->
  <dependency>
      <groupId>io.retxt.concurrency</groupId>
      <artifactId>dispatch-android</artifactId>
      <version>${version}</version>
  </dependency>

Gradle

io.retxt.concurrency:dispatch:${version}
// Optional Android support
io.retxt.concurrency:dispatch-android:${version}

Promises

Features

  • Similar interface and implementation to PromiseKit
  • Defaults to executing on main queue but easily redirectable to a specific or background queue

Implementation

Promises are implemented via the dispatch queues and they are 100% pure Java and provide tight integration with Operations as well.

Availability

Maven (snapshots in oss.jfrog.org & oss.sonatype.org)

  <dependency>
      <groupId>io.retxt.concurrency</groupId>
      <artifactId>promise</artifactId>
      <version>${version}</version>
  </dependency>

Gradle

io.retxt.concurrency:promise:${version}

Operations & Operation Queues

Features

  • General Operations
  • Advanced Operations
    • Very similar to those described in WWDC 2015 - Session #226
    • Conditions - Required to bet met before operation can be executed
      • Examples
        • Mutual Exclusion - Ensure only one instance of operations with this condition can execute simulataneously
        • No Cancelled Dependencies - Ensure operation executes only if no dependencies were cancelled
        • Delay - Delay start of operation for a specific time period
      • Easy creation of new conditions such as network reachability or UI modal exclusion
    • Finish & cancel with errors

Implementation

All Operations and AdvancedOperations are implemented via the dispatch queues and therefore are 100% pure Java and provide tight integration with Promises as well.

Availability

Maven (snapshots in oss.jfrog.org & oss.sonatype.org)

  <dependency>
      <groupId>io.retxt.concurrency</groupId>
      <artifactId>operations</artifactId>
      <version>${version}</version>
  </dependency>

Gradle

io.retxt.concurrency:operations:${version}

About

Dispatch queues (akin to Grand Central Dispatch), Promises and Cocoa Operations implemented in Java

License:MIT License


Languages

Language:Java 100.0%