September 2018
Intermediate to advanced
328 pages
9h 10m
English
The example uses two worker threads: one for addition and another for subtraction. Consequently, we'll need two separate Wasm modules. Create a folder named /lib in your /parallel-wasm directory. Within the /lib directory, create a file named add.c and populate it with the following contents:
int calculate(int firstVal, int secondVal) { return firstVal + secondVal;}
Create another file in /lib named subtract.c and populate it with the following contents:
int calculate(int firstVal, int secondVal) { return firstVal - secondVal;}
Note that the function name in both files is calculate. This was done so we don't have to write any conditional logic within the worker code to determine the Wasm function to call. The algebraic operation ...
Read now
Unlock full access