Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 2448

Show
Ignore:
Timestamp:
07/12/07 00:44:41 (1 year ago)
Author:
kris
Message:

Added Tom's magic wrappers

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/example/cluster/Add.d

    r2442 r2448  
    33*******************************************************************************/ 
    44 
    5 private import tango.net.cluster.NetworkCall; 
     5public import tango.net.cluster.NetworkCall; 
     6 
    67 
    78/******************************************************************************* 
     9         
     10        a Task function 
     11 
     12*******************************************************************************/ 
     13 
     14real multiply (real x, real y) 
     15{ 
     16        return x * y; 
     17} 
     18 
     19 
     20/******************************************************************************* 
     21 
     22        a Task function 
     23 
     24*******************************************************************************/ 
     25 
     26int divide (int x, int y) 
     27{ 
     28        return x / y; 
     29} 
     30 
     31 
     32/******************************************************************************* 
     33 
     34        a verbose Task message 
    835 
    936*******************************************************************************/ 
     
    2855        } 
    2956 
    30         override void read  (IReader input)  {input (a) (b) (result);} 
     57        override void read  (IReader input)  {input (a)(b)(result);} 
    3158 
    32         override void write (IWriter output) {output (a) (b) (result);} 
     59        override void write (IWriter output) {output (a)(b)(result);} 
    3360} 
  • trunk/example/cluster/tclient.d

    r2445 r2448  
    2121void main (char[][] args) 
    2222{ 
    23         StopWatch w; 
    24  
    2523        auto cluster = (new Cluster).join; 
    2624        auto channel = cluster.createChannel ("rpc.channel"); 
    2725 
     26        // an explicit task instance 
    2827        auto add = new Add; 
     28 
     29        // an implicit task instance 
     30        auto mul = new NetCall!(multiply); 
     31 
     32        StopWatch w; 
    2933        while (true) 
    3034              { 
    3135              w.start; 
    32               for (int i=20000; i--;) 
    33                    add (1, 2, channel); 
    34          
     36              for (int i=10000; i--;) 
     37                  { 
     38                  // both tasks are used in the same manner 
     39                  add (1, 2, channel); 
     40                  mul (1, 2, channel); 
     41                  } 
    3542              Stdout.formatln ("{} calls/s", 20000/w.stop); 
    3643              } 
  • trunk/example/cluster/tserver.d

    r2442 r2448  
    2929           auto server = new TaskServer (new InternetAddress(arg.port), arg.log); 
    3030           server.enroll (new Add); 
     31           server.enroll (new NetCall!(multiply)); 
    3132           server.start; 
    3233           }