Module multiprocess

← Back to All Modules





Description

This module enables parallelism in Dinfio. You can run multiple processes simultaneously. This is useful for intensive operations, like Networking, File IO, Computation, etc.


Constants


Functions


Classes

There are no classes.


Examples

import multiprocess
 
start
    process("child_1")
    process("child_2", [23], on_updated(), on_returned(), on_finished())
stop
 
function on_updated(data)
    writeln("Updated data from child #2: " & data)
stop
 
function on_returned(data)
    writeln("Returned data from child #2: " & data)
stop
 
function on_finished()
    writeln("Child #2 finished")
stop
' Child #1 - child_1.fio
 
import multiprocess
 
start
    writeln("Child #1 started")
    sleep(2000)
    writeln("Child #1 finished")
stop
' Child #2 - child_2.fio
 
import multiprocess
 
start
    n = process_arguments[0]
 
    process_yield(n * 2)
    process_return(n ^ 2)
stop
' Example output:
'
' Child #1 started
' Updated data from child #2: 46
' Returned data from child #2: 529
' Child #2 finished
' Child #1 finished