All Projects → saidsikira → Overdrive

saidsikira / Overdrive

Licence: mit
⚡️ Fast async task based Swift framework with focus on type safety, concurrency and multi threading

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Overdrive

TAOMP
《多处理器编程的艺术》一书中的示例代码实现,带有注释与单元测试
Stars: ✭ 39 (-95.26%)
Mutual labels:  multi-threading, concurrency
Fucking Java Concurrency
🎏 Simple show cases of java concurrency problems, seeing 🙈 is believing 🐵
Stars: ✭ 779 (-5.35%)
Mutual labels:  concurrency, multi-threading
Thread Pool
Thread pool implementation using c++11 threads
Stars: ✭ 417 (-49.33%)
Mutual labels:  concurrency, multi-threading
thread-pool
BS::thread_pool: a fast, lightweight, and easy-to-use C++17 thread pool library
Stars: ✭ 1,043 (+26.73%)
Mutual labels:  multi-threading, concurrency
chicken-gochan
Go-like Channels for Chicken Scheme
Stars: ✭ 18 (-97.81%)
Mutual labels:  multi-threading, concurrency
Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (-37.18%)
Mutual labels:  concurrency, multi-threading
Javamtp
《Java多线程编程实战指南(设计模式篇)》源码
Stars: ✭ 575 (-30.13%)
Mutual labels:  concurrency, multi-threading
H2o 3
H2O is an Open Source, Distributed, Fast & Scalable Machine Learning Platform: Deep Learning, Gradient Boosting (GBM) & XGBoost, Random Forest, Generalized Linear Modeling (GLM with Elastic Net), K-Means, PCA, Generalized Additive Models (GAM), RuleFit, Support Vector Machine (SVM), Stacked Ensembles, Automatic Machine Learning (AutoML), etc.
Stars: ✭ 5,656 (+587.24%)
Mutual labels:  multi-threading
Translations
🐼 Chinese translations for classic IT resources
Stars: ✭ 6,074 (+638.03%)
Mutual labels:  concurrency
Funfix
Functional Programming Library for JavaScript, TypeScript and Flow ✨⚡️
Stars: ✭ 596 (-27.58%)
Mutual labels:  concurrency
Taskflow
A General-purpose Parallel and Heterogeneous Task Programming System
Stars: ✭ 6,128 (+644.59%)
Mutual labels:  multi-threading
Pget
The fastest file download client
Stars: ✭ 724 (-12.03%)
Mutual labels:  concurrency
Kovenant
Kovenant. Promises for Kotlin.
Stars: ✭ 657 (-20.17%)
Mutual labels:  concurrency
Transient
A full stack, reactive architecture for general purpose programming. Algebraic and monadically composable primitives for concurrency, parallelism, event handling, transactions, multithreading, Web, and distributed computing with complete de-inversion of control (No callbacks, no blocking, pure state)
Stars: ✭ 617 (-25.03%)
Mutual labels:  concurrency
Cr
Runs your tasks at maximum concurrency
Stars: ✭ 681 (-17.25%)
Mutual labels:  concurrency
Java Concurrency Progamming Tutorial
BAT华为大厂一线工程师四年磨一剑精心编排 Java 高并发编程案例代码 & 教程 & 面试题集锦。详细文档讲解请阅读本人的知识库仓:https://github.com/Wasabi1234/Java-Interview-Tutorial
Stars: ✭ 606 (-26.37%)
Mutual labels:  concurrency
Actix
Actor framework for Rust.
Stars: ✭ 6,764 (+721.87%)
Mutual labels:  concurrency
Ocaml Multicore
Multicore OCaml
Stars: ✭ 591 (-28.19%)
Mutual labels:  concurrency
Continuable
C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections)
Stars: ✭ 655 (-20.41%)
Mutual labels:  concurrency
Example.v2
An example project for book 'Go Programming & Concurrency in Practice, 2nd edition' (《Go并发编程实战》第2版).
Stars: ✭ 722 (-12.27%)
Mutual labels:  concurrency

Build Status Plaforms Carthage Compatible Swift Package Manager Compatible Pod version

Our apps constantly do work. The faster you react to user input and produce an output, the more likely is that the user will continue to use your application. As our applications grow in complexity, the more and more work needs to be done. You need to start thinking about how to categorize and optimize work, how to make that work more efficient, more optimized and finally, faster. In most cases that doesn’t end very well because you need to know a lot about concurrency, multithreading etc. - it’s a very complex field. You need to know all API specifics before you are able to write something.

Overdrive was created as a result of that struggle. It is a framework that exposes several simple concepts which are made on top of complex system frameworks that enable multithreading, concurrency and most importantly, more speed.

let task = URLSessionTask(url: "https://api.swiftable.io")

task
  .retry(3)
  .onValue { json in
    print(json["message"])
  }.onError { error in
    print(error)
}

TaskQueue.background.add(task: task)

Contents:

What can I do with Overdrive?

  • [x] Execute tasks concurrently
  • [x] Utilize multi-core systems by default
  • [x] Easily defer task execution to custom thread or queue
  • [x] Ensure that multiple tasks are executed in the correct order
  • [x] Express custom conditions under which tasks can be executed
  • [x] Enforce testability
  • [x] Retry tasks that finished with errors
  • [x] Write thread safe code by default

Requirements

  • Xcode 8.0+
  • Swift 3
  • Platforms:
    • iOS 8.0+
    • macOS 10.11+
    • tvOS 9.0+
    • watchOS 2.0+
    • Ubuntu

Installation

Carthage

github "arikis/Overdrive" >= 0.3

Cocoa Pods

platform :ios, '8.0'
use_frameworks!

target 'Your App Target' do
  pod 'Overdrive', '~> 0.3'
end

Swift Package Manager

import PackageDescription

let package = Package(
  name: "Your Package Name",
  dependencies: [
    .Package(url: "https://github.com/arikis/Overdrive.git",
             majorVersion: 0,
           minor: 3)
  ]
)

Manual installation

Overdrive can also be installed manually by dragging the Overdrive.xcodeproj to your project and adding Overdrive.framework to the embedded libraries in project settings.

Usage

Overdrive features two main classes:

Workflow:

  1. Create subclass of Task<T>
  2. Override run() method and encapsulate any synchronous or asynchronous operation
  3. Finish execution with value(T) or error(Error) by using finish(with:) method
  4. Create instance of subclass
  5. Add it to the TaskQueue when you want to start execution

Example Task<UIImage> subclass for photo download task:

class GetLogoTask: Task<UIImage> {

  override func run() {
    let logoURL = URL(string: "https://swiftable.io/logo.png")!

    do {
      let logoData = try Data(contentsOf: logoURL)
      let image = UIImage(data: logoData)!
      finish(with: .value(image)) // Finish with image
    } catch {
      finish(with: .error(error)) // Finish with error if any
    }
  }
}

To setup completion blocks, you use onValue and onError methods:

let logoTask = GetLogoTask()

logoTask
  .onValue { logo in
    print(logo) // UIImage object
  }.onError { error in
    print(error)
}

To execute the task add it to the instance of TaskQueue

let queue = TaskQueue()
queue.add(task: logoTask)

Concurrency

TaskQueue executes tasks concurrently by default. Maximum number of concurrent operations is defined by the current system conditions. If you want to limit the number of maximum concurrent task executions use maxConcurrentTaskCount property.

let queue = TaskQueue()
queue.maxConcurrentTaskCount = 3

Thread safety

All task properties are thread-safe by default, meaning that you can access them from any thread or queue and not worry about locks and access synchronization.

Inspiration

Overdrive framework was heavily inspired by talks and code from several Apple WWDC videos.

Overdrive is a term for an effect used in electric guitar playing that occurs when guitar amp tubes starts to produce overdriven, almost distorted sound, due to the higher gain(master) setting.

Long term plans

This section defines some long term plans for Overdrive. They're not scheduled for implementation or for any specific version.

Remove Foundation.Operation dependency

Currently, Overdrive leverages Foundation.Operation and Foundation.OperationQueue classes for concurrency and execution. While those classes provide excellent functionality, they're still rewrites of their Objective C counterpart (NSOperation and NSOperationQueue). This means that writing Task<T> requires a lot of overrides and state management.

For example, any task subclass must override run() method to define execution point. If this method is not overridden, queue will perform assert to notify that this method should be overridden. Same will happen if super.run() is called.

In the future, Overdrive should only use libdispatch for it's functionality.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].