Distributed programming: Difference between revisions

m
m (→‎{{header|Perl}}: future-proof for 5.36)
m (→‎{{header|Wren}}: Minor tidy)
 
Line 1,931:
<br>
We need two Wren scripts one for each VM:
<syntaxhighlight lang="ecmascriptwren">/* distributed_programming_serverDistributed_programming_server.wren */
 
class Rpc {
Line 1,952:
HTTP.serve(listener)</syntaxhighlight>
<br>
<syntaxhighlight lang="ecmascriptwren">/* distributed_programming_server2Distributed_programming_server_2.wren */
 
class TaxComputer {
Line 1,962:
<br>
We now embed these scripts in the following Go program and run it on one terminal.
<syntaxhighlight lang="go">/* go run distributed_programming_serverDistributed_programming_server.go */
 
package main
Line 1,980:
var vm2 *wren.VM
 
var fileName = "distributed_programming_serverDistributed_programming_server.wren"
var fileName2 = "distributed_programming_server2Distributed_programming_server_2.wren"
 
func (taxRate TaxComputer) Tax(x float64, r *float64) error {
Line 2,051:
<br>
Just one Wren script needed here:
<syntaxhighlight lang="ecmascriptwren">/* distributed_programming_clientDistributed_programming_client.wren */
 
import "./fmt" for Fmt
Line 2,069:
<br>
which we embed in the following Go program and run it on a different terminal.
<syntaxhighlight lang="go">/* go run distributed_programming_clientDistributed_programming_client.go */
 
package main
Line 2,117:
cfg.LoadModuleFn = moduleFn
vm := cfg.NewVM()
fileName := "distributed_programming_clientDistributed_programming_client.wren"
clientMethodMap := wren.MethodMap { "call(_,_)": call }
classMap := wren.ClassMap { "Client": wren.NewClass(dialHTTP, nil, clientMethodMap) }
9,485

edits