Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: client/samples/dartcombat/player.dart

Issue 8457005: convert isolates to use Future (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated co19 Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/samples/dartcombat/state.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/samples/dartcombat/player.dart
diff --git a/client/samples/dartcombat/player.dart b/client/samples/dartcombat/player.dart
index c5b8a87eeb9d2571b59d92d256e0e20a43441bb6..fbea71163718224b0cf2a571e45941903987faea 100644
--- a/client/samples/dartcombat/player.dart
+++ b/client/samples/dartcombat/player.dart
@@ -7,7 +7,7 @@ interface Player factory PlayerImpl {
Player();
- final Promise<SendPort> portToPlayer;
+ final Future<SendPort> portToPlayer;
void setup(Window window, int player);
@@ -21,10 +21,10 @@ interface Enemy factory EnemyImpl {
Enemy(SendPort port);
/** tell the enemy that we are ready, receive confirmation asynchronously. */
- Promise<int> ready();
+ Future<int> ready();
/** shoot asynchronously. */
- Promise<int> shoot(int x, int y);
+ Future<int> shoot(int x, int y);
}
@@ -33,7 +33,7 @@ interface Enemy factory EnemyImpl {
* contains the actual player state.
*/
class PlayerImpl implements Player {
- final Promise<SendPort> portToPlayer;
+ final Future<SendPort> portToPlayer;
PlayerImpl() : portToPlayer = new PlayerState().spawn();
@@ -65,8 +65,8 @@ class EnemyImpl implements Enemy {
EnemyImpl(this.portToEnemy) {}
- Promise<int> ready() {
- Promise<int> res = new Promise<int>();
+ Future<int> ready() {
+ Completer<int> res = new Completer<int>();
ReceivePort port = portToEnemy.call(
{ "action" : MessageIds.ENEMY_IS_READY });
port.receive((var message, SendPort replyTo) {
@@ -74,14 +74,14 @@ class EnemyImpl implements Enemy {
if (success) {
res.complete(0);
} else {
- res.fail(message[1]);
+ res.completeException(message[1]);
}
});
- return res;
+ return res.future;
}
- Promise<int> shoot(int x, int y) {
- Promise<int> res = new Promise<int>();
+ Future<int> shoot(int x, int y) {
+ Completer<int> res = new Completer<int>();
ReceivePort port = portToEnemy.call(
{ "action" : MessageIds.SHOOT, "args" : [x, y] });
port.receive((var message, SendPort replyTo) {
@@ -89,10 +89,10 @@ class EnemyImpl implements Enemy {
if (success) {
res.complete(message[1][0]);
} else {
- res.fail(message[1]);
+ res.completeException(message[1]);
}
});
- return res;
+ return res.future;
}
}
« no previous file with comments | « no previous file | client/samples/dartcombat/state.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698