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

@@ -0,0 +1,18 @@
import time
// Simulate expensive computing using sleep function
fn expensive_computing(id int, duration int) {
println('Executing expensive computing task (${id})...')
time.sleep(duration * time.millisecond)
println('Finish task ${id} on ${duration} ms')
}
fn main() {
mut threads := []thread{}
threads << spawn expensive_computing(1, 100)
threads << spawn expensive_computing(2, 500)
threads << spawn expensive_computing(3, 1000)
// Join all tasks
threads.wait()
println('All jobs finished!')
}
@@ -0,0 +1,32 @@
import net.http
import sync
import time
fn vlang_time(mut wg sync.WaitGroup) !string {
start := time.ticks()
data := http.get('https://vlang.io/utc_now')!
finish := time.ticks()
println('Finish getting time ${finish - start} ms')
println(data.body)
wg.done()
return data.body
}
fn remote_ip(mut wg sync.WaitGroup) !string {
start := time.ticks()
data := http.get('https://api.ipify.org')!
finish := time.ticks()
println('Finish getting ip ${finish - start} ms')
println(data.body)
wg.done()
return data.body
}
fn main() {
mut wg := sync.new_waitgroup()
wg.add(2)
// Run tasks async
spawn vlang_time(mut wg)
spawn remote_ip(mut wg)
wg.wait()
}
@@ -0,0 +1,13 @@
fn expensive_computing(i int) int {
return i * i
}
fn main() {
mut threads := []thread int{}
for i in 1 .. 10 {
threads << spawn expensive_computing(i)
}
// Join all tasks
r := threads.wait()
println('All jobs finished: ${r}')
}