From e81e0ac708d0740cd94a7146f0631307da7001de Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 5 Nov 2022 10:46:40 +0300 Subject: [PATCH] fmt: replace `go` with `spawn` --- cmd/tools/modules/testing/common.v | 2 +- cmd/tools/test_os_process.v | 2 +- cmd/tools/vdoc/vdoc.v | 2 +- cmd/tools/vtest-parser.v | 4 +-- cmd/tools/vwatch.v | 2 +- examples/concurrency/concurrency.v | 6 ++-- examples/concurrency/concurrency_http.v | 4 +-- examples/concurrency/concurrency_returns.v | 2 +- examples/flappylearning/game.v | 2 +- examples/gg/mandelbrot.v | 4 +-- examples/gg/random.v | 2 +- examples/gg/worker_thread.v | 2 +- examples/hot_reload/bounce.v | 2 +- examples/net_t.v | 2 +- examples/pendulum-simulation/animation.v | 4 +-- examples/pendulum-simulation/full.v | 6 ++-- .../modules/sim/anim/app.v | 2 +- examples/pendulum-simulation/parallel.v | 2 +- .../pendulum-simulation/parallel_with_iw.v | 4 +-- examples/quadtree_demo/quadtree_demo.v | 2 +- examples/tcp_echo_server.v | 2 +- examples/websocket/client-server/client.v | 2 +- examples/websocket/ping.v | 4 +-- vlib/clipboard/x11/clipboard.c.v | 2 +- vlib/context/cancel.v | 2 +- vlib/context/cancel_test.v | 2 +- vlib/context/deadline.v | 2 +- vlib/context/onecontext/onecontext.v | 6 ++-- vlib/log/log_test.v | 4 +-- vlib/net/http/server_test.v | 6 ++-- .../tcp_self_dial_from_many_clients_test.v | 6 ++-- vlib/net/tcp_simple_client_server_test.v | 2 +- vlib/net/tcp_test.v | 2 +- vlib/net/udp_test.v | 2 +- vlib/net/unix/unix_test.v | 4 +-- .../unix/use_net_and_net_unix_together_test.v | 2 +- vlib/net/websocket/websocket_server.v | 4 +-- vlib/net/websocket/websocket_test.v | 6 ++-- vlib/picoev/picoev.v | 2 +- vlib/sync/bench/channel_bench_v.v | 4 +-- .../many_writers_and_receivers_on_1_channel.v | 4 +-- vlib/sync/channel_1_test.v | 2 +- vlib/sync/channel_2_test.v | 2 +- vlib/sync/channel_3_test.v | 16 +++++----- vlib/sync/channel_4_test.v | 16 +++++----- vlib/sync/channel_array_mut_test.v | 2 +- vlib/sync/channel_close_test.v | 32 +++++++++---------- vlib/sync/channel_fill_test.v | 2 +- vlib/sync/channel_opt_propagate_test.v | 2 +- vlib/sync/channel_polling_test.v | 4 +-- vlib/sync/channel_push_or_1_test.v | 10 +++--- vlib/sync/channel_push_or_2_test.v | 2 +- vlib/sync/channel_select_2_test.v | 8 ++--- vlib/sync/channel_select_3_test.v | 4 +-- vlib/sync/channel_select_4_test.v | 4 +-- vlib/sync/channel_select_5_test.v | 12 +++---- vlib/sync/channel_select_6_test.v | 18 +++++------ vlib/sync/channel_select_test.v | 8 ++--- vlib/sync/many_times_test.v | 4 +-- vlib/sync/once_test.v | 2 +- vlib/sync/once_with_param_test.v | 2 +- vlib/sync/pool/pool.v | 2 +- vlib/sync/select_close_test.v | 8 ++--- vlib/sync/stdatomic/atomic_test.v | 4 +-- vlib/sync/struct_chan_init_test.v | 2 +- vlib/sync/thread_test.v | 4 +-- vlib/sync/waitgroup_test.v | 4 +-- vlib/v/compiler_errors_test.v | 2 +- vlib/v/fmt/fmt.v | 2 +- vlib/v/gen/js/tests/js.v | 2 +- vlib/v/live/executable/reloader.v | 2 +- vlib/v/tests/anon_fn_test.v | 2 +- vlib/v/tests/array_map_ref_test.v | 4 +-- vlib/v/tests/array_of_threads_wait_test.v | 2 +- vlib/v/tests/atomic_test.v | 2 +- vlib/v/tests/autolock_array1_test.v | 4 +-- vlib/v/tests/autolock_array2_test.v | 4 +-- vlib/v/tests/bench/gcboehm/GC_bench.v | 2 +- vlib/v/tests/break_in_lock_test.v | 4 +-- vlib/v/tests/channels_test.v | 4 +-- vlib/v/tests/comptime_if_expr_threads_test.v | 2 +- vlib/v/tests/comptime_if_threads_yes_test.v | 2 +- vlib/v/tests/default_thread_stack_size_test.v | 2 +- vlib/v/tests/defer/defer_test.v | 2 +- vlib/v/tests/fixed_array_of_threads_test.v | 2 +- vlib/v/tests/for_loops_2_test.v | 2 +- .../tests/go_anon_fn_call_with_ref_arg_test.v | 2 +- vlib/v/tests/go_anon_fn_variable_call_test.v | 4 +-- vlib/v/tests/go_array_wait_test.v | 22 ++++++------- .../tests/go_call_anon_fn_with_closure_test.v | 4 +-- vlib/v/tests/go_call_fn_return_test.v | 2 +- .../v/tests/go_call_fn_using_map_value_test.v | 2 +- .../tests/go_call_fn_with_anon_fn_arg_test.v | 2 +- vlib/v/tests/go_call_generic_fn_test.v | 2 +- vlib/v/tests/go_call_interface_method_test.v | 2 +- ...andle_for_functions_returning_array_test.v | 2 +- vlib/v/tests/go_wait_1_test.v | 2 +- vlib/v/tests/go_wait_2_test.v | 2 +- vlib/v/tests/go_wait_3_test.v | 2 +- vlib/v/tests/go_wait_option_test.v | 22 ++++++------- ...wait_with_fn_of_interface_parameter_test.v | 2 +- vlib/v/tests/init_global_test.v | 6 ++-- vlib/v/tests/inout/go_print.out | 2 +- vlib/v/tests/keep_args_alive_test.v | 4 +-- vlib/v/tests/option_2_test.v | 6 ++-- vlib/v/tests/reliability/semaphore_wait.v | 6 ++-- .../f1.v | 2 +- .../f2.v | 2 +- vlib/v/tests/semaphore_test.v | 4 +-- vlib/v/tests/semaphore_timed_test.v | 2 +- vlib/v/tests/shared_array_test.v | 8 ++--- vlib/v/tests/shared_autolock_test.v | 4 +-- vlib/v/tests/shared_lock_2_test.v | 2 +- vlib/v/tests/shared_lock_3_test.v | 2 +- vlib/v/tests/shared_lock_4_test.v | 2 +- vlib/v/tests/shared_lock_5_test.v | 6 ++-- vlib/v/tests/shared_lock_6_test.v | 10 +++--- vlib/v/tests/shared_lock_test.v | 2 +- vlib/v/tests/shared_map_test.v | 8 ++--- vlib/v/tests/shared_unordered_mixed_test.v | 6 ++-- vlib/v/tests/thread_to_string_test.v | 2 +- vlib/vweb/csrf/csrf_test.v | 2 +- vlib/vweb/tests/vweb_test.v | 2 +- vlib/vweb/tests/vweb_test_server.v | 4 +-- vlib/vweb/vweb.v | 2 +- vlib/vweb/vweb_app_test.v | 2 +- 126 files changed, 262 insertions(+), 262 deletions(-) diff --git a/cmd/tools/modules/testing/common.v b/cmd/tools/modules/testing/common.v index a2ce36113..daa5e93e1 100644 --- a/cmd/tools/modules/testing/common.v +++ b/cmd/tools/modules/testing/common.v @@ -298,7 +298,7 @@ pub fn (mut ts TestSession) test() { ts.nmessages = chan LogMessage{cap: 10000} ts.nprint_ended = chan int{cap: 0} ts.nmessage_idx = 0 - go ts.print_messages() + spawn ts.print_messages() pool_of_test_runners.set_shared_context(ts) pool_of_test_runners.work_on_pointers(unsafe { remaining_files.pointers() }) ts.benchmark.stop() diff --git a/cmd/tools/test_os_process.v b/cmd/tools/test_os_process.v index bc275dd53..40000b800 100644 --- a/cmd/tools/test_os_process.v +++ b/cmd/tools/test_os_process.v @@ -73,7 +73,7 @@ fn main() { if ctx.is_verbose { eprintln('> args: $args | context: $ctx') } - go do_timeout(&ctx) + spawn do_timeout(&ctx) for i := 1; true; i++ { ctx.println('$i') time.sleep(ctx.period_ms * time.millisecond) diff --git a/cmd/tools/vdoc/vdoc.v b/cmd/tools/vdoc/vdoc.v index 862d5f433..cb1125f64 100644 --- a/cmd/tools/vdoc/vdoc.v +++ b/cmd/tools/vdoc/vdoc.v @@ -210,7 +210,7 @@ fn (vd VDoc) render_parallel(out Output) { work.close() wg.add(vjobs) for _ in 0 .. vjobs { - go vd.work_processor(mut work, mut wg) + spawn vd.work_processor(mut work, mut wg) } wg.wait() } diff --git a/cmd/tools/vtest-parser.v b/cmd/tools/vtest-parser.v index de8d4ca92..ae19cf3f0 100644 --- a/cmd/tools/vtest-parser.v +++ b/cmd/tools/vtest-parser.v @@ -57,7 +57,7 @@ fn main() { mut source := os.read_file(context.path)! source = source[..context.cut_index] - go fn (ms int) { + spawn fn (ms int) { time.sleep(ms * time.millisecond) exit(ecode_timeout) }(context.timeout_ms) @@ -248,7 +248,7 @@ fn (mut context Context) start_printing() { if !context.is_linear && !context.is_silent { println('\n') } - go context.print_periodic_status() + spawn context.print_periodic_status() } fn (mut context Context) stop_printing() { diff --git a/cmd/tools/vwatch.v b/cmd/tools/vwatch.v index 9fb8d2f28..625933244 100644 --- a/cmd/tools/vwatch.v +++ b/cmd/tools/vwatch.v @@ -381,6 +381,6 @@ fn (mut context Context) worker_main() { context.is_exiting = true context.kill_pgroup() }) or { panic(err) } - go context.compilation_runner_loop() + spawn context.compilation_runner_loop() change_detection_loop(context) } diff --git a/examples/concurrency/concurrency.v b/examples/concurrency/concurrency.v index 92a5517e8..738c86347 100644 --- a/examples/concurrency/concurrency.v +++ b/examples/concurrency/concurrency.v @@ -9,9 +9,9 @@ fn expensive_computing(id int, duration int) { fn main() { mut threads := []thread{} - threads << go expensive_computing(1, 100) - threads << go expensive_computing(2, 500) - threads << go expensive_computing(3, 1000) + 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!') diff --git a/examples/concurrency/concurrency_http.v b/examples/concurrency/concurrency_http.v index 39de5a765..5db549415 100644 --- a/examples/concurrency/concurrency_http.v +++ b/examples/concurrency/concurrency_http.v @@ -26,7 +26,7 @@ fn main() { mut wg := sync.new_waitgroup() wg.add(2) // Run tasks async - go vlang_time(mut wg) - go remote_ip(mut wg) + spawn vlang_time(mut wg) + spawn remote_ip(mut wg) wg.wait() } diff --git a/examples/concurrency/concurrency_returns.v b/examples/concurrency/concurrency_returns.v index 6d687e4f2..aa26c656d 100644 --- a/examples/concurrency/concurrency_returns.v +++ b/examples/concurrency/concurrency_returns.v @@ -5,7 +5,7 @@ fn expensive_computing(i int) int { fn main() { mut threads := []thread int{} for i in 1 .. 10 { - threads << go expensive_computing(i) + threads << spawn expensive_computing(i) } // Join all tasks r := threads.wait() diff --git a/examples/flappylearning/game.v b/examples/flappylearning/game.v index 5643b8e1d..c40f6e0b8 100644 --- a/examples/flappylearning/game.v +++ b/examples/flappylearning/game.v @@ -198,7 +198,7 @@ fn main() { network: [2, 2, 1] } app.start() - go app.run() + spawn app.run() app.gg.run() } diff --git a/examples/gg/mandelbrot.v b/examples/gg/mandelbrot.v index 1e8661ede..0d11218d3 100644 --- a/examples/gg/mandelbrot.v +++ b/examples/gg/mandelbrot.v @@ -58,7 +58,7 @@ fn (mut state AppState) update() { threads.wait() } for t in 0 .. state.ntasks { - threads << go state.worker(t, chunk_channel, chunk_ready_channel) + threads << spawn state.worker(t, chunk_channel, chunk_ready_channel) } // mut oview := ViewRect{} @@ -237,6 +237,6 @@ fn main() { scroll_fn: graphics_scroll user_data: state ) - go state.update() + spawn state.update() state.gg.run() } diff --git a/examples/gg/random.v b/examples/gg/random.v index b90b1da9e..2de6c32e9 100644 --- a/examples/gg/random.v +++ b/examples/gg/random.v @@ -58,6 +58,6 @@ fn main() { frame_fn: graphics_frame user_data: state ) - go state.update() + spawn state.update() state.gg.run() } diff --git a/examples/gg/worker_thread.v b/examples/gg/worker_thread.v index 285b3f6e9..1d5231fd8 100644 --- a/examples/gg/worker_thread.v +++ b/examples/gg/worker_thread.v @@ -42,7 +42,7 @@ fn main() { fn init(mut app App) { // Spawn a new worker thread. - go worker(mut app) + spawn worker(mut app) } // worker simulates a workload. This should be run in a separate thread. diff --git a/examples/hot_reload/bounce.v b/examples/hot_reload/bounce.v index 14ff96ecb..0ff663b00 100644 --- a/examples/hot_reload/bounce.v +++ b/examples/hot_reload/bounce.v @@ -45,7 +45,7 @@ fn main() { ) // window.onkeydown(key_down) println('Starting the game loop...') - go game.run() + spawn game.run() game.gg.run() } diff --git a/examples/net_t.v b/examples/net_t.v index c2ff47fb4..742011403 100644 --- a/examples/net_t.v +++ b/examples/net_t.v @@ -15,7 +15,7 @@ fn main() { mut wg := sync.new_waitgroup() for i := 0; i < 50; i++ { wg.add(1) - go send_request(mut wg) + spawn send_request(mut wg) } wg.wait() } diff --git a/examples/pendulum-simulation/animation.v b/examples/pendulum-simulation/animation.v index 9d41b826b..4fd84ef86 100644 --- a/examples/pendulum-simulation/animation.v +++ b/examples/pendulum-simulation/animation.v @@ -24,14 +24,14 @@ fn main() { } for id in 0 .. args.workers { - workers << go sim.sim_worker(id, app.request_chan, [app.result_chan]) + workers << spawn sim.sim_worker(id, app.request_chan, [app.result_chan]) } handle_request := fn [app] (request &sim.SimRequest) ! { app.request_chan <- request } - go app.gg.run() + spawn app.gg.run() sim.run(args.params, grid: args.grid, on_request: sim.SimRequestHandler(handle_request)) } diff --git a/examples/pendulum-simulation/full.v b/examples/pendulum-simulation/full.v index 796e6cd86..0139f55c5 100644 --- a/examples/pendulum-simulation/full.v +++ b/examples/pendulum-simulation/full.v @@ -38,16 +38,16 @@ fn main() { // start a worker on each core for id in 0 .. app.args.workers { - workers << go sim.sim_worker(id, app.request_chan, [app.result_chan, img_result_chan]) + workers << spawn sim.sim_worker(id, app.request_chan, [app.result_chan, img_result_chan]) } handle_request := fn [app] (request &sim.SimRequest) ! { app.request_chan <- request } - workers << go img.image_worker(mut writer, img_result_chan, img_settings) + workers << spawn img.image_worker(mut writer, img_result_chan, img_settings) - go app.gg.run() + spawn app.gg.run() sim.run(app.args.params, grid: app.args.grid diff --git a/examples/pendulum-simulation/modules/sim/anim/app.v b/examples/pendulum-simulation/modules/sim/anim/app.v index 9c9fda7bb..d393c0b4e 100644 --- a/examples/pendulum-simulation/modules/sim/anim/app.v +++ b/examples/pendulum-simulation/modules/sim/anim/app.v @@ -48,7 +48,7 @@ pub fn new_app(args simargs.ParallelArgs) &App { fn init(mut app App) { app.iidx = app.gg.new_streaming_image(app.args.grid.width, app.args.grid.height, 4, pixel_format: .rgba8) - go pixels_worker(mut app) + spawn pixels_worker(mut app) } fn frame(mut app App) { diff --git a/examples/pendulum-simulation/parallel.v b/examples/pendulum-simulation/parallel.v index 416a69b5c..c0b1fc3c9 100644 --- a/examples/pendulum-simulation/parallel.v +++ b/examples/pendulum-simulation/parallel.v @@ -35,7 +35,7 @@ fn main() { } for id in 0 .. args.workers { - workers << go sim.sim_worker(id, request_chan, [result_chan]) + workers << spawn sim.sim_worker(id, request_chan, [result_chan]) } mut x := 0 diff --git a/examples/pendulum-simulation/parallel_with_iw.v b/examples/pendulum-simulation/parallel_with_iw.v index 96911c3d2..33e4929f0 100644 --- a/examples/pendulum-simulation/parallel_with_iw.v +++ b/examples/pendulum-simulation/parallel_with_iw.v @@ -34,10 +34,10 @@ fn main() { } for id in 0 .. args.workers { - workers << go sim.sim_worker(id, request_chan, [result_chan]) + workers << spawn sim.sim_worker(id, request_chan, [result_chan]) } - workers << go img.image_worker(mut writer, result_chan, img_settings) + workers << spawn img.image_worker(mut writer, result_chan, img_settings) handle_request := fn [request_chan] (request &sim.SimRequest) ! { request_chan <- request diff --git a/examples/quadtree_demo/quadtree_demo.v b/examples/quadtree_demo/quadtree_demo.v index 557e98ad3..a209a0557 100644 --- a/examples/quadtree_demo/quadtree_demo.v +++ b/examples/quadtree_demo/quadtree_demo.v @@ -129,7 +129,7 @@ fn main() { ) app.qt = app.qt.create(0, 0, 1340, 640, 8, 4, 0) app.start() - go app.run() + spawn app.run() app.gg.run() } diff --git a/examples/tcp_echo_server.v b/examples/tcp_echo_server.v index 7fa0b5887..26ca7691d 100644 --- a/examples/tcp_echo_server.v +++ b/examples/tcp_echo_server.v @@ -14,7 +14,7 @@ fn main() { eprintln('Listen on $laddr ...') for { mut socket := server.accept()! - go handle_client(mut socket) + spawn handle_client(mut socket) } } diff --git a/examples/websocket/client-server/client.v b/examples/websocket/client-server/client.v index cb20bdf36..f7ba20fea 100644 --- a/examples/websocket/client-server/client.v +++ b/examples/websocket/client-server/client.v @@ -49,6 +49,6 @@ fn start_client() !&websocket.Client { ws.connect() or { println(term.red('error on connect: $err')) } - go ws.listen() // or { println(term.red('error on listen $err')) } + spawn ws.listen() // or { println(term.red('error on listen $err')) } return ws } diff --git a/examples/websocket/ping.v b/examples/websocket/ping.v index 967841470..ef600aa1a 100644 --- a/examples/websocket/ping.v +++ b/examples/websocket/ping.v @@ -4,7 +4,7 @@ import time import net.websocket fn main() { - go start_server() + spawn start_server() time.sleep(100 * time.millisecond) start_client()! } @@ -65,7 +65,7 @@ fn start_client() ! { // // println('type: $msg.opcode payload:\n$msg.payload ref: $r') // }, &r) ws.connect() or { println('error on connect: $err') } - go write_echo(mut ws) // or { println('error on write_echo $err') } + spawn write_echo(mut ws) // or { println('error on write_echo $err') } ws.listen() or { println('error on listen $err') } unsafe { ws.free() diff --git a/vlib/clipboard/x11/clipboard.c.v b/vlib/clipboard/x11/clipboard.c.v index ca9b26f31..35365efa9 100644 --- a/vlib/clipboard/x11/clipboard.c.v +++ b/vlib/clipboard/x11/clipboard.c.v @@ -195,7 +195,7 @@ fn new_x11_clipboard(selection AtomType) &Clipboard { cb.selection = cb.get_atom(selection) // start the listener on another thread or // we will be locked and will have to hard exit - go cb.start_listener() + spawn cb.start_listener() return cb } diff --git a/vlib/context/cancel.v b/vlib/context/cancel.v index 9f1d7b4b5..9c23a2d05 100644 --- a/vlib/context/cancel.v +++ b/vlib/context/cancel.v @@ -141,7 +141,7 @@ fn propagate_cancel(mut parent Context, mut child Canceler) { } } mut p := parent_cancel_context(mut parent) or { - go fn (mut parent Context, mut child Canceler) { + spawn fn (mut parent Context, mut child Canceler) { pdone := parent.done() select { _ := <-pdone { diff --git a/vlib/context/cancel_test.v b/vlib/context/cancel_test.v index f9d055d2d..f1674e780 100644 --- a/vlib/context/cancel_test.v +++ b/vlib/context/cancel_test.v @@ -13,7 +13,7 @@ fn test_with_cancel() { // the internal routine started by gen. gen := fn (mut ctx context.Context) chan int { dst := chan int{} - go fn (mut ctx context.Context, dst chan int) { + spawn fn (mut ctx context.Context, dst chan int) { mut v := 0 ch := ctx.done() for { diff --git a/vlib/context/deadline.v b/vlib/context/deadline.v index e44810de7..0c04a3f98 100644 --- a/vlib/context/deadline.v +++ b/vlib/context/deadline.v @@ -51,7 +51,7 @@ pub fn with_deadline(mut parent Context, d time.Time) (Context, CancelFn) { } if ctx.err() is none { - go fn (mut ctx TimerContext, dur time.Duration) { + spawn fn (mut ctx TimerContext, dur time.Duration) { time.sleep(dur) ctx.cancel(true, deadline_exceeded) }(mut ctx, dur) diff --git a/vlib/context/onecontext/onecontext.v b/vlib/context/onecontext/onecontext.v index 9de76069b..70f5d0988 100644 --- a/vlib/context/onecontext/onecontext.v +++ b/vlib/context/onecontext/onecontext.v @@ -30,7 +30,7 @@ pub fn merge(ctx context.Context, ctxs ...context.Context) (context.Context, con cancel_fn: cancel cancel_ctx: cancel_ctx } - go octx.run() + spawn octx.run() return context.Context(octx), context.CancelFn(cancel) } @@ -112,7 +112,7 @@ pub fn (mut octx OneContext) cancel(err IError) { } pub fn (mut octx OneContext) run_two_contexts(mut ctx1 context.Context, mut ctx2 context.Context) { - go fn (mut octx OneContext, mut ctx1 context.Context, mut ctx2 context.Context) { + spawn fn (mut octx OneContext, mut ctx1 context.Context, mut ctx2 context.Context) { octx_cancel_done := octx.cancel_ctx.done() c1done := ctx1.done() c2done := ctx2.done() @@ -131,7 +131,7 @@ pub fn (mut octx OneContext) run_two_contexts(mut ctx1 context.Context, mut ctx2 } pub fn (mut octx OneContext) run_multiple_contexts(mut ctx context.Context) { - go fn (mut octx OneContext, mut ctx context.Context) { + spawn fn (mut octx OneContext, mut ctx context.Context) { octx_cancel_done := octx.cancel_ctx.done() cdone := ctx.done() select { diff --git a/vlib/log/log_test.v b/vlib/log/log_test.v index 92160a64b..e6c1a7337 100644 --- a/vlib/log/log_test.v +++ b/vlib/log/log_test.v @@ -63,7 +63,7 @@ fn test_log_mutable_reference() { println(@FN + ' start') mut log := new_log() assert typeof(log).name == '&log.Log' - go log_mutable_statements(mut log) + spawn log_mutable_statements(mut log) delay() // wait to finish assert true println(@FN + ' end') @@ -75,7 +75,7 @@ fn test_logger_mutable_reference() { mut logger := new_log_as_logger() logger.set_level(.warn) assert typeof(logger).name == '&log.Logger' - go logger_mutable_statements(mut logger) + spawn logger_mutable_statements(mut logger) delay() // wait to finish assert true println(@FN + ' end') diff --git a/vlib/net/http/server_test.v b/vlib/net/http/server_test.v index 70db4d597..99ae5fdd2 100644 --- a/vlib/net/http/server_test.v +++ b/vlib/net/http/server_test.v @@ -5,7 +5,7 @@ fn test_server_stop() { mut server := &http.Server{ accept_timeout: 1 * time.second } - t := go server.listen_and_serve() + t := spawn server.listen_and_serve() time.sleep(250 * time.millisecond) mut watch := time.new_stopwatch() server.stop() @@ -20,7 +20,7 @@ fn test_server_close() { accept_timeout: 1 * time.second handler: MyHttpHandler{} } - t := go server.listen_and_serve() + t := spawn server.listen_and_serve() time.sleep(250 * time.millisecond) mut watch := time.new_stopwatch() server.close() @@ -67,7 +67,7 @@ fn test_server_custom_handler() { handler: handler port: cport } - t := go server.listen_and_serve() + t := spawn server.listen_and_serve() for server.status() != .running { time.sleep(10 * time.millisecond) } diff --git a/vlib/net/tcp_self_dial_from_many_clients_test.v b/vlib/net/tcp_self_dial_from_many_clients_test.v index b6cd18fc4..43cb5f0f9 100644 --- a/vlib/net/tcp_self_dial_from_many_clients_test.v +++ b/vlib/net/tcp_self_dial_from_many_clients_test.v @@ -67,7 +67,7 @@ fn start_server(schannel chan int, shared ctx Context) { } continue } - go receive_data(mut tcp_con, shared ctx) + spawn receive_data(mut tcp_con, shared ctx) lock ctx { ctx.ok_server_accepts++ } @@ -109,11 +109,11 @@ fn test_tcp_self_dialing() { start_time := time.now() shared ctx := &Context{} mut server_channel := chan int{cap: 1} - go start_server(server_channel, shared ctx) + spawn start_server(server_channel, shared ctx) svalue := <-server_channel elog('>>> server was started: ${svalue}. Starting clients:') for i := int(0); i < 20; i++ { - go start_client(i, shared ctx) + spawn start_client(i, shared ctx) elog('>>> started client $i') // time.sleep(2 * time.millisecond) } diff --git a/vlib/net/tcp_simple_client_server_test.v b/vlib/net/tcp_simple_client_server_test.v index 947b2c335..2125ee1fc 100644 --- a/vlib/net/tcp_simple_client_server_test.v +++ b/vlib/net/tcp_simple_client_server_test.v @@ -14,7 +14,7 @@ fn setup() (&net.TcpListener, &net.TcpConn, &net.TcpConn) { mut server := net.listen_tcp(.ip6, server_port) or { panic(err) } c := chan &net.TcpConn{} - go accept(mut server, c) + spawn accept(mut server, c) mut client := net.dial_tcp('localhost$server_port') or { panic(err) } socket := <-c diff --git a/vlib/net/tcp_test.v b/vlib/net/tcp_test.v index 66415f7bc..2c6c9e2f5 100644 --- a/vlib/net/tcp_test.v +++ b/vlib/net/tcp_test.v @@ -64,7 +64,7 @@ fn test_tcp_ip6() { fn start_echo_server(mut l net.TcpListener) { ch_server_started := chan int{} - go one_shot_echo_server(mut l, ch_server_started) + spawn one_shot_echo_server(mut l, ch_server_started) _ := <-ch_server_started } diff --git a/vlib/net/udp_test.v b/vlib/net/udp_test.v index 5ca749ac6..a86ce5ddb 100644 --- a/vlib/net/udp_test.v +++ b/vlib/net/udp_test.v @@ -54,7 +54,7 @@ fn echo() ! { fn test_udp() { mut l := net.listen_udp(server_addr) or { panic('could not listen_udp: $err') } - go echo_server(mut l) + spawn echo_server(mut l) echo() or { panic('could not echo: $err') } l.close() or {} diff --git a/vlib/net/unix/unix_test.v b/vlib/net/unix/unix_test.v index 547f81043..7526a1469 100644 --- a/vlib/net/unix/unix_test.v +++ b/vlib/net/unix/unix_test.v @@ -30,7 +30,7 @@ fn handle_conn(mut c unix.StreamConn) { fn echo_server(mut l unix.StreamListener) ! { for { mut new_conn := l.accept() or { continue } - go handle_conn(mut new_conn) + spawn handle_conn(mut new_conn) } } @@ -54,7 +54,7 @@ fn echo() ! { fn test_tcp() { assert os.exists(test_port) == false mut l := unix.listen_stream(test_port) or { panic(err) } - go echo_server(mut l) + spawn echo_server(mut l) echo() or { panic(err) } l.close() or {} } diff --git a/vlib/net/unix/use_net_and_net_unix_together_test.v b/vlib/net/unix/use_net_and_net_unix_together_test.v index 5ff7a8ba5..358ae799b 100644 --- a/vlib/net/unix/use_net_and_net_unix_together_test.v +++ b/vlib/net/unix/use_net_and_net_unix_together_test.v @@ -19,7 +19,7 @@ fn testsuite_end() { fn test_that_net_and_net_unix_can_be_imported_together_without_conflicts() { mut l := unix.listen_stream(test_port) or { panic(err) } - go echo_server(mut l) + spawn echo_server(mut l) defer { l.close() or {} } diff --git a/vlib/net/websocket/websocket_server.v b/vlib/net/websocket/websocket_server.v index 32e17e7ea..71da1b095 100644 --- a/vlib/net/websocket/websocket_server.v +++ b/vlib/net/websocket/websocket_server.v @@ -64,10 +64,10 @@ pub fn (mut s Server) listen() ! { s.logger.info('websocket server: start listen on port $s.port') s.ls = net.listen_tcp(s.family, ':$s.port')! s.set_state(.open) - go s.handle_ping() + spawn s.handle_ping() for { mut c := s.accept_new_client() or { continue } - go s.serve_client(mut c) + spawn s.serve_client(mut c) } s.logger.info('websocket server: end listen on port $s.port') } diff --git a/vlib/net/websocket/websocket_test.v b/vlib/net/websocket/websocket_test.v index 2d04990fa..4cffba439 100644 --- a/vlib/net/websocket/websocket_test.v +++ b/vlib/net/websocket/websocket_test.v @@ -27,7 +27,7 @@ fn test_ws_ipv6() { } port := 30000 + rand.intn(1024) or { 0 } eprintln('> port ipv6: $port') - go start_server(.ip6, port) + spawn start_server(.ip6, port) time.sleep(1500 * time.millisecond) ws_test(.ip6, 'ws://localhost:$port') or { eprintln('> error while connecting .ip6, err: $err') @@ -42,7 +42,7 @@ fn test_ws_ipv4() { } port := 30000 + rand.intn(1024) or { 0 } eprintln('> port ipv4: $port') - go start_server(.ip, port) + spawn start_server(.ip, port) time.sleep(1500 * time.millisecond) ws_test(.ip, 'ws://localhost:$port') or { eprintln('> error while connecting .ip, err: $err') @@ -113,7 +113,7 @@ fn ws_test(family net.AddrFamily, uri string) ! { } }, test_results) ws.connect() or { panic('fail to connect, err: $err') } - go ws.listen() + spawn ws.listen() text := ['a'].repeat(2) for msg in text { ws.write(msg.bytes(), .text_frame) or { panic('fail to write to websocket, err: $err') } diff --git a/vlib/picoev/picoev.v b/vlib/picoev/picoev.v index fd20105e7..d02a78aee 100644 --- a/vlib/picoev/picoev.v +++ b/vlib/picoev/picoev.v @@ -240,7 +240,7 @@ pub fn new(config Config) &Picoev { } C.picoev_add(voidptr(loop), fd, int(Event.read), 0, accept_callback, pv) - go update_date(mut pv) + spawn update_date(mut pv) return pv } diff --git a/vlib/sync/bench/channel_bench_v.v b/vlib/sync/bench/channel_bench_v.v index 48f026989..96ea2d644 100644 --- a/vlib/sync/bench/channel_bench_v.v +++ b/vlib/sync/bench/channel_bench_v.v @@ -38,7 +38,7 @@ fn main() { mut no := nobj for i in 0 .. nrec { n := no / (nrec - i) - go do_rec(ch, resch, n) + spawn do_rec(ch, resch, n) no -= n } $if debug { @@ -49,7 +49,7 @@ fn main() { n := no / (nsend - i) end := no no -= n - go do_send(ch, no, end) + spawn do_send(ch, no, end) } assert no == 0 mut sum := i64(0) diff --git a/vlib/sync/bench/many_writers_and_receivers_on_1_channel.v b/vlib/sync/bench/many_writers_and_receivers_on_1_channel.v index e1cd96872..529c0c500 100644 --- a/vlib/sync/bench/many_writers_and_receivers_on_1_channel.v +++ b/vlib/sync/bench/many_writers_and_receivers_on_1_channel.v @@ -117,11 +117,11 @@ fn main() { } ctx.pops_wg.add(n_readers) for i := 0; i < n_readers; i++ { - go do_rec(ch, i, mut ctx) + spawn do_rec(ch, i, mut ctx) } ctx.pushes_wg.add(n_writers) for i := 0; i < n_writers; i++ { - go do_send(ch, i, mut ctx) + spawn do_send(ch, i, mut ctx) } ctx.pushes_wg.wait() eprintln('>> all pushes done') diff --git a/vlib/sync/channel_1_test.v b/vlib/sync/channel_1_test.v index 17588fd48..745441a09 100644 --- a/vlib/sync/channel_1_test.v +++ b/vlib/sync/channel_1_test.v @@ -10,7 +10,7 @@ fn do_send(ch chan int) { fn test_channel_buffered() { ch := chan int{cap: 1000} - go do_send(ch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. num_iterations { sum += <-ch diff --git a/vlib/sync/channel_2_test.v b/vlib/sync/channel_2_test.v index 5e8251d86..3b28032f1 100644 --- a/vlib/sync/channel_2_test.v +++ b/vlib/sync/channel_2_test.v @@ -10,7 +10,7 @@ fn do_send(ch chan int) { fn test_channel_unbuffered() { ch := chan int{} - go do_send(ch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. num_iterations { sum += <-ch diff --git a/vlib/sync/channel_3_test.v b/vlib/sync/channel_3_test.v index d07276b0d..78ea10553 100644 --- a/vlib/sync/channel_3_test.v +++ b/vlib/sync/channel_3_test.v @@ -16,14 +16,14 @@ fn do_send(ch chan int) { fn test_channel_multi_unbuffered() { ch := chan int{} resch := chan i64{} - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_send(ch) - go do_send(ch) - go do_send(ch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_send(ch) + spawn do_send(ch) + spawn do_send(ch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. 4 { sum += <-resch diff --git a/vlib/sync/channel_4_test.v b/vlib/sync/channel_4_test.v index 379266870..acb80a94f 100644 --- a/vlib/sync/channel_4_test.v +++ b/vlib/sync/channel_4_test.v @@ -16,14 +16,14 @@ fn do_send(ch chan int) { fn test_channel_multi_buffered() { ch := chan int{cap: 100} resch := chan i64{} - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_send(ch) - go do_send(ch) - go do_send(ch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_send(ch) + spawn do_send(ch) + spawn do_send(ch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. 4 { sum += <-resch diff --git a/vlib/sync/channel_array_mut_test.v b/vlib/sync/channel_array_mut_test.v index bfd53a1aa..edeb0ef99 100644 --- a/vlib/sync/channel_array_mut_test.v +++ b/vlib/sync/channel_array_mut_test.v @@ -22,7 +22,7 @@ fn do_rec_calc_send(chs []chan mut St) { fn test_channel_array_mut() { mut chs := [chan mut St{cap: 1}, chan mut St{}] - go do_rec_calc_send(chs) + spawn do_rec_calc_send(chs) mut t := &St{ n: 100 } diff --git a/vlib/sync/channel_close_test.v b/vlib/sync/channel_close_test.v index a31bfa91c..3d67271fb 100644 --- a/vlib/sync/channel_close_test.v +++ b/vlib/sync/channel_close_test.v @@ -23,11 +23,11 @@ fn do_send(ch chan int) { fn test_channel_close_buffered_multi() { ch := chan int{cap: 10} resch := chan i64{} - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. 4 { sum += <-resch @@ -38,11 +38,11 @@ fn test_channel_close_buffered_multi() { fn test_channel_close_unbuffered_multi() { ch := chan int{} resch := chan i64{} - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_rec(ch, resch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_rec(ch, resch) + spawn do_send(ch) mut sum := i64(0) for _ in 0 .. 4 { sum += <-resch @@ -53,8 +53,8 @@ fn test_channel_close_unbuffered_multi() { fn test_channel_close_buffered() { ch := chan int{cap: 100} resch := chan i64{} - go do_rec(ch, resch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_send(ch) mut sum := i64(0) sum += <-resch assert sum == i64(8000) * (8000 - 1) / 2 @@ -63,8 +63,8 @@ fn test_channel_close_buffered() { fn test_channel_close_unbuffered() { ch := chan int{} resch := chan i64{cap: 100} - go do_rec(ch, resch) - go do_send(ch) + spawn do_rec(ch, resch) + spawn do_send(ch) mut sum := i64(0) sum += <-resch assert sum == i64(8000) * (8000 - 1) / 2 @@ -72,7 +72,7 @@ fn test_channel_close_unbuffered() { fn test_channel_send_close_buffered() { ch := chan int{cap: 1} - t := go fn (ch chan int) { + t := spawn fn (ch chan int) { ch <- 31 mut x := 45 ch <- 17 or { x = -133 } @@ -90,7 +90,7 @@ fn test_channel_send_close_buffered() { fn test_channel_send_close_unbuffered() { time.sleep(1 * time.second) ch := chan int{} - t := go fn (ch chan int) { + t := spawn fn (ch chan int) { mut x := 31 ch <- 177 or { x = -71 } diff --git a/vlib/sync/channel_fill_test.v b/vlib/sync/channel_fill_test.v index b4eabc0a7..5e89a85c9 100644 --- a/vlib/sync/channel_fill_test.v +++ b/vlib/sync/channel_fill_test.v @@ -15,7 +15,7 @@ fn do_send(ch chan int, mut fin sync.Semaphore) { fn test_channel_len_cap() { ch := chan int{cap: queue_len} mut sem := sync.new_semaphore() - go do_send(ch, mut sem) + spawn do_send(ch, mut sem) sem.wait() assert ch.cap == queue_len assert ch.len == queue_fill diff --git a/vlib/sync/channel_opt_propagate_test.v b/vlib/sync/channel_opt_propagate_test.v index 0bab011ef..ee78023c6 100644 --- a/vlib/sync/channel_opt_propagate_test.v +++ b/vlib/sync/channel_opt_propagate_test.v @@ -27,7 +27,7 @@ fn do_rec_calc_send(chs []chan i64, mut sem sync.Semaphore) { fn test_channel_array_mut() { mut chs := [chan i64{}, chan i64{cap: 10}] mut sem := sync.new_semaphore() - go do_rec_calc_send(chs, mut sem) + spawn do_rec_calc_send(chs, mut sem) mut t := i64(100) for _ in 0 .. num_iterations { chs[0] <- t diff --git a/vlib/sync/channel_polling_test.v b/vlib/sync/channel_polling_test.v index 846dcfd34..a7bb24717 100644 --- a/vlib/sync/channel_polling_test.v +++ b/vlib/sync/channel_polling_test.v @@ -36,13 +36,13 @@ fn test_channel_polling() { ch := chan int{cap: buflen} resch := chan i64{} for _ in 0 .. nrec { - go do_rec(ch, resch, objs_per_thread) + spawn do_rec(ch, resch, objs_per_thread) } mut n := nobj for _ in 0 .. nsend { end := n n -= objs_per_thread - go do_send(ch, n, end) + spawn do_send(ch, n, end) } mut sum := i64(0) for _ in 0 .. nrec { diff --git a/vlib/sync/channel_push_or_1_test.v b/vlib/sync/channel_push_or_1_test.v index 1551d830d..1ad57d612 100644 --- a/vlib/sync/channel_push_or_1_test.v +++ b/vlib/sync/channel_push_or_1_test.v @@ -11,7 +11,7 @@ fn f(ch chan int) { fn test_push_or_unbuffered() { ch := chan int{} - go f(ch) + spawn f(ch) mut j := 0 for { ch <- j or { break } @@ -23,7 +23,7 @@ fn test_push_or_unbuffered() { fn test_push_or_buffered() { ch := chan int{cap: c} - go f(ch) + spawn f(ch) mut j := 0 for { ch <- j or { break } @@ -50,9 +50,9 @@ fn g(ch chan int, res chan int) { fn test_many_senders() { ch := chan int{} res := chan int{} - go g(ch, res) - go g(ch, res) - go g(ch, res) + spawn g(ch, res) + spawn g(ch, res) + spawn g(ch, res) mut k := 0 for _ in 0 .. 3 * n { k = <-ch diff --git a/vlib/sync/channel_push_or_2_test.v b/vlib/sync/channel_push_or_2_test.v index 040e81413..6aaf0fb5b 100644 --- a/vlib/sync/channel_push_or_2_test.v +++ b/vlib/sync/channel_push_or_2_test.v @@ -16,7 +16,7 @@ fn do_send(ch chan f64, val f64) ?f64 { fn test_push_propargate() { ch := chan f64{} - go f(ch) + spawn f(ch) mut s := 1.0 for { s = do_send(ch, s) or { break } diff --git a/vlib/sync/channel_select_2_test.v b/vlib/sync/channel_select_2_test.v index 0c1b830d8..f8ffdd7fa 100644 --- a/vlib/sync/channel_select_2_test.v +++ b/vlib/sync/channel_select_2_test.v @@ -31,10 +31,10 @@ fn test_select() { chl := chan i64{cap: 1} chb := chan u8{cap: 10} recch := chan i64{cap: 0} - go do_rec_i64(recch) - go do_send_int(chi) - go do_send_u8(chb) - go do_send_i64(chl) + spawn do_rec_i64(recch) + spawn do_send_int(chi) + spawn do_send_u8(chb) + spawn do_send_i64(chl) mut sum := i64(0) mut rl := i64(0) mut sl := i64(0) diff --git a/vlib/sync/channel_select_3_test.v b/vlib/sync/channel_select_3_test.v index fdf609659..99e4c34fd 100644 --- a/vlib/sync/channel_select_3_test.v +++ b/vlib/sync/channel_select_3_test.v @@ -79,7 +79,7 @@ fn test_select_blocks() { } assert r == true assert t == true - go f2(ch2, ch3, mut sem) + spawn f2(ch2, ch3, mut sem) n := <-ch3 assert n == 23 ch2 <- St{ @@ -87,7 +87,7 @@ fn test_select_blocks() { } sem.wait() stopwatch := time.new_stopwatch() - go f1(ch1, ch2, ch3, ch4, ch5, mut sem) + spawn f1(ch1, ch2, ch3, ch4, ch5, mut sem) sem.wait() elapsed_ms := f64(stopwatch.elapsed()) / time.millisecond // https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/high-resolution-timers diff --git a/vlib/sync/channel_select_4_test.v b/vlib/sync/channel_select_4_test.v index 77cd5574e..60f2f51d5 100644 --- a/vlib/sync/channel_select_4_test.v +++ b/vlib/sync/channel_select_4_test.v @@ -16,8 +16,8 @@ fn test_select() { chi := chan int{cap: 10} recch := chan i64{cap: 10} chsum := chan i64{} - go do_rec_i64(recch, chsum) - go do_send_int(chi) + spawn do_rec_i64(recch, chsum) + spawn do_send_int(chi) mut sum := i64(0) mut sl := i64(0) for _ in 0 .. 60000 + recch.cap { diff --git a/vlib/sync/channel_select_5_test.v b/vlib/sync/channel_select_5_test.v index 97228fe73..622cde9b4 100644 --- a/vlib/sync/channel_select_5_test.v +++ b/vlib/sync/channel_select_5_test.v @@ -28,12 +28,12 @@ fn test_select() { chi := chan int{cap: 10} recch := chan i64{cap: 10} chsum := chan i64{} - go do_rec_i64(recch, chsum) - go do_rec_i64(recch, chsum) - go do_rec_i64(recch, chsum) - go do_send_int(chi) - go do_send_int2(chi) - go do_send_int3(chi) + spawn do_rec_i64(recch, chsum) + spawn do_rec_i64(recch, chsum) + spawn do_rec_i64(recch, chsum) + spawn do_send_int(chi) + spawn do_send_int2(chi) + spawn do_send_int3(chi) mut sum := i64(0) mut sl := i64(0) for _ in 0 .. 60000 + recch.cap { diff --git a/vlib/sync/channel_select_6_test.v b/vlib/sync/channel_select_6_test.v index cce63fecf..3186f470a 100644 --- a/vlib/sync/channel_select_6_test.v +++ b/vlib/sync/channel_select_6_test.v @@ -51,15 +51,15 @@ fn test_select() { chsum2 := chan i64{} chsumf1 := chan f64{} chsumf2 := chan f64{} - go do_send_int(ch1, 3) - go do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) - go do_rec_f64(chf1, chsumf1) - go do_rec_f64(chf2, chsumf2) - go do_rec_f64(chf2, chsumf2) - go do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) - go do_send_int(ch2, 7) - go do_send_int(ch2, 17) - go do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) + spawn do_send_int(ch1, 3) + spawn do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) + spawn do_rec_f64(chf1, chsumf1) + spawn do_rec_f64(chf2, chsumf2) + spawn do_rec_f64(chf2, chsumf2) + spawn do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) + spawn do_send_int(ch2, 7) + spawn do_send_int(ch2, 17) + spawn do_select(ch1, ch2, chf1, chf2, chsum1, chsum2) sum1 := <-chsum1 + <-chsum1 + <-chsum1 sum2 := <-chsum2 + <-chsum2 + <-chsum2 diff --git a/vlib/sync/channel_select_test.v b/vlib/sync/channel_select_test.v index cd0c4004b..65a030fa7 100644 --- a/vlib/sync/channel_select_test.v +++ b/vlib/sync/channel_select_test.v @@ -53,10 +53,10 @@ fn test_select() { mut chl := new_channel(1) mut chb := new_channel(10) mut recch := new_channel(0) - go do_rec_i64(mut recch) - go do_send_int(mut chi) - go do_send_u8(mut chb) - go do_send_i64(mut chl) + spawn do_rec_i64(mut recch) + spawn do_send_int(mut chi) + spawn do_send_u8(mut chb) + spawn do_send_i64(mut chl) mut channels := [chi, recch, chl, chb] directions := [Direction.pop, .push, .pop, .pop] mut sum := i64(0) diff --git a/vlib/sync/many_times_test.v b/vlib/sync/many_times_test.v index e2ddca3ae..7853b551d 100644 --- a/vlib/sync/many_times_test.v +++ b/vlib/sync/many_times_test.v @@ -24,7 +24,7 @@ fn test_many_times_once() { // It is executed 10 times, but only once actually. for i := 0; i < n; i++ { - go run(mut m, mut co, c) + spawn run(mut m, mut co, c) } for i := 0; i < n; i++ { <-c @@ -40,7 +40,7 @@ fn test_many_times_fifth() { // It is executed 10 times, but only 5 times actually. for i := 0; i < n; i++ { - go run(mut m, mut co, c) + spawn run(mut m, mut co, c) } for i := 0; i < n; i++ { <-c diff --git a/vlib/sync/once_test.v b/vlib/sync/once_test.v index 5b77c84dd..62bf3aa30 100644 --- a/vlib/sync/once_test.v +++ b/vlib/sync/once_test.v @@ -24,7 +24,7 @@ fn test_once() { // It is executed 10 times, but only once actually. for i := 0; i < n; i++ { - go run(mut once, mut o, c) + spawn run(mut once, mut o, c) } for i := 0; i < n; i++ { <-c diff --git a/vlib/sync/once_with_param_test.v b/vlib/sync/once_with_param_test.v index c6f26efc3..c2acdfb6b 100644 --- a/vlib/sync/once_with_param_test.v +++ b/vlib/sync/once_with_param_test.v @@ -29,7 +29,7 @@ fn test_once() { // It is executed 10 times, but only once actually. for i := 0; i < n; i++ { - go run(mut once, mut o, c) + spawn run(mut once, mut o, c) } for i := 0; i < n; i++ { <-c diff --git a/vlib/sync/pool/pool.v b/vlib/sync/pool/pool.v index 1ac751434..4f2dc6a2a 100644 --- a/vlib/sync/pool/pool.v +++ b/vlib/sync/pool/pool.v @@ -89,7 +89,7 @@ pub fn (mut pool PoolProcessor) work_on_pointers(items []voidptr) { pool.waitgroup.add(njobs) for i := 0; i < njobs; i++ { if njobs > 1 { - go process_in_thread(mut pool, i) + spawn process_in_thread(mut pool, i) } else { // do not run concurrently, just use the same thread: process_in_thread(mut pool, i) diff --git a/vlib/sync/select_close_test.v b/vlib/sync/select_close_test.v index 7a15bf9f5..083340162 100644 --- a/vlib/sync/select_close_test.v +++ b/vlib/sync/select_close_test.v @@ -44,10 +44,10 @@ fn test_select() { mut chl := new_channel(1) mut chb := new_channel(10) mut recch := new_channel(0) - go do_rec_i64(mut recch) - go do_send_int(mut chi) - go do_send_u8(mut chb) - go do_send_i64(mut chl) + spawn do_rec_i64(mut recch) + spawn do_send_int(mut chi) + spawn do_send_u8(mut chb) + spawn do_send_i64(mut chl) mut channels := [chi, recch, chl, chb] directions := [Direction.pop, .push, .pop, .pop] mut sum := i64(0) diff --git a/vlib/sync/stdatomic/atomic_test.v b/vlib/sync/stdatomic/atomic_test.v index 2e43e59f0..0d0020c39 100644 --- a/vlib/sync/stdatomic/atomic_test.v +++ b/vlib/sync/stdatomic/atomic_test.v @@ -15,7 +15,7 @@ fn test_count_10_times_1_cycle_should_result_10_cycles_with_sync() { mut counter := &Counter{} wg.add(10) for i := 0; i < 10; i++ { - go count_one_cycle(mut counter, mut wg) + spawn count_one_cycle(mut counter, mut wg) } wg.wait() assert counter.counter == u64(desired_iterations) @@ -29,7 +29,7 @@ fn test_count_10_times_1_cycle_should_not_be_10_cycles_without_sync() { mut counter := &Counter{} wg.add(10) for i := 0; i < 10; i++ { - go count_one_cycle_without_sync(mut counter, mut wg) + spawn count_one_cycle_without_sync(mut counter, mut wg) } wg.wait() // Note: we do not assert here, just print, because sometimes by chance counter.counter may be == desired_iterations diff --git a/vlib/sync/struct_chan_init_test.v b/vlib/sync/struct_chan_init_test.v index a51ea4b6d..2faf92738 100644 --- a/vlib/sync/struct_chan_init_test.v +++ b/vlib/sync/struct_chan_init_test.v @@ -8,7 +8,7 @@ fn f(st Abc) { fn test_chan_init() { st := Abc{} - go f(st) + spawn f(st) i := <-st.ch assert i == 47 } diff --git a/vlib/sync/thread_test.v b/vlib/sync/thread_test.v index 797d7e9ea..913cf2f56 100644 --- a/vlib/sync/thread_test.v +++ b/vlib/sync/thread_test.v @@ -9,8 +9,8 @@ fn simple_thread() u64 { fn test_sync_thread_id() { mtid := sync.thread_id() eprintln('main thread_id: $sync.thread_id().hex()') - x := go simple_thread() - y := go simple_thread() + x := spawn simple_thread() + y := spawn simple_thread() xtid := x.wait() ytid := y.wait() eprintln('main thread_id: $sync.thread_id().hex()') diff --git a/vlib/sync/waitgroup_test.v b/vlib/sync/waitgroup_test.v index 493665f52..cc473f5e5 100644 --- a/vlib/sync/waitgroup_test.v +++ b/vlib/sync/waitgroup_test.v @@ -10,7 +10,7 @@ fn test_waitgroup_reuse() { wg.add(1) mut executed := false - go fn (mut wg WaitGroup, executed voidptr) { + spawn fn (mut wg WaitGroup, executed voidptr) { defer { wg.done() } @@ -28,7 +28,7 @@ fn test_waitgroup_reuse() { fn test_waitgroup_no_use() { mut done := false - go fn (done voidptr) { + spawn fn (done voidptr) { time.sleep(1 * time.second) if *(&bool(done)) == false { panic('test_waitgroup_no_use did not complete in time') diff --git a/vlib/v/compiler_errors_test.v b/vlib/v/compiler_errors_test.v index d177acc31..188e68904 100644 --- a/vlib/v/compiler_errors_test.v +++ b/vlib/v/compiler_errors_test.v @@ -252,7 +252,7 @@ fn (mut tasks Tasks) run() { } work.close() for _ in 0 .. vjobs { - go work_processor(work, results) + spawn work_processor(work, results) } if github_job == '' { println('') diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 1639b1f69..9666f9155 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1170,7 +1170,7 @@ pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) { } pub fn (mut f Fmt) go_expr(node ast.GoExpr) { - f.write('go ') + f.write('spawn ') f.call_expr(node.call_expr) } diff --git a/vlib/v/gen/js/tests/js.v b/vlib/v/gen/js/tests/js.v index a81b7839f..4d4f8fb00 100644 --- a/vlib/v/gen/js/tests/js.v +++ b/vlib/v/gen/js/tests/js.v @@ -90,7 +90,7 @@ fn main() { for m, n in ma { iss := m } - go async(0, 'hello') + spawn async(0, 'hello') fn_in_var := fn (number int) { println('number: $number') } diff --git a/vlib/v/live/executable/reloader.v b/vlib/v/live/executable/reloader.v index 3051ddd8e..b086a4493 100644 --- a/vlib/v/live/executable/reloader.v +++ b/vlib/v/live/executable/reloader.v @@ -45,7 +45,7 @@ pub fn start_reloader(mut r live.LiveReloadInfo) { eprintln(err) exit(1) } - go reloader(mut r) + spawn reloader(mut r) } fn elog(r &live.LiveReloadInfo, s string) { diff --git a/vlib/v/tests/anon_fn_test.v b/vlib/v/tests/anon_fn_test.v index 9337e422b..20c22138d 100644 --- a/vlib/v/tests/anon_fn_test.v +++ b/vlib/v/tests/anon_fn_test.v @@ -3,7 +3,7 @@ import sync fn test_go_anon_fn() { mut wg := sync.new_waitgroup() wg.add(1) - go fn (mut wg sync.WaitGroup) { + spawn fn (mut wg sync.WaitGroup) { wg.done() }(mut wg) wg.wait() diff --git a/vlib/v/tests/array_map_ref_test.v b/vlib/v/tests/array_map_ref_test.v index 42cd4eff4..dbd691653 100644 --- a/vlib/v/tests/array_map_ref_test.v +++ b/vlib/v/tests/array_map_ref_test.v @@ -35,8 +35,8 @@ fn test_array_map_ref() { a_ref[1] = 17 } assert a_ref.len == 5 - t1 := go mod_map(shared m_shared) - t2 := go mod_array(shared a_shared) + t1 := spawn mod_map(shared m_shared) + t2 := spawn mod_array(shared a_shared) lock m_shared, a_shared { a_shared[4] = -12.25 m_shared['tz'] = 73.75 diff --git a/vlib/v/tests/array_of_threads_wait_test.v b/vlib/v/tests/array_of_threads_wait_test.v index d2f679b2a..50a20fb98 100644 --- a/vlib/v/tests/array_of_threads_wait_test.v +++ b/vlib/v/tests/array_of_threads_wait_test.v @@ -26,7 +26,7 @@ fn test_array_of_threads_wait() { println('Async') mut results := []thread f64{len: 16, cap: 16} for num in 0 .. 15 { - results << go async(size, init_val + num) + results << spawn async(size, init_val + num) } waited_results := results.wait() diff --git a/vlib/v/tests/atomic_test.v b/vlib/v/tests/atomic_test.v index bd28ec3e4..524e256a5 100644 --- a/vlib/v/tests/atomic_test.v +++ b/vlib/v/tests/atomic_test.v @@ -11,7 +11,7 @@ mut: fn test_atomic() { mut app := &App{} for i in 0 .. 10 { - go app.run() + spawn app.run() } time.sleep(200 * time.millisecond) println('idx=$app.idx') diff --git a/vlib/v/tests/autolock_array1_test.v b/vlib/v/tests/autolock_array1_test.v index b4c337fea..b6aaea1cb 100644 --- a/vlib/v/tests/autolock_array1_test.v +++ b/vlib/v/tests/autolock_array1_test.v @@ -13,8 +13,8 @@ fn add_elements(shared foo []int, n int) { fn test_autolocked_array() { shared abc := &[0] - go add_elements(shared abc, 1) - go add_elements(shared abc, 3) + spawn add_elements(shared abc, 1) + spawn add_elements(shared abc, 3) for _ in 0 .. iterations_per_thread { abc << 0 } diff --git a/vlib/v/tests/autolock_array2_test.v b/vlib/v/tests/autolock_array2_test.v index fa650bb62..5d05de593 100644 --- a/vlib/v/tests/autolock_array2_test.v +++ b/vlib/v/tests/autolock_array2_test.v @@ -14,8 +14,8 @@ fn inc_elements(shared foo []int, n int, mut sem sync.Semaphore) { fn test_autolocked_array_2() { shared abc := &[0, 0, 0] mut sem := sync.new_semaphore() - go inc_elements(shared abc, 1, mut sem) - go inc_elements(shared abc, 2, mut sem) + spawn inc_elements(shared abc, 1, mut sem) + spawn inc_elements(shared abc, 2, mut sem) for _ in 0 .. iterations_per_thread2 { unsafe { abc[2]++ diff --git a/vlib/v/tests/bench/gcboehm/GC_bench.v b/vlib/v/tests/bench/gcboehm/GC_bench.v index 411b12239..c7aaadf17 100644 --- a/vlib/v/tests/bench/gcboehm/GC_bench.v +++ b/vlib/v/tests/bench/gcboehm/GC_bench.v @@ -54,7 +54,7 @@ fn main() { eprintln('usage:\n\t${os.args[0]} [num_iterations]') exit(1) } - go waste_mem() + spawn waste_mem() mut last := time.sys_mono_now() for _ in 0 .. n_iterations { now := time.sys_mono_now() diff --git a/vlib/v/tests/break_in_lock_test.v b/vlib/v/tests/break_in_lock_test.v index d2048deb5..539ed1fb6 100644 --- a/vlib/v/tests/break_in_lock_test.v +++ b/vlib/v/tests/break_in_lock_test.v @@ -13,8 +13,8 @@ const ( fn test_return_lock() { start := time.now() shared s := AA{'3'} - go printer(shared s, start) - go fn (shared s AA, start time.Time) { + spawn printer(shared s, start) + spawn fn (shared s AA, start time.Time) { for { reader(shared s) if time.now() - start > run_time { diff --git a/vlib/v/tests/channels_test.v b/vlib/v/tests/channels_test.v index 5f84c7159..e51cef737 100644 --- a/vlib/v/tests/channels_test.v +++ b/vlib/v/tests/channels_test.v @@ -18,7 +18,7 @@ fn test_printing_of_channels() { val: 1000 another: fch } - res := (go fn1(ch)).wait() + res := (spawn fn1(ch)).wait() println(res) println(ch) assert res.str().contains('another: chan f64{cap: 100, closed: 0}') @@ -40,7 +40,7 @@ fn func(ch chan As) { fn test_chan_of_sumtype() { a := chan As{} - go func(a) + spawn func(a) ret := <-a println(ret) assert '$ret' == 'As(Aa{})' diff --git a/vlib/v/tests/comptime_if_expr_threads_test.v b/vlib/v/tests/comptime_if_expr_threads_test.v index 6fa6e1375..f508b04a3 100644 --- a/vlib/v/tests/comptime_if_expr_threads_test.v +++ b/vlib/v/tests/comptime_if_expr_threads_test.v @@ -16,7 +16,7 @@ fn test_comptime_if_expr_of_threads() { println('Async') mut results := []thread f64{cap: 16} for num in 0 .. 15 { - results << go async(size, num) + results << spawn async(size, num) } waited_results := results.wait() diff --git a/vlib/v/tests/comptime_if_threads_yes_test.v b/vlib/v/tests/comptime_if_threads_yes_test.v index df5470961..b911e0bac 100644 --- a/vlib/v/tests/comptime_if_threads_yes_test.v +++ b/vlib/v/tests/comptime_if_threads_yes_test.v @@ -1,5 +1,5 @@ fn abc() { - go fn () {}() + spawn fn () {}() } fn test_if_threads() { diff --git a/vlib/v/tests/default_thread_stack_size_test.v b/vlib/v/tests/default_thread_stack_size_test.v index 0cc46b41c..1b3d6adc7 100644 --- a/vlib/v/tests/default_thread_stack_size_test.v +++ b/vlib/v/tests/default_thread_stack_size_test.v @@ -20,7 +20,7 @@ fn test_default_stack_depth() { // and would have failed on macos, where the default thread size // is just 512KB, if V was not changed to have a default for // `-thread-stack-size` of 8MB. - t := go abc(10) + t := spawn abc(10) res := t.wait() assert res == 55 } diff --git a/vlib/v/tests/defer/defer_test.v b/vlib/v/tests/defer/defer_test.v index dfa66b601..3a17ba2c1 100644 --- a/vlib/v/tests/defer/defer_test.v +++ b/vlib/v/tests/defer/defer_test.v @@ -71,7 +71,7 @@ fn test_defer_with_anon_fn() { assert f.add(1) == 111 } - go fn () { + spawn fn () { defer { println('deferred 1') } diff --git a/vlib/v/tests/fixed_array_of_threads_test.v b/vlib/v/tests/fixed_array_of_threads_test.v index 7bd232a4d..fda4719df 100644 --- a/vlib/v/tests/fixed_array_of_threads_test.v +++ b/vlib/v/tests/fixed_array_of_threads_test.v @@ -2,7 +2,7 @@ module main fn test_fixed_array_of_threads() { mut avar := [8]thread string{} - avar[0] = go printme() + avar[0] = spawn printme() ret := avar[0].wait() assert ret == 'me' } diff --git a/vlib/v/tests/for_loops_2_test.v b/vlib/v/tests/for_loops_2_test.v index 5def00b15..344f9d465 100644 --- a/vlib/v/tests/for_loops_2_test.v +++ b/vlib/v/tests/for_loops_2_test.v @@ -27,7 +27,7 @@ fn test_for_match() { fn test_for_select() { ch1 := chan int{} ch2 := chan f64{} - go do_send(ch1, ch2) + spawn do_send(ch1, ch2) mut a := 0 mut b := 0 for select { diff --git a/vlib/v/tests/go_anon_fn_call_with_ref_arg_test.v b/vlib/v/tests/go_anon_fn_call_with_ref_arg_test.v index 4caf39427..b752f9964 100644 --- a/vlib/v/tests/go_anon_fn_call_with_ref_arg_test.v +++ b/vlib/v/tests/go_anon_fn_call_with_ref_arg_test.v @@ -6,7 +6,7 @@ fn test_go_anon_fn_call_with_ref_arg() { foo := &Foo{ bar: 'hello' } - g := go fn (foo Foo) string { + g := spawn fn (foo Foo) string { return foo.bar }(foo) ret := g.wait() diff --git a/vlib/v/tests/go_anon_fn_variable_call_test.v b/vlib/v/tests/go_anon_fn_variable_call_test.v index 8d48fdaee..ca965b0ea 100644 --- a/vlib/v/tests/go_anon_fn_variable_call_test.v +++ b/vlib/v/tests/go_anon_fn_variable_call_test.v @@ -7,7 +7,7 @@ fn sum1(a int, b int) int { } sum_func2 := sum_func1 - g := go sum_func2(a, b) + g := spawn sum_func2(a, b) result := g.wait() return result @@ -21,7 +21,7 @@ fn sum2(a int, b int) int { sum_func1 := add sum_func2 := sum_func1 - g := go sum_func2(a, b) + g := spawn sum_func2(a, b) result := g.wait() return result diff --git a/vlib/v/tests/go_array_wait_test.v b/vlib/v/tests/go_array_wait_test.v index fbe6a5086..62dec4544 100644 --- a/vlib/v/tests/go_array_wait_test.v +++ b/vlib/v/tests/go_array_wait_test.v @@ -9,7 +9,7 @@ fn f(x f64) f64 { fn test_array_thread_f64_wait() { mut r := []thread f64{cap: 10} for i in 0 .. 10 { - r << go f(f64(i) + 0.5) + r << spawn f(f64(i) + 0.5) } x := r.wait() assert x == [0.25, 2.25, 6.25, 12.25, 20.25, 30.25, 42.25, 56.25, 72.25, 90.25] @@ -24,13 +24,13 @@ fn g(shared a []int, i int) { fn test_array_thread_void_wait() { shared a := [2, 3, 5, 7, 11, 13, 17] t := [ - go g(shared a, 0), - go g(shared a, 3), - go g(shared a, 6), - go g(shared a, 2), - go g(shared a, 1), - go g(shared a, 5), - go g(shared a, 4), + spawn g(shared a, 0), + spawn g(shared a, 3), + spawn g(shared a, 6), + spawn g(shared a, 2), + spawn g(shared a, 1), + spawn g(shared a, 5), + spawn g(shared a, 4), ] println('threads started') t.wait() @@ -43,9 +43,9 @@ fn test_void_thread_decl() { shared a := [2, 3, 9] mut t1 := thread(0) mut tarr := []thread{len: 2} - t1 = go g(shared a, 0) - tarr[0] = go g(shared a, 1) - tarr[1] = go g(shared a, 2) + t1 = spawn g(shared a, 0) + tarr[0] = spawn g(shared a, 1) + tarr[1] = spawn g(shared a, 2) t1.wait() tarr.wait() rlock a { diff --git a/vlib/v/tests/go_call_anon_fn_with_closure_test.v b/vlib/v/tests/go_call_anon_fn_with_closure_test.v index 4cdde80d5..ef5762dfb 100644 --- a/vlib/v/tests/go_call_anon_fn_with_closure_test.v +++ b/vlib/v/tests/go_call_anon_fn_with_closure_test.v @@ -6,7 +6,7 @@ fn test_go_call_anon_fn_with_closure1() { return a } - g := go b() + g := spawn b() ret := g.wait() assert ret == 1 } @@ -17,7 +17,7 @@ fn test_go_call_anon_fn_with_closure2() { 'key2': 2 } - h := go fn [m] () int { + h := spawn fn [m] () int { println(m['key2']) return m['key2'] }() diff --git a/vlib/v/tests/go_call_fn_return_test.v b/vlib/v/tests/go_call_fn_return_test.v index 400a0a02a..c5f30e735 100644 --- a/vlib/v/tests/go_call_fn_return_test.v +++ b/vlib/v/tests/go_call_fn_return_test.v @@ -1,7 +1,7 @@ const text = 'Hello world' fn test_go_call_fn_return() { - hex_go := go text.bytes().hex() + hex_go := spawn text.bytes().hex() hex := text.bytes().hex() assert hex == '48656c6c6f20776f726c64' diff --git a/vlib/v/tests/go_call_fn_using_map_value_test.v b/vlib/v/tests/go_call_fn_using_map_value_test.v index 63c3ad8b3..d807d611e 100644 --- a/vlib/v/tests/go_call_fn_using_map_value_test.v +++ b/vlib/v/tests/go_call_fn_using_map_value_test.v @@ -8,7 +8,7 @@ fn test_go_call_fn_using_map_value() { mut fns := map[string]fn (int, int) int{} fns['sum'] = sum - g := go fns['sum'](2, 3) + g := spawn fns['sum'](2, 3) x := g.wait() println('$x') diff --git a/vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v b/vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v index f86bb2494..57cd61c36 100644 --- a/vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v +++ b/vlib/v/tests/go_call_fn_with_anon_fn_arg_test.v @@ -8,7 +8,7 @@ fn on_connect() { } fn test_go_call_fn_with_anon_fn_arg() { - g := go start(on_connect) + g := spawn start(on_connect) ret := g.wait() assert ret == 'ok!!' } diff --git a/vlib/v/tests/go_call_generic_fn_test.v b/vlib/v/tests/go_call_generic_fn_test.v index a42c2a73b..0a99ff099 100644 --- a/vlib/v/tests/go_call_generic_fn_test.v +++ b/vlib/v/tests/go_call_generic_fn_test.v @@ -7,7 +7,7 @@ fn test(c chan int, s T) { fn test_go_generic_fn() { mut c := chan int{} - go test(c, 'abcd') + spawn test(c, 'abcd') x := <-c assert x == 123 println('bye') diff --git a/vlib/v/tests/go_call_interface_method_test.v b/vlib/v/tests/go_call_interface_method_test.v index 0533f93c1..11d0769de 100644 --- a/vlib/v/tests/go_call_interface_method_test.v +++ b/vlib/v/tests/go_call_interface_method_test.v @@ -21,7 +21,7 @@ fn test_go_call_interface_method() { tasks << Task2{} for task in tasks { - go task.task() + spawn task.task() } assert true diff --git a/vlib/v/tests/go_handle_for_functions_returning_array_test.v b/vlib/v/tests/go_handle_for_functions_returning_array_test.v index 6a030c53c..4dcef4fd0 100644 --- a/vlib/v/tests/go_handle_for_functions_returning_array_test.v +++ b/vlib/v/tests/go_handle_for_functions_returning_array_test.v @@ -3,7 +3,7 @@ fn create_random_frames(amount int, pixels int) [][][]int { } fn test_go_can_be_used_with_functions_returning_arrays() { - x := go create_random_frames(2, 2) + x := spawn create_random_frames(2, 2) res := x.wait() assert res == [[[2, 2]]] } diff --git a/vlib/v/tests/go_wait_1_test.v b/vlib/v/tests/go_wait_1_test.v index 71e483999..9f7a2baf6 100644 --- a/vlib/v/tests/go_wait_1_test.v +++ b/vlib/v/tests/go_wait_1_test.v @@ -3,7 +3,7 @@ fn f(x int, y f64) f64 { } fn test_go_return() { - r := go f(3, 4.0) + r := spawn f(3, 4.0) z := r.wait() assert typeof(z).name == 'f64' assert z == 12.0 diff --git a/vlib/v/tests/go_wait_2_test.v b/vlib/v/tests/go_wait_2_test.v index b27477325..730c7963d 100644 --- a/vlib/v/tests/go_wait_2_test.v +++ b/vlib/v/tests/go_wait_2_test.v @@ -15,7 +15,7 @@ fn f(x int, y f64, shared s St) { fn test_go_return() { shared t := &St{} - r := go f(3, 4.0, shared t) + r := spawn f(3, 4.0, shared t) r.wait() rlock t { assert t.x == 12.0 diff --git a/vlib/v/tests/go_wait_3_test.v b/vlib/v/tests/go_wait_3_test.v index b41efb9bb..2466d4276 100644 --- a/vlib/v/tests/go_wait_3_test.v +++ b/vlib/v/tests/go_wait_3_test.v @@ -12,7 +12,7 @@ fn test_method_go_wait() { test: 'hi' } } - thread := go a.sub.get() + thread := spawn a.sub.get() r := thread.wait() assert r == 'hi' } diff --git a/vlib/v/tests/go_wait_option_test.v b/vlib/v/tests/go_wait_option_test.v index f1c05a1d5..0097eae3c 100644 --- a/vlib/v/tests/go_wait_option_test.v +++ b/vlib/v/tests/go_wait_option_test.v @@ -17,8 +17,8 @@ fn g(n int) ? { } fn test_opt_val_wait() { - h1 := go f(-1) - h2 := go f(3) + h1 := spawn f(-1) + h2 := spawn f(3) r1 := h1.wait() or { 17.0 } r2 := h2.wait() or { 23.0 } assert r1 == 17.0 @@ -26,8 +26,8 @@ fn test_opt_val_wait() { } fn test_opt_void_wait() { - h1 := go g(2) - h2 := go g(3) + h1 := spawn g(2) + h2 := spawn g(3) mut x := 0 mut y := 0 h1.wait() or { x = 1 } @@ -37,8 +37,8 @@ fn test_opt_void_wait() { } fn propagate(n int, m int) ?f64 { - h1 := go f(n) - h2 := go g(m) + h1 := spawn f(n) + h2 := spawn g(m) r := h1.wait()? h2.wait()? return r @@ -56,7 +56,7 @@ fn test_propagate() { fn test_array_void_interate() { mut r := []thread ?{} for i in 0 .. 3 { - r << go g(i) + r << spawn g(i) } mut res := []int{len: 3, init: 17} for i, t in r { @@ -70,7 +70,7 @@ fn test_array_void_interate() { fn test_array_val_interate() { mut r := []thread ?f64{} for i in -1 .. 2 { - r << go f(i) + r << spawn f(i) } mut res := []f64{len: 3} for i, t in r { @@ -94,15 +94,15 @@ fn get_only_a_result_return() ! { } fn test_only_a_option_return() { - t1 := go get_only_a_option_return(true) + t1 := spawn get_only_a_option_return(true) t1.wait() or { assert false } - t2 := go get_only_a_option_return(false) + t2 := spawn get_only_a_option_return(false) t2.wait() or { assert true } assert true } fn test_only_a_result_return() { - t := go get_only_a_result_return() + t := spawn get_only_a_result_return() t.wait() or { assert true } assert true } diff --git a/vlib/v/tests/go_wait_with_fn_of_interface_parameter_test.v b/vlib/v/tests/go_wait_with_fn_of_interface_parameter_test.v index 6cf6787e5..2e755d033 100644 --- a/vlib/v/tests/go_wait_with_fn_of_interface_parameter_test.v +++ b/vlib/v/tests/go_wait_with_fn_of_interface_parameter_test.v @@ -8,7 +8,7 @@ interface In1 { fn test_go_wait_with_fn_of_interface_type() { mut var := &St1{} - (go fn1(mut var)).wait() + (spawn fn1(mut var)).wait() } fn fn1(mut v In1) { diff --git a/vlib/v/tests/init_global_test.v b/vlib/v/tests/init_global_test.v index a635bbaaf..2fed325e9 100644 --- a/vlib/v/tests/init_global_test.v +++ b/vlib/v/tests/init_global_test.v @@ -14,7 +14,7 @@ fn test_global_init() { intmap['two'] = 27 key := 'two' assert intmap[key] == 27 - t := go pushf64() + t := spawn pushf64() numberfns['one'] = one numberfns['two'] = fn () int { return 2 @@ -124,7 +124,7 @@ fn test_global_shared() { mys.x = 13.0 mys.y = -35.125 } - t := go switch() + t := spawn switch() for _ in 0 .. 2500000 { lock mys { mys.x, mys.y = mys.y, mys.x @@ -168,7 +168,7 @@ fn switch2() u64 { fn test_global_mutex() { assert f1 == 34.0625 - t := go switch2() + t := spawn switch2() for _ in 0 .. 25000 { mtx.@lock() f1, f2 = f2, f1 diff --git a/vlib/v/tests/inout/go_print.out b/vlib/v/tests/inout/go_print.out index ee8e3b469..b1e0f8a71 100644 --- a/vlib/v/tests/inout/go_print.out +++ b/vlib/v/tests/inout/go_print.out @@ -1,2 +1,2 @@ [1, 2, 3] -[4,5, 6] +[4, 5, 6] diff --git a/vlib/v/tests/keep_args_alive_test.v b/vlib/v/tests/keep_args_alive_test.v index b1b0b3f29..b8a53e8bb 100644 --- a/vlib/v/tests/keep_args_alive_test.v +++ b/vlib/v/tests/keep_args_alive_test.v @@ -63,8 +63,8 @@ fn waste_mem(n int, mut sem sync.Semaphore) { fn test_keep_args_alive_attribute() { mut sem := sync.new_semaphore() $if gcboehm ? { - go waste_mem(-1, mut sem) - go waste_mem(-1, mut sem) + spawn waste_mem(-1, mut sem) + spawn waste_mem(-1, mut sem) waste_mem(10000, mut sem) } r := &voidptr(set_vals()) diff --git a/vlib/v/tests/option_2_test.v b/vlib/v/tests/option_2_test.v index dfb8bc503..1123db6f1 100644 --- a/vlib/v/tests/option_2_test.v +++ b/vlib/v/tests/option_2_test.v @@ -41,9 +41,9 @@ fn test_channel_push() { fn test_thread_wait() { thrs := [ - go f(3), - go f(-7), - go f(12), + spawn f(3), + spawn f(-7), + spawn f(12), ] mut res := []int{cap: 3} for t in thrs { diff --git a/vlib/v/tests/reliability/semaphore_wait.v b/vlib/v/tests/reliability/semaphore_wait.v index f480fcaa7..61704c94e 100644 --- a/vlib/v/tests/reliability/semaphore_wait.v +++ b/vlib/v/tests/reliability/semaphore_wait.v @@ -125,10 +125,10 @@ fn main() { exit(1) } mut sem := sync.new_semaphore() - go do_rec(mut sem, timed) - go do_send(mut sem) + spawn do_rec(mut sem, timed) + spawn do_send(mut sem) for _ in 0 .. 4 { - go waste_mem() + spawn waste_mem() } mut last := time.sys_mono_now() for _ in 0 .. n_iterations { diff --git a/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f1.v b/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f1.v index 71fa28cdb..7516de4f9 100644 --- a/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f1.v +++ b/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f1.v @@ -2,5 +2,5 @@ module main fn f1() { x := Abc{111} - go f(x) + spawn f(x) } diff --git a/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f2.v b/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f2.v index 2facc2976..6f7c94556 100644 --- a/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f2.v +++ b/vlib/v/tests/run_project_folders/go_fns_in_different_files_over_the_same_struct/f2.v @@ -2,5 +2,5 @@ module main fn f2() { x := Abc{222} - go f(x) + spawn f(x) } diff --git a/vlib/v/tests/semaphore_test.v b/vlib/v/tests/semaphore_test.v index b35474648..3a491c7ed 100644 --- a/vlib/v/tests/semaphore_test.v +++ b/vlib/v/tests/semaphore_test.v @@ -14,8 +14,8 @@ fn send_signals(mut sem sync.Semaphore, mut sem_end sync.Semaphore) { fn test_semaphores() { mut sem := sync.new_semaphore() mut sem_end := sync.new_semaphore() - go send_signals(mut sem, mut sem_end) - go send_signals(mut sem, mut sem_end) + spawn send_signals(mut sem, mut sem_end) + spawn send_signals(mut sem, mut sem_end) for _ in 0 .. 2 * signals_per_thread { sem.wait() } diff --git a/vlib/v/tests/semaphore_timed_test.v b/vlib/v/tests/semaphore_timed_test.v index e80ef74e7..911bb5e14 100644 --- a/vlib/v/tests/semaphore_timed_test.v +++ b/vlib/v/tests/semaphore_timed_test.v @@ -13,7 +13,7 @@ fn run_forever(shared foo []int, mut sem sync.Semaphore) { fn test_semaphore() { shared abc := &[0] mut sem := sync.new_semaphore() - go run_forever(shared abc, mut sem) + spawn run_forever(shared abc, mut sem) for _ in 0 .. 1000 { unsafe { abc[0]-- } } diff --git a/vlib/v/tests/shared_array_test.v b/vlib/v/tests/shared_array_test.v index 453396c0b..3d5b86502 100644 --- a/vlib/v/tests/shared_array_test.v +++ b/vlib/v/tests/shared_array_test.v @@ -13,10 +13,10 @@ fn incr(shared foo []int, index int) { fn test_shared_array() { shared foo := &[10, 20, 0] - go incr(shared foo, 0) - go incr(shared foo, 1) - go incr(shared foo, 0) - go incr(shared foo, 1) + spawn incr(shared foo, 0) + spawn incr(shared foo, 1) + spawn incr(shared foo, 0) + spawn incr(shared foo, 1) for _ in 0 .. 50000 { lock foo { foo[0] -= 2 diff --git a/vlib/v/tests/shared_autolock_test.v b/vlib/v/tests/shared_autolock_test.v index fc41047f9..1bc846789 100644 --- a/vlib/v/tests/shared_autolock_test.v +++ b/vlib/v/tests/shared_autolock_test.v @@ -8,7 +8,7 @@ fn inc_array_elem(shared b []int, i int) { fn test_autolock_array() { shared a := [1, 2, 7, 5] - t := go inc_array_elem(shared a, 2) + t := spawn inc_array_elem(shared a, 2) for _ in 0 .. iterations { a[2]++ } @@ -31,7 +31,7 @@ fn test_autolock_map() { 'asd': 7 'iop': 5 } - t := go inc_map_elem(shared m, 'asd') + t := spawn inc_map_elem(shared m, 'asd') for _ in 0 .. iterations { m['asd']++ } diff --git a/vlib/v/tests/shared_lock_2_test.v b/vlib/v/tests/shared_lock_2_test.v index 5070d1b93..2340d7065 100644 --- a/vlib/v/tests/shared_lock_2_test.v +++ b/vlib/v/tests/shared_lock_2_test.v @@ -28,7 +28,7 @@ fn test_shared_receiver_lock() { shared z := &St{ a: 1 } - go x.f(shared y, shared z) + spawn x.f(shared y, shared z) for _ in 0 .. 100 { lock x, y { tmp := x.a diff --git a/vlib/v/tests/shared_lock_3_test.v b/vlib/v/tests/shared_lock_3_test.v index b5ca960be..be7df6e4e 100644 --- a/vlib/v/tests/shared_lock_3_test.v +++ b/vlib/v/tests/shared_lock_3_test.v @@ -32,7 +32,7 @@ fn test_shared_lock() { a: read_threads } for _ in 0 .. read_threads { - go f(shared x, shared z) + spawn f(shared x, shared z) } for i in 0 .. writes { lock x { // wait for ongoing reads to finish, don't start new ones diff --git a/vlib/v/tests/shared_lock_4_test.v b/vlib/v/tests/shared_lock_4_test.v index bfe1e333d..2997bfef1 100644 --- a/vlib/v/tests/shared_lock_4_test.v +++ b/vlib/v/tests/shared_lock_4_test.v @@ -32,7 +32,7 @@ fn test_shared_lock() { a: read_threads } for _ in 0 .. read_threads { - go x.f(shared z) + spawn x.f(shared z) } for i in 0 .. writes { lock x { // wait for ongoing reads to finish, don't start new ones diff --git a/vlib/v/tests/shared_lock_5_test.v b/vlib/v/tests/shared_lock_5_test.v index 08284c051..ca4eca511 100644 --- a/vlib/v/tests/shared_lock_5_test.v +++ b/vlib/v/tests/shared_lock_5_test.v @@ -46,9 +46,9 @@ fn test_shared_receiver_lock() { shared z := &St{ a: 1 } - t1 := go x.f(shared y, shared z) - t2 := go x.f(shared y, shared z) - t3 := go h(shared x, shared y, shared z) + t1 := spawn x.f(shared y, shared z) + t2 := spawn x.f(shared y, shared z) + t3 := spawn h(shared x, shared y, shared z) for _ in 0 .. 10000 { lock z, y, x { tmp := y.a diff --git a/vlib/v/tests/shared_lock_6_test.v b/vlib/v/tests/shared_lock_6_test.v index 6ed5beaad..1f3465dac 100644 --- a/vlib/v/tests/shared_lock_6_test.v +++ b/vlib/v/tests/shared_lock_6_test.v @@ -39,11 +39,11 @@ fn test_shared_receiver_lock() { shared z := St{ a: 103 } - t1 := go x.f(shared y, shared x) - t2 := go y.f(shared y, shared z) - t3 := go z.g(shared x, shared z) - t4 := go x.g(shared x, shared x) - t5 := go z.f(shared z, shared z) + t1 := spawn x.f(shared y, shared x) + t2 := spawn y.f(shared y, shared z) + t3 := spawn z.g(shared x, shared z) + t4 := spawn x.g(shared x, shared x) + t5 := spawn z.f(shared z, shared z) t1.wait() t2.wait() t3.wait() diff --git a/vlib/v/tests/shared_lock_test.v b/vlib/v/tests/shared_lock_test.v index c9de4a441..bb2d84e02 100644 --- a/vlib/v/tests/shared_lock_test.v +++ b/vlib/v/tests/shared_lock_test.v @@ -28,7 +28,7 @@ fn test_shared_lock() { shared z := St{ a: 1 } - go f(shared x, shared y, shared z) + spawn f(shared x, shared y, shared z) for _ in 0 .. 100 { lock x, y { tmp := x.a diff --git a/vlib/v/tests/shared_map_test.v b/vlib/v/tests/shared_map_test.v index d6442a0a9..73d250b15 100644 --- a/vlib/v/tests/shared_map_test.v +++ b/vlib/v/tests/shared_map_test.v @@ -18,10 +18,10 @@ fn test_shared_array() { foo['q'] = 20 } mut sem := sync.new_semaphore() - go incr(shared foo, 'p', mut sem) - go incr(shared foo, 'q', mut sem) - go incr(shared foo, 'p', mut sem) - go incr(shared foo, 'q', mut sem) + spawn incr(shared foo, 'p', mut sem) + spawn incr(shared foo, 'q', mut sem) + spawn incr(shared foo, 'p', mut sem) + spawn incr(shared foo, 'q', mut sem) for _ in 0 .. 50000 { lock foo { foo['p'] -= 2 diff --git a/vlib/v/tests/shared_unordered_mixed_test.v b/vlib/v/tests/shared_unordered_mixed_test.v index f8ee27c87..a47716513 100644 --- a/vlib/v/tests/shared_unordered_mixed_test.v +++ b/vlib/v/tests/shared_unordered_mixed_test.v @@ -67,9 +67,9 @@ fn test_mixed_order_lock_rlock() { h: u64(-1) } // spawn 3 threads for doubling with different orders of objects - t1 := go doub_large(shared a, shared b, shared c, shared d, shared e) - t2 := go doub_large(shared e, shared b, shared a, shared c, shared d) - t3 := go doub_large(shared b, shared a, shared e, shared d, shared c) + t1 := spawn doub_large(shared a, shared b, shared c, shared d, shared e) + t2 := spawn doub_large(shared e, shared b, shared a, shared c, shared d) + t3 := spawn doub_large(shared b, shared a, shared e, shared d, shared c) t1.wait() t2.wait() t3.wait() diff --git a/vlib/v/tests/thread_to_string_test.v b/vlib/v/tests/thread_to_string_test.v index 944efccc4..bb6a1ac53 100644 --- a/vlib/v/tests/thread_to_string_test.v +++ b/vlib/v/tests/thread_to_string_test.v @@ -3,6 +3,6 @@ fn ret_ten() int { } fn test_thread_str() { - th := go ret_ten() + th := spawn ret_ten() assert th.str() == 'thread(int)' } diff --git a/vlib/vweb/csrf/csrf_test.v b/vlib/vweb/csrf/csrf_test.v index c1b11c8ee..c482a1280 100644 --- a/vlib/vweb/csrf/csrf_test.v +++ b/vlib/vweb/csrf/csrf_test.v @@ -19,7 +19,7 @@ fn (mut app App) index() vweb.Result { } fn test_send_a_request_to_homepage_expecting_a_csrf_cookie() { - go vweb.run_at(&App{}, vweb.RunParams{ port: sport }) + spawn vweb.run_at(&App{}, vweb.RunParams{ port: sport }) time.sleep(500 * time.millisecond) res := http.get('http://localhost:$sport/')? if res.header.str().contains('__Host-Csrf-Token') { diff --git a/vlib/vweb/tests/vweb_test.v b/vlib/vweb/tests/vweb_test.v index e08831609..dbf3e5d42 100644 --- a/vlib/vweb/tests/vweb_test.v +++ b/vlib/vweb/tests/vweb_test.v @@ -46,7 +46,7 @@ fn test_a_simple_vweb_app_runs_in_the_background() { eprintln('running:\n$server_exec_cmd') } $if windows { - go os.system(server_exec_cmd) + spawn os.system(server_exec_cmd) } $else { res := os.system(server_exec_cmd) assert res == 0 diff --git a/vlib/vweb/tests/vweb_test_server.v b/vlib/vweb/tests/vweb_test_server.v index d72516dd7..d33b14a2d 100644 --- a/vlib/vweb/tests/vweb_test_server.v +++ b/vlib/vweb/tests/vweb_test_server.v @@ -33,7 +33,7 @@ fn main() { assert http_port > 0 timeout := os.args[2].int() assert timeout > 0 - go exit_after_timeout(timeout) + spawn exit_after_timeout(timeout) // shared config := &Config{ max_ping: 50 @@ -108,7 +108,7 @@ pub fn (mut app App) shutdown() vweb.Result { if session_key != 'superman' { return app.not_found() } - go app.gracefull_exit() + spawn app.gracefull_exit() return app.ok('good bye') } diff --git a/vlib/vweb/vweb.v b/vlib/vweb/vweb.v index 16100a89b..853ff0680 100644 --- a/vlib/vweb/vweb.v +++ b/vlib/vweb/vweb.v @@ -433,7 +433,7 @@ pub fn run_at(global_app &T, params RunParams) ! { eprintln('accept() failed with error: $err.msg()') continue } - go handle_conn(mut conn, mut request_app, routes) + spawn handle_conn(mut conn, mut request_app, routes) } } diff --git a/vlib/vweb/vweb_app_test.v b/vlib/vweb/vweb_app_test.v index a70bd1bdc..6abb64271 100644 --- a/vlib/vweb/vweb_app_test.v +++ b/vlib/vweb/vweb_app_test.v @@ -18,7 +18,7 @@ struct Article { } fn test_a_vweb_application_compiles() { - go fn () { + spawn fn () { time.sleep(2 * time.second) exit(0) }() -- 2.30.2