Sha256: dd506f42b5655e9e915ee81c8c568594cecfa03f2dba1e41912eba33c6d45215

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

(*

 Schedule a call for an external process +called+ with +input+, and
 +resume+ back to the calling process in context +resumeCtx+.

 Implementation adds two step entries in +steps+ sequence.
 Entries cannot be made to position 1 because it represents
 currently running process, which get shifted away the sequnce
 once the process finishes.

*)

macro schedule_process_mac( called, input, resume, resumeCtx ) {

    \* NOTICE!!: call and resume steps always successive elements
    \* The only option is to apped to +steps+
    if ( Cardinality( { p \in 1..Len(steps) :  \A s \in steps[p]: s.ctx = Nil }  ) <= 1  ) {
	  steps := steps \o
		  << { NewStep( called, input, Nil ) },
		     { NewStep( resume, Nil, resumeCtx ) } >>;
    } else {
         \* Non-deteministic choice where to put
	 with ( pos \in { p \in 2..Len(steps) : \A s \in steps[p]: s.ctx = Nil  } ) {
	   steps := IF pos = Len(steps) THEN
		     steps \o
			<< { NewStep( called, input, Nil ) },
			   { NewStep( resume, Nil, resumeCtx ) } >>
		      ELSE
			 SubSeq( steps, 1, pos-1 )  \o
			     << { NewStep( called, input, Nil ) },
				{ NewStep( resume, Nil, resumeCtx ) } >> \o         
			 SubSeq( steps, pos, Len(steps))
		    ;
	 }; \* with
   }; \* else
  skip;
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tla-sbuilder-0.3.9 mustache/resources/schedule_process_macro.tla
tla-sbuilder-0.3.8 mustache/resources/schedule_process_macro.tla
tla-sbuilder-0.3.7 mustache/resources/schedule_process_macro.tla
tla-sbuilder-0.3.4 mustache/resources/schedule_process_macro.tla