mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-10-18 17:32:09 +08:00
add "hello_nim" example application written by Nim.
Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
This commit is contained in:

committed by
Alin Jerpelea

parent
a594bbda7c
commit
c785e32183
18
examples/hello_nim/hello_nim_async.nim
Normal file
18
examples/hello_nim/hello_nim_async.nim
Normal file
@@ -0,0 +1,18 @@
|
||||
import std/asyncdispatch
|
||||
import std/strformat
|
||||
|
||||
proc task(id: int): Future[void] {.async.} =
|
||||
for loop in 0..2:
|
||||
echo &"Hello from task {id}! loops: {loop}"
|
||||
if loop < 2:
|
||||
await sleepAsync(1000)
|
||||
|
||||
proc launch() {.async.} =
|
||||
for id in 1..2:
|
||||
asyncCheck task(id)
|
||||
await sleepAsync(200)
|
||||
await task(3)
|
||||
|
||||
proc hello_nim() {.exportc, cdecl.} =
|
||||
waitFor launch()
|
||||
GC_runOrc()
|
Reference in New Issue
Block a user