All Projects → onmyway133 → Mainthreadguard

onmyway133 / Mainthreadguard

Licence: other
💂 Tracking UIKit access on main thread

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mainthreadguard

youtube-dl-nas
youtube download queue websocket server with login for private NAS.
Stars: ✭ 136 (+156.6%)
Mutual labels:  queue, thread
Sc
Common libraries and data structures for C.
Stars: ✭ 161 (+203.77%)
Mutual labels:  thread, queue
Diskqueue
A thread-safe, multi-process(ish) persistent queue library for .Net and Mono
Stars: ✭ 66 (+24.53%)
Mutual labels:  thread, queue
spinach
Modern Redis task queue for Python 3
Stars: ✭ 46 (-13.21%)
Mutual labels:  queue, thread
Toro
Multithreaded message processing on Postgres
Stars: ✭ 39 (-26.42%)
Mutual labels:  queue
Rxjava Android Samples
Learning RxJava for Android by example
Stars: ✭ 7,520 (+14088.68%)
Mutual labels:  thread
Core
Package core is a service container that elegantly bootstrap and coordinate twelve-factor apps in Go.
Stars: ✭ 34 (-35.85%)
Mutual labels:  queue
Storage Based Queue
Javascript queue library with persistent storage based queue mechanism for the browsers environments. Specially designed for offline.
Stars: ✭ 33 (-37.74%)
Mutual labels:  queue
Webfsd
A simple HTTP server for mostly static content written in C
Stars: ✭ 50 (-5.66%)
Mutual labels:  thread
Vsalert
An drop-in replacement for UIAlertController with more power and better looks.
Stars: ✭ 48 (-9.43%)
Mutual labels:  thread
Yii Queue
Queue extension for Yii 3.0
Stars: ✭ 38 (-28.3%)
Mutual labels:  queue
Sidekiq Job Php
Push and schedule jobs to Sidekiq from PHP
Stars: ✭ 34 (-35.85%)
Mutual labels:  queue
Libgenerics
libgenerics is a minimalistic and generic library for C basic data structures.
Stars: ✭ 42 (-20.75%)
Mutual labels:  queue
Azure.data.wrappers
Azure Storage Simplified
Stars: ✭ 34 (-35.85%)
Mutual labels:  queue
Laravel Elasticbeanstalk Queue Worker
Stars: ✭ 48 (-9.43%)
Mutual labels:  queue
Cockburst
一个高性能,可靠,异步的本地持久化队列实现;重启JVM、重启服务器、或者强制KILL进程时,队列里的数据不丢失;
Stars: ✭ 33 (-37.74%)
Mutual labels:  queue
Laravel Queue Database Ph4
Laravel Database Queue with Optimistic locking
Stars: ✭ 37 (-30.19%)
Mutual labels:  queue
Uploader
A lightweight and very configurable jQuery plugin for file uploading using ajax(a sync); includes support for queues, progress tracking and drag and drop.
Stars: ✭ 1,042 (+1866.04%)
Mutual labels:  queue
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-33.96%)
Mutual labels:  queue
Python Parallel Programming Cookbook Cn
📖《Python Parallel Programming Cookbook》中文版
Stars: ✭ 978 (+1745.28%)
Mutual labels:  thread

MainThreadGuard

Tracking UIKit access on main thread

Version License Platform Swift

Description

This is just a Swift port of PSPDFUIKitMainThreadGuard.m using swizzling on UIView extension

Usage

Call Guard.setup

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  // setup

  Guard.setup()

  return true
}

Features

It works by swizzling in the following methods

  • setNeedsLayout
  • setNeedsDisplay
  • setNeedsDisplayInRect:

Try accessing UIKit from another thread and MainThreadGuard will assert

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = UIColor.white

    let label = UILabel()
    view.addSubview(label)

    DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async {
      label.text = "Setting text on background thread"
    }
  }
}

Xcode 9+

Xcode 9+ has Main Thread Checker, which detects invalid use of AppKit, UIKit, and other APIs from a background thread.

Installation

MainThreadGuard is available through CocoaPods. To install it, simply add the following line to your Podfile:

You should add this to Debug configuration only

pod "MainThreadGuard", git: 'https://github.com/onmyway133/MainThreadGuard', configurations: 'Debug'

Author

Khoa Pham, [email protected]

License

MainThreadGuard is available under the MIT license. See the LICENSE file for more info.

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].