Posted to tcl by pooryorick at Tue May 24 19:23:22 GMT 2016view raw
- set task1 [relay order 0 [coroutine p1 [list apply args {
- relay accept deliver [info coroutine]
- foreach arg $args {
- dict set results [
- relay call cl::Buffer copy $arg] {}
- }
- foreach arg $args {
- catch {relay receive} res options
- dict set results [dict get $options -id] $res
- }
- kernel_1 bind {*}[dict values $results]
- {*}$deliver [kernel_1 execute]
- } [namespace current]] $a $b]]
- set task2 [relay order 0 [coroutine p2 [list apply data {
- relay accept deliver [info coroutine]
- relay call 0 cl::Buffer copy $data
- kernel_2 bind [relay receive]
- {*}$deliver [kernel_2 execute]
- } [namespace current]]]]
- while {[incr i] <= 2} {
- catch {relay receive} res options
- switch [dict get $options -id] $task1 {
- set res1 $res
- } $task2 {
- set res2 $res
- }
- }
- # Do things with res_1 and res_2