我正在尝试从子外壳填充数组。这可能吗?
array = []
processes = []
limit = 10
File.foreach("/path/to/file") do |line|
if processes.size == limit
processes.delete Process.wait
end
processes << fork do
begin
something = so_something
if something == something
array.push(line)
end
end
end
end
Process.waitall
如果我这样做,则数组在 Process.waitall 之后显示为空。我想稍后引用该数组。