import std/[enumerate]
import malebolgia
func threadFunc(a: int): int =
a + a
proc run(inputs: openArray[int]): seq[int] =
result = newSeq[int](inputs.len)
var m = createMaster()
m.awaitAll:
for i, item in enumerate(inputs):
m.spawn threadFunc(item) -> result[i]
echo run([1, 2, 3, 4, 5])
$ nim --skipUserCfg --skipParentCfg --skipProjCfg c -r thisfile.nim
@[2, 4, 6, 8, 10]
$ nim --skipUserCfg --skipParentCfg --skipProjCfg cpp -r thisfile.nim
/home/jack/.cache/nim/malebolgia_cpp_d/@mmalebolgia_cpp.nim.cpp: In function ‘tySequence__qwqHTkRvwhrRyENtudHQ7g run__malebolgia95cpp_u6(NI*, NI)’:
/home/jack/.cache/nim/malebolgia_cpp_d/@mmalebolgia_cpp.nim.cpp:334:240: error: use of deleted function ‘tyObject_Master__F3e20AfgTBHcMGUUxuJL1g& tyObject_Master__F3e20AfgTBHcMGUUxuJL1g::operator=(tyObject_Master__F3e20AfgTBHcMGUUxuJL1g&&)’
334 | s/experiments/malebolgia_cpp.nim"); m = createMaster__OOZOOZOOZOnimbleZpkgs50Zmalebolgia4549O51O494551b54b56b48565757c5448515748dd5048525351c53f55a50a484953515450cf4851Zmalebolgia_u25(T3_);
569 | return result;
| ^~~~~~
/home/jack/.cache/nim/malebolgia_cpp_d/@m..@s..@s..@s.nimble@spkgs2@smalebolgia-1.3.1-3b6b8b0899c60390dd20453c5f7a2a015362cf03@smalebolgia.nim.cpp:105:8: note: ‘tyObject_Master__F3e20AfgTBHcMGUUxuJL1g::tyObject_Master__F3e20AfgTBHcMGUUxuJL1g(const tyObject_Master__F3e20AfgTBHcMGUUxuJL1g&)’ is implicitly deleted because the default definition would be ill-formed:
105 | struct tyObject_Master__F3e20AfgTBHcMGUUxuJL1g {
Version:
Nim Compiler Version 2.0.2 [Linux: amd64]
Compiled at 2023-12-15
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: c4c44d10df8a14204a75c34e499def200589cb7c
active boot switches: -d:release
package "malebolgia@1.3.1" with checksum "3b6b8b0899c60390dd20453c5f7a2a015362cf03"
Version: