All Projects → elijahdou → Suzaku

elijahdou / Suzaku

Licence: apache-2.0
Hashed wheel timer in Swift

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Suzaku

Easytimer.js
Easy to use Timer/Stopwatch/Countdown library compatible with AMD, ES6 and Typescript
Stars: ✭ 562 (+629.87%)
Mutual labels:  timer
Appserver
A multithreaded application server for PHP, written in PHP.
Stars: ✭ 930 (+1107.79%)
Mutual labels:  timer
React Countdown
React Component showing a countdown to certain date and time.
Stars: ✭ 58 (-24.68%)
Mutual labels:  timer
Termdown
Countdown timer and stopwatch in your terminal
Stars: ✭ 749 (+872.73%)
Mutual labels:  timer
Update Background Locations
A sample iOs example that tracks background locations.
Stars: ✭ 7 (-90.91%)
Mutual labels:  timer
Dinnertime
Cooking timer & scheduler with spoken instructions
Stars: ✭ 7 (-90.91%)
Mutual labels:  timer
Node Measured
A Node metrics library for measuring and reporting application-level metrics, inspired by Coda Hale, Yammer Inc's Dropwizard Metrics Libraries
Stars: ✭ 500 (+549.35%)
Mutual labels:  timer
Swiftytimer
Swifty API for NSTimer
Stars: ✭ 1,143 (+1384.42%)
Mutual labels:  timer
Flutter timer and stopwatch
A Timer with all the functionality you would expect. Both Inputs and Outputs are of type Duration.
Stars: ✭ 18 (-76.62%)
Mutual labels:  timer
Ttimer
Terminal countdown timer, written in Go
Stars: ✭ 42 (-45.45%)
Mutual labels:  timer
Each
Elegant ⏱ interface for Swift apps
Stars: ✭ 764 (+892.21%)
Mutual labels:  timer
Zltoolkit
一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
Stars: ✭ 838 (+988.31%)
Mutual labels:  timer
Prince
Implementing PopRouting
Stars: ✭ 11 (-85.71%)
Mutual labels:  timer
Countdownlabel
Simple countdown UILabel with morphing animation, and some useful function.
Stars: ✭ 714 (+827.27%)
Mutual labels:  timer
Countdowntask
⌛️A countdown library for Android.
Stars: ✭ 64 (-16.88%)
Mutual labels:  timer
Wecron
✔️ 微信上的定时提醒 - Cron on WeChat
Stars: ✭ 537 (+597.4%)
Mutual labels:  timer
Mycodo
An environmental monitoring and regulation system
Stars: ✭ 936 (+1115.58%)
Mutual labels:  timer
Flip Clock
A flip clock, timer and countdown made with Polymer
Stars: ✭ 69 (-10.39%)
Mutual labels:  timer
Alfred Time
Start and stop tracking time with Toggl, Harvest, Everhour or Clockify through Alfred 4
Stars: ✭ 65 (-15.58%)
Mutual labels:  timer
Obs Studio Python Scripting Cheatsheet Obspython Examples Of Api
⚫️ OBS Studio API with Python
Stars: ✭ 40 (-48.05%)
Mutual labels:  timer

Suzaku

CI Status Version Platform

Suzaku is a swift version of the hashed wheel timer.

Feature

  • Thread safe
  • GCD Timer
  • Local variable timer

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

Hashed Wheel Timer were used as a base for Kernels and Network stacks. It is suitable for scenarios where a large number of timed tasks are concurrent. Suzaku is a swift implementation of hashed wheel timer designed for iOS clients, suitable for scenarios such as live rooms and persistent connections.

/// normal
class SomeClass {
    let timer = try! HashedWheelTimer(tickDuration: .seconds(1), ticksPerWheel: 8, dispatchQueue: nil)
    var counter = 0
    let dateFormatter = DateFormatter()
    func someFunction() {
        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
        timer.resume()
        _ = try? timer.addTimeout(timeInterval: .seconds(3), reapting: true, block: { [weak self](timer) in
            guard let self = self else { return }
            self.counter += 1
            print("\(Thread.current) counter: \(self.counter) at \(self.dateFormatter.string(from: Date()))")
            if self.counter == 18 {
                timer.stop()
            }
        })
    }
}

/// local variable timer
class SomeClass {
    let dateFormatter = DateFormatter()
    
    func someFunction() {
        dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
        var localTimer = try? HashedWheelTimer(tickDuration: .seconds(1), ticksPerWheel: 1, dispatchQueue: DispatchQueue.global())
        localTimer?.resume()
        DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
            _ = try? localTimer?.addTimeout(timeInterval: .seconds(5), reapting: true, block: { [weak self](timer) in
            guard let self = self else { return }
            print("\(Thread.current) fired \(self.dateFormatter.string(from: Date()))")
        })
    }
}

Requirements

  • iOS 10.0+
  • Swift 5.0+
  • Xcode 11+
  • OSX 10.12+

Installation

CocoaPods

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

pod 'Suzaku'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Alamofire does support its use on supported platforms.

Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/elijahdou/Suzaku.git")
]

Author

elijahdou, [email protected]

License

Suzaku is available under the Apache 2.0 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].