Skip to content

Vargeel/echo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

![drawing](http://i.imgur.com/Zqu5QcG.png width="100")

Echo is a simple way to create an event loop and use GCD in Swift for Linux and OSX

How to use?

Using Echo is simple, to start the main run loop, just call:

Echo.beginEventLoop()

or

Echo.begin()

When you want to exit the loop, just call exit

Echo.exit()

How to use GCD?

Using GCD is the same as with Mac OS X (With limited current features)

main.swift
import Echo

dispatch_async(dispatch_get_global_queue(0, 0)) {
    for i in 0 ..< 1000 {
        dispatch_async(dispatch_get_main_queue()) {
            print(i)
        }
    }

    dispatch_async(dispatch_get_main_queue()) {
        Echo.exit()
    }
}

Echo.begin()

The above code snippet will print all the numbers on the main loop whilst looping in the global queue.

What is it used for?

Is that it?

Yep, it's that simple.

Please feel free to fork and extend to the rest of GCD's functions for Linux

About

Simple Event Looping and GCD in Swift

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 95.4%
  • Objective-C 4.6%