Posted to tcl by pooryorick at Tue May 24 19:23:22 GMT 2016view raw

  1. set task1 [relay order 0 [coroutine p1 [list apply args {
  2. relay accept deliver [info coroutine]
  3. foreach arg $args {
  4. dict set results [
  5. relay call cl::Buffer copy $arg] {}
  6. }
  7. foreach arg $args {
  8. catch {relay receive} res options
  9. dict set results [dict get $options -id] $res
  10. }
  11. kernel_1 bind {*}[dict values $results]
  12. {*}$deliver [kernel_1 execute]
  13. } [namespace current]] $a $b]]
  14.  
  15.  
  16. set task2 [relay order 0 [coroutine p2 [list apply data {
  17. relay accept deliver [info coroutine]
  18. relay call 0 cl::Buffer copy $data
  19. kernel_2 bind [relay receive]
  20. {*}$deliver [kernel_2 execute]
  21. } [namespace current]]]]
  22.  
  23. while {[incr i] <= 2} {
  24. catch {relay receive} res options
  25. switch [dict get $options -id] $task1 {
  26. set res1 $res
  27. } $task2 {
  28. set res2 $res
  29. }
  30. }
  31.  
  32. # Do things with res_1 and res_2
  33.