mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
examples: add a simple coroutine example
This commit is contained in:
parent
1be539d20f
commit
3f62487409
3 changed files with 64 additions and 3 deletions
|
@ -11,7 +11,7 @@ import time
|
|||
#include "photonwrapper.h"
|
||||
|
||||
fn C.photon_init_default() int
|
||||
fn C.photon_thread_create(f voidptr)
|
||||
fn C.photon_thread_create(f voidptr, arg voidptr)
|
||||
fn C.photon_sleep_s(n int)
|
||||
fn C.photon_sleep_ms(n int)
|
||||
|
||||
|
@ -21,5 +21,8 @@ pub fn sleep(duration time.Duration) {
|
|||
}
|
||||
|
||||
fn init() {
|
||||
C.photon_init_default()
|
||||
ret := C.photon_init_default()
|
||||
if ret < 0 {
|
||||
panic('failed to initialize coroutines via photon (ret=${ret})')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue