Our example demonstrates how to wait on multiple channel-like operations. Combining parallel execution and communication channels is a powerful feature in scientific computing.
In this Scilab implementation, we use arrays (c1 and c2) to simulate channels. The parallel_run function is used to start parallel executions, similar to goroutines. We use a polling mechanism to check for new values in our “channels”.
To run the program, save it as select_example.sce and execute it in Scilab:
We receive the values “one” and then “two” as expected. Note that the total execution time is only about 2 seconds since both the 1 and 2 second delays execute concurrently.
This example demonstrates how to implement concurrent operations and synchronization in Scilab, even though it doesn’t have built-in support for channels or select statements like some other languages.