Last active
April 23, 2017 20:11
-
-
Save Kemonozume/ec97368db35661fe777db24c377cba18 to your computer and use it in GitHub Desktop.
Generics nim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncdispatch, times, os | |
| type | |
| TickerFunc* = proc (s: Ticker) : Future[void] | |
| TickerObj[T] = object | |
| poll: int | |
| running*: bool | |
| f: TickerFunc | |
| data: T | |
| Ticker*[T] = ref TickerObj[T] | |
| #timer.nim(12, 3) Error: cannot instantiate: 'Ticker' | |
| proc newTimer*[T](f: TickerFunc, data: T = nil, poll: int = 2000,) : Ticker[T] = | |
| #Ticker[T](poll: poll, running: false, f: f, data: data) | |
| new(result) | |
| result.data = data | |
| result.f = f | |
| result.poll = poll | |
| return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment