Loading

  1. Configuration
  2. Example

Concurrent EVAL extension

Depending on your Warp 10 use, you might need to parallelize tasks. You can run several macros in parallel with this extension. Do not activate this extension on a multi-user instance, there is a high risk a user can saturate your CPU.

This extension adds the following functions to WarpScript:

Configuration

Your custom configurations can be stored in a new etc/conf.d/99-myWarp10.conf file. Your custom configurations will override all the predefined Warp 10 configurations.

// CEVAL, SYNC
warpscript.extension.concurrent = io.warp10.script.ext.concurrent.ConcurrentWarpScriptExtension

Example

See CEVAL documentation.

Here is an example that demonstrates the purpose of SYNC when you change the same variable from multiple threads:

//CEVAL with synchronization [] 'l' STORE [] 's' STORE <% DROP //drop the index <% $l [ 42 ] APPEND DROP %> SYNC <% $s 42 +! DROP %> SYNC %> 'macro' STORE [] 'macroLIST' STORE 1 10000 <% DROP //drop the index $macroLIST $macro +! DROP %> FOR // execute 10000 times on 8 threads $macroLIST 8 CEVAL DROP $l SIZE //exactly 10000 $s SIZE //exactly 10000 'CEVAL with sync' //CEVAL without synchronization [] 'l' STORE [] 's' STORE <% DROP //drop the index $l [ 42 ] APPEND DROP $s 42 +! DROP %> 'macro' STORE [] 'macroLIST' STORE 1 10000 <% DROP //drop the index $macroLIST $macro +! DROP %> FOR // execute 10000 times on 8 threads $macroLIST 8 CEVAL DROP $l SIZE // not exactly 10000 $s SIZE // not exactly 10000 'CEVAL without sync'