• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..05-Feb-2019-

READMEH A D05-Feb-20191.3 KiB3834

dc#.scmH A D05-Feb-20197.4 KiB240192

dc.scmH A D05-Feb-201922.9 KiB704526

distr-comp.scmH A D05-Feb-20191.2 KiB5031

makefile.inH A D05-Feb-20195.4 KiB253160

README

1This example is a distributed application composed of two nodes
2(running in the same Scheme process).  A thread is started on the
3first node.  The thread performs a loop.  At each iteration of the
4loop it prints the name of the node it is running on, then the thread
5migrates to the other node.  This example can easily be changed so
6that each node is running on a different machine.  Say the machines
7are "foo.com" and "bar.com".  The machine "foo.com" should run
8
9(define (main)
10  (become-tcp-node
11   9000 ; TCP port-number for this node
12   'foo ; name of the first node
13   (lambda () 'no-op)))
14
15An the machine "bar.com" should run
16
17(define (main)
18  (become-tcp-node
19   9000 ; TCP port-number for this node
20   'bar ; name of the second node
21   (lambda ()
22     ; start a thread on bar.com
23     (spawn
24      (let ((n1 (current-node))
25            (n2 (make-tcp-node "foo.com" 9000 'foo)))
26        (let loop ((i 0) (a n1) (b n2))
27          (if (= i 100)
28              (exit)
29              (begin
30                (if #t
31                    (begin
32                      (pp (list i 'from (current-node-name))
33                          (current-output-port))
34                      (force-output (current-output-port))
35                      (thread-sleep! .1)))
36                (goto b)
37                (loop (+ i 1) b a)))))))))
38