Initial project import

This commit is contained in:
Agila Forge Importer committed 2026-07-13 15:20:32 +00:00
commit 23f2d29e32
11957 files changed
+1754577

No files matched your search

Whitespace-only changes.
@@ -0,0 +1,36 @@
// vtest build: false // This should be build with: `v -use-coroutines coroutine_benchs.v`
// Note: the Photon wrapper is not yet trivial enough to build/install on the CI.
import coroutines
import time
import net.http
import sync
const run_time = 10 * time.second
fn request(mut mu sync.Mutex, count &int) {
for {
http.get('http://vlang.io/utc_now') or { panic(err) }
mu.lock()
unsafe {
(*count)++
}
mu.unlock()
}
}
fn main() {
mut mu := sync.new_mutex()
mut count := 0
for _ in 0 .. 8 {
go request(mut mu, &count)
}
$if is_coroutine ? {
println('IS COROUTINE=true')
coroutines.sleep(run_time)
} $else {
println('IS COROUTINE=false')
time.sleep(run_time)
}
println('${count} requests made.')
}
@@ -0,0 +1,62 @@
// vtest build: false // This should be build with: v -use-coroutines simple_coroutines.v
// Note: the Photon wrapper is not yet trivial enough to build/install on the CI.
import coroutines
import time
import os
import net.http
fn foo(a int) {
for {
println('1hello from foo() a=${a}')
// C.printf(c'hello from foo() a=%d\n', a)
coroutines.sleep(1 * time.second)
}
}
fn foo2(a int) {
mut i := 0
for {
println('hello from foo2() a=${a}')
// C.printf(c'hello from foo2() a=%d\n', a)
coroutines.sleep(2 * time.second)
i++
resp := http.get('https://vlang.io/utc_now') or { panic(err) }
println(resp)
mut f := os.create('/tmp/FOO2_a${i}') or { panic(err) }
f.write_string(resp.body) or { panic(err) }
f.close()
}
}
fn foo3(a int) {
for {
println('hello from foo3() a=${a}')
// C.printf(c'hello from foo3() a=%d\n', a)
coroutines.sleep(3 * time.second)
}
}
fn foo4(a int) {
for {
println('hello from foo4() a=${a}')
// C.printf(c'hello from foo4() a=%d\n', a)
coroutines.sleep(3 * time.second)
}
}
fn main() {
go foo(10)
go foo2(20)
go foo3(30)
go foo3(40)
$if is_coroutine ? {
println('IS COROUTINE=true')
} $else {
println('IS COROUTINE=false')
}
for {
println('hello from MAIN')
coroutines.sleep(1 * time.second)
}
println('done')
}