diff --git a/ROADMAP.md b/ROADMAP.md index a22e2efbfe..3b6421b7dd 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,8 +1,27 @@ +## [Version 0.3] + +-- [x] gc option +-- [x] channels +-- [x] lock{} +-- [x] thread safe arrays +-- [x] rune type +-- [x] replace `ustring` with `[]rune` +-- [x] fix `byte.str()` +-- [x] maps with non-string keys +-- [x] iOS/Android support +-- [x] parallel cgen +-- [x] IO streams +-- [x] struct embedding +-- [x] interface embedding +-- [x] interfaces: allow struct fields (not just methods) +-- [x] short generics syntax (`foo(5)` instead of `foo(5)`) +-- [x] more advanced errors, not just `error('message')` + ## [Version 0.4] - [x] [Coroutines](https://github.com/vlang/v/discussions/11582) - [x] vfmt: add missing imports (like goimports) -- [ ] Recursive structs via options: `struct Node { next ?Node }` +- [x] Recursive structs via options: `struct Node { next ?Node }` - [x] First class Option type - [x] Optional function struct fields - [ ] Handle function pointers safely, remove `if function == 0 {` @@ -13,6 +32,7 @@ - [x] New VPM site ## [Version 0.5] + - [ ] [Thread safe maps](https://github.com/vlang/v/discussions/11729) - [ ] Parallel parser - [ ] Parallel checker @@ -29,6 +49,7 @@ - [ ] Big remaining bugs fixed - [ ] More powerful comptime - [ ] Constraits for generics +- [ ] Coroutines on Windows - [ ] Autofree memory management option ready for production - [ ] C2V supporting entire C99 standard diff --git a/examples/coroutines/simple_coroutines.v b/examples/coroutines/simple_coroutines.v new file mode 100644 index 0000000000..c76c753130 --- /dev/null +++ b/examples/coroutines/simple_coroutines.v @@ -0,0 +1,37 @@ +// Build with +// v -use-coroutines simple_coroutines.v +// +import coroutines +import time + +fn foo(a int) { + for { + println('hello from foo() a=${a}') + coroutines.sleep(1 * time.second) + } +} + +fn foo2(a int) { + for { + println('hello from foo2() a=${a}') + coroutines.sleep(2 * time.second) + } +} + +fn foo3(a int) { + for { + println('hello from foo3() a=${a}') + coroutines.sleep(3 * time.second) + } +} + +fn main() { + go foo(10) + go foo2(20) + go foo3(30) + for { + println('hello from MAIN') + coroutines.sleep(1 * time.second) + } + println('done') +} diff --git a/vlib/coroutines/coroutines.v b/vlib/coroutines/coroutines.v index 8104ff6494..0d50ad3a03 100644 --- a/vlib/coroutines/coroutines.v +++ b/vlib/coroutines/coroutines.v @@ -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})') + } }