Pretty GCD calls and easier code execution.

Related tags

GCD Threader
Overview

Threader

Pretty GCD calls and easier code execution.

Version License Platform

Overview

Threader makes GCD calls easy to read & write. It also provides a simple way to execute code where and when you want.

Installation

CocoaPods

Threader is integrated with CocoaPods!

  1. Add the following to your Podfile:
use_frameworks!
pod 'Threader'
  1. In your project directory, run pod install
  2. Import the Threader module wherever you need it
  3. Profit

Manually

You can also manually add the source files to your project.

  1. Clone this git repo
  2. Add all the Swift files in the Threader/ subdirectory to your project
  3. Profit

Threader

Using Threader you can fine-tune where and how code get executed.

Threader.DispatchAsyncMain.execute {
    /* Important main-thread code */
}

The above simply executes the code within the block on the main-thread. Naturally, Threader also provides other execution options:

  • Immediate - executes the code block immediately on the current thread.
  • DispatchAsync - executes the code block asynchronously on a given DispatchQueue.
  • DispatchAsyncMain - executes code block asynchronously on the main thread.
  • DispatchAsyncGlobal - executes the code block asynchronously on the global-queue.
  • DispatchAsyncAfter - executes the code block asynchronously at a specified DispatchTime, on a DispatchQueue.
  • DispatchAsyncBarrier - executes the code block asynchronously blocking on a given DispatchQueue.
  • DispatchSync - executes the code block synchronously on a given DispatchQueue.
  • DispatchSyncBarrier - executes the code block synchronously blocking on a given DispatchQueue.
  • Operation - executes the code block on a given OperationQueue.
  • Block - executes code from a closure.
  • Default - executes code on the current thread, or on a global DispatchQueue depending on the block of code's current position in the thread.

Dispatching code to a given queue is as easy as:

let queue = DispatchQueue.global()
Threader.DispatchAsync(queue).execute {
    /* Important background-thread code */
}

It can even be simplified further:

Threader.DispatchAsync(.global()).execute {
    /* Important background-thread code */
}

DispatchQueue

In previous versions of Threader, DispatchQueue was a small wrapper around C-based GCD calls. However, as of Swift 3, Apple decided to provide their own solution. Not surprisingly, the also named their wrapper DispatchQueue. Moving forward, Threader will use Apple's native implementation of DispatchQueue for all GCD related calls.

You might also like...
A simple GCD based HTTP client and server, written in 'pure' Swift
A simple GCD based HTTP client and server, written in 'pure' Swift

SwiftyHTTP Note: I'm probably not going to update this any further - If you need a Swift networking toolset for the server side, consider: Macro.swift

GCDWebServer is a modern and lightweight GCD based HTTP 1.1 server designed to be embedded in iOS, macOS & tvOS apps.

GCDWebServer is a modern and lightweight GCD based HTTP 1.1 server designed to be embedded in iOS, macOS & tvOS apps. It was written from scr

MusicAlbumApp - Applications for training networking, field validation, screen transitions, and GCD

MusicAlbumApp This is an educational application for finding music albums and vi

 GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift
GCDTimer - Well tested Grand Central Dispatch (GCD) Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer

Well-tested GCD Timer in Swift
Well-tested GCD Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer class Demo { in

An iOS drop down menu with pretty animation and easy to customize.
An iOS drop down menu with pretty animation and easy to customize.

IGLDropDownMenu An iOS drop down menu with pretty animation. Screenshot How To Use Use CocoaPods: pod 'IGLDropDownMenu' Manual Install: Just drap the

Review page interaction - handy and pretty way to ask for review.
Review page interaction - handy and pretty way to ask for review.

RPInteraction Overview Review page interaction - handy and pretty way to ask for review. Inspired by dribbble shot. Requirements iOS8 Installation RPI

A highly configurable and out-of-the-box-pretty UI library
A highly configurable and out-of-the-box-pretty UI library

We absolutely love beautiful interfaces! As an organization named Unicorn, we are obligated to be unique and majestic.

Review page interaction - handy and pretty way to ask for review
Review page interaction - handy and pretty way to ask for review

RPInteraction Overview Review page interaction - handy and pretty way to ask for review. Inspired by dribbble shot. Requirements iOS8 Installation RPI

LTHRadioButton - A radio button with a pretty animation
LTHRadioButton - A radio button with a pretty animation

LTHRadioButton Slightly inspired by Google's material radio button. The clip below has 3 sections: full speed, 25% and 10%, but after converting it to

A radio button with a pretty animation
A radio button with a pretty animation

LTHRadioButton Slightly inspired by Google's material radio button. The clip below has 3 sections: full speed, 25% and 10%, but after converting it to

Pretty iOS mobile screens + AVPlayer video view ––– made in SwiftUI
Pretty iOS mobile screens + AVPlayer video view ––– made in SwiftUI

UrbanVillageProjectScreens Recreated UI screens from the conceptual Urban Village Project. Read more about the project here. Please open an issue if y

A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically.

ShotPlan (WIP) A command line tool that calls your Xcode Test Plan and creates screenshots of your app automatically. ShotPlan will also take care of

A framework that provides CurtainController. CurtainController is a container view controller that implements a content-curtain interface. You can find a similar implementation in applications like Apple Maps, Find My, Stocks, etc. Someone calls it Sample app to open parking lot gates by phone calls
Sample app to open parking lot gates by phone calls

DouzePointCinq - Test app Sample iOS app to open parking lot gates by phone calls. Screenshots (dark & light modes) How to use Clone the project git c

An iOS Safari extension that redirects MetaMask calls to Rainbow.

Rainbow Bridge (iOS App) An iOS Safari extension that redirects MetaMask calls to Rainbow. Since I can't figure out how to get the Rainbow source runn

Make API Calls using SwiftUI

SwiftUIApICall Make API Calls using SwiftUI This is a simple app for maing API C

Project shows how to unit test asynchronous API calls in Swift using Mocking without using any 3rd party software

UnitTestingNetworkCalls-Swift Project shows how to unit test asynchronous API ca

Lightweight lib around NSURLSession to ease HTTP calls

AeroGear iOS HTTP Thin layer to take care of your http requests working with NSURLSession. Project Info License: Apache License, Version 2.0 Build: Co

Owner
Mitch Treece
Mitch Treece
Well-tested GCD Timer in Swift

GCDTimer Well tested Grand Central Dispatch (GCD) Timer in Swift. Checkout the test file. Usage Long running timer import GCDTimer class Demo { in

Hemanta Sapkota 183 Sep 9, 2022
async and await for Swift.

async and await for Swift. Usage Beta version. New docs soon... Contribute If you have any problems or need more information, please open an issue usi

Alecrim 88 Sep 9, 2022
Just a tiny library to make using GCD easier and intuitive

## Build Status Branch Status master develop Dispatch Note: Dispatch requires swift 3.0. Use version 1.0.0 for swift 2.3 or version 0.9.8 for swift 2.

João Mourato 178 Jun 29, 2022
⏲ A tiny package to measure code execution time. Only 20 lines of code.

Measure ⏲ A tiny package to measure code execution time. Measure.start("create-user") let user = User() Measure.finish("create-user") Console // ⏲ Mea

Mezhevikin Alexey 3 Oct 1, 2022
Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy.

EasyBackgroundRefresh Easy background refresh registration, scheduling, execution, and completion. BGTaskScheduler for the lazy. Usage For fast refres

Yonat Sharon 6 Dec 5, 2022
Kommander is a Swift library to manage the task execution in different threads.

A lightweight, pure-Swift library for manage the task execution in different threads. Through the definition a simple but powerful concept, Kommand.

Intelygenz 173 Apr 11, 2022
PillowTalk - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution.

An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution.

Lakr Aream 416 Dec 16, 2022
Proof-of-concept `WKWebview.evaluateJavaScript(...)` replacement for WebSocket-based Javascript execution.

Proof-of-concept `WKWebview.evaluateJavaScript(...)` replacement for WebSocket-based Javascript execution.

Daniel Dallos 9 Dec 7, 2022
MobilePillowTalkLite - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution

# PillowTalk - iOS/Lite bbtop PillowTalk -> 枕头逼逼 -> bbtop! An iOS & SwiftUI serv

Lakr Aream 416 Dec 16, 2022
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).

Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD). It allows you to create any asynchronous and synchronous task easily, all managed by a queue, with just a few lines.

Fabrizio Brancati 1k Dec 2, 2022