Hello all,
I have written some code that sends messages to various branches of other processing code. Two of these branches rely on each other, and I also need to make sure that one branch has completely executed prior to the other passing beyond a certain point.
Basically what I have done is to stick a 'delay 0' object in the "dependant" branch. Am I correct in that using this forces this branch to "postpone" itself, allowing the other branch to complete its code? This has been working for me, as I had hoped, but I was wondering if there is a better way to handle this.
I can see one problem with this if there is a dependancy of several branches. Short of having the code branches merge, is there some other way to achieve this? Are there such things as state flags or "semifores" in pd? (ie don't continue until "my-state" is true).
I have included an example of what I have done.
Thanks,
Mike
#N canvas 290 147 491 518 10; #X obj 38 134 random 1000; #X obj 120 134 random 1000; #X obj 38 153 s one; #X obj 120 153 s two; #X obj 128 281 r one; #X obj 128 384 print one; #X obj 200 281 r two; #X obj 200 384 print two; #X obj 202 134 random 1000; #X obj 202 153 s three; #X obj 272 281 r three; #X obj 272 384 print three; #X obj 128 356 f; #X obj 88 330 delay 0; #X obj 114 305 t b f; #X obj 98 62 bng 15 250 50 0 empty empty three-two-one 0 -6 32 8 -262144 -1 -1; #X obj 98 83 t b b b; #X obj 202 63 bng 15 250 50 0 empty empty one-two-three 0 -6 32 8 -262144 -1 -1; #X obj 202 84 t b b b; #X connect 0 0 2 0; #X connect 1 0 3 0; #X connect 4 0 14 0; #X connect 6 0 7 0; #X connect 8 0 9 0; #X connect 10 0 11 0; #X connect 12 0 5 0; #X connect 13 0 12 0; #X connect 14 0 13 0; #X connect 14 1 12 1; #X connect 15 0 16 0; #X connect 16 0 0 0; #X connect 16 1 1 0; #X connect 16 2 8 0; #X connect 17 0 18 0; #X connect 18 0 8 0; #X connect 18 1 1 0; #X connect 18 2 0 0;
Hallo, Michael McGonagle hat gesagt: // Michael McGonagle wrote:
I have written some code that sends messages to various branches of other processing code. Two of these branches rely on each other, and I also need to make sure that one branch has completely executed prior to the other passing beyond a certain point.
Basically what I have done is to stick a 'delay 0' object in the "dependant" branch. Am I correct in that using this forces this branch to "postpone" itself, allowing the other branch to complete its code? This has been working for me, as I had hoped, but I was wondering if there is a better way to handle this.
First: Why didn't you just change the "one-two-three" triggers so that the rightmost one sends "two" and the middle one sends "one"? I guess, for analytical reasons, didn't you?
Then [delay 0] in theory should do just that: delay for no time, as if it weren't there. It obviously doesn't do that. In my eyes this is wrong and a bug. So I wouldn't rely on it for ordering of messages. It sure is better to order with trigger-objects.
I can see one problem with this if there is a dependancy of several branches. Short of having the code branches merge, is there some other way to achieve this? Are there such things as state flags or "semifores" in pd? (ie don't continue until "my-state" is true).
As I said: Why not order the branch at the root with the correct trigger ordering?
ciao