 |
Changeset 2449
- Timestamp:
- 07/12/07 14:11:46
(1 year ago)
- Author:
- kris
- Message:
moved some things around
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2448 |
r2449 |
|
| 12 | 12 | *******************************************************************************/ |
|---|
| 13 | 13 | |
|---|
| 14 | | real multiply (real x, real y) |
|---|
| | 14 | real add (real x, real y) |
|---|
| 15 | 15 | { |
|---|
| 16 | | return x * y; |
|---|
| | 16 | return x + y; |
|---|
| 17 | 17 | } |
|---|
| 18 | 18 | |
|---|
| … | … | |
| 36 | 36 | *******************************************************************************/ |
|---|
| 37 | 37 | |
|---|
| 38 | | class Add : NetworkCall |
|---|
| | 38 | class Subtract : NetworkCall |
|---|
| 39 | 39 | { |
|---|
| 40 | 40 | double a, |
|---|
| … | … | |
| 52 | 52 | override void execute () |
|---|
| 53 | 53 | { |
|---|
| 54 | | result = a + b; |
|---|
| | 54 | result = a - b; |
|---|
| 55 | 55 | } |
|---|
| 56 | 56 | |
|---|
| r2448 |
r2449 |
|
| 24 | 24 | auto channel = cluster.createChannel ("rpc.channel"); |
|---|
| 25 | 25 | |
|---|
| | 26 | // an implicit task instance |
|---|
| | 27 | auto add = new NetCall!(add); |
|---|
| | 28 | |
|---|
| 26 | 29 | // an explicit task instance |
|---|
| 27 | | auto add = new Add; |
|---|
| 28 | | |
|---|
| 29 | | // an implicit task instance |
|---|
| 30 | | auto mul = new NetCall!(multiply); |
|---|
| | 30 | auto sub = new Subtract; |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | StopWatch w; |
|---|
| … | … | |
| 38 | 38 | // both tasks are used in the same manner |
|---|
| 39 | 39 | add (1, 2, channel); |
|---|
| 40 | | mul (1, 2, channel); |
|---|
| | 40 | sub (3, 4, channel); |
|---|
| 41 | 41 | } |
|---|
| 42 | 42 | Stdout.formatln ("{} calls/s", 20000/w.stop); |
|---|
| r2448 |
r2449 |
|
| 28 | 28 | { |
|---|
| 29 | 29 | auto server = new TaskServer (new InternetAddress(arg.port), arg.log); |
|---|
| 30 | | server.enroll (new Add); |
|---|
| 31 | | server.enroll (new NetCall!(multiply)); |
|---|
| | 30 | server.enroll (new NetCall!(add)); |
|---|
| | 31 | server.enroll (new Subtract); |
|---|
| 32 | 32 | server.start; |
|---|
| 33 | 33 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic