mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
all: coroutines (part 1)
This commit is contained in:
parent
5812579d53
commit
45f16a2640
18 changed files with 216 additions and 24 deletions
21
vlib/coroutines/coroutines.v
Normal file
21
vlib/coroutines/coroutines.v
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) 2019-2023 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
module coroutines
|
||||
|
||||
import time
|
||||
|
||||
#flag -I @VEXEROOT/thirdparty/photon
|
||||
#flag @VEXEROOT/thirdparty/photon/photonwrapper.so
|
||||
|
||||
#include "photonwrapper.h"
|
||||
|
||||
fn C.photon_init_default() int
|
||||
fn C.photon_thread_create11(f voidptr)
|
||||
fn C.photon_sleep_s(n int)
|
||||
fn C.photon_sleep_ms(n int)
|
||||
|
||||
// sleep is coroutine-safe version of time.sleep()
|
||||
pub fn sleep(duration time.Duration) {
|
||||
C.photon_sleep_ms(duration.milliseconds())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue