Dynamic process network management
Is it possible to create and destroy a process sub-network during runtime?
Background: A user subscribes to a service which requires the creation of a sub-process network for data processing. A user un-subscribes from service which requires the deletion of a sub-process network.
The following code creates three control sub-process networks. The number of control processes is determined before entering the parallel. With my limited understanding, I don't see a way of making that dynamic, i.e. adding and removing processes to and from the parallel.
import sys from pycsp.parallel import *
@process def source(chan_out, label): for i in range(10): chan_out(label + " (%d)\n" % (i)) retire(chan_out)
@process def sink(chan_in): while True: sys.stdout.write(chan_in())
@process def control(label): chan = Channel() Parallel( source(-chan, label), sink(+chan) )
Parallel( control('A'), control('B'), control('C') )
shutdown()