http://hg.viff.dk/viff/rev/d6ff18bd643c
changeset: 1175:d6ff18bd643c
user: Marcel Keller <[email protected]>
date: Mon May 04 14:04:36 2009 +0200
summary: Replaced addCallback() by schedule_callback() for callbacks using
the program counter.
To achieve this, schedule_callback() has to return the return value of
addCallback() (the Deferred).
diffstat:
5 files changed, 8 insertions(+), 8 deletions(-)
apps/aes.py | 2 +-
apps/millionaires.py | 4 ++--
viff/equality.py | 2 +-
viff/runtime.py | 4 ++--
viff/test/test_active_runtime.py | 4 ++--
diffs (82 lines):
diff -r ade6aff2dde2 -r d6ff18bd643c apps/aes.py
--- a/apps/aes.py Mon May 04 13:05:21 2009 +0200
+++ b/apps/aes.py Mon May 04 14:04:36 2009 +0200
@@ -81,7 +81,7 @@
rt.shutdown()
g = gather_shares(opened_ciphertext)
- g.addCallback(fin)
+ rt.schedule_callback(g, fin)
def share_key(rt):
key = []
diff -r ade6aff2dde2 -r d6ff18bd643c apps/millionaires.py
--- a/apps/millionaires.py Mon May 04 13:05:21 2009 +0200
+++ b/apps/millionaires.py Mon May 04 14:04:36 2009 +0200
@@ -97,10 +97,10 @@
# the argument (which is None since self.results_ready does
# not return anything), so we throw it away using a lambda
# expressions which ignores its first argument.
- results.addCallback(lambda _: runtime.synchronize())
+ runtime.schedule_callback(results, lambda _: runtime.synchronize())
# The next callback shuts the runtime down, killing the
# connections between the players.
- results.addCallback(lambda _: runtime.shutdown())
+ runtime.schedule_callback(results, lambda _: runtime.shutdown())
def results_ready(self, results):
# Since this method is called as a callback above, the results
diff -r ade6aff2dde2 -r d6ff18bd643c viff/equality.py
--- a/viff/equality.py Mon May 04 13:05:21 2009 +0200
+++ b/viff/equality.py Mon May 04 14:04:36 2009 +0200
@@ -74,7 +74,7 @@
xj = (-1) * (1/Zp(2)) * (bj - 1)
return xj
- x = [cj.addCallback(finish, bj) for cj, bj in zip(c, b)]
+ x = [self.schedule_callback(cj, finish, bj) for cj, bj in zip(c, b)]
# Take the product (this is here the same as the "and") of all
# the x'es
diff -r ade6aff2dde2 -r d6ff18bd643c viff/runtime.py
--- a/viff/runtime.py Mon May 04 13:05:21 2009 +0200
+++ b/viff/runtime.py Mon May 04 14:04:36 2009 +0200
@@ -570,7 +570,7 @@
The runtime is shut down when all variables are calculated.
"""
dl = DeferredList(vars)
- dl.addCallback(lambda _: self.shutdown())
+ self.schedule_callback(dl, lambda _: self.shutdown())
@increment_pc
def schedule_callback(self, deferred, func, *args, **kwargs):
@@ -603,7 +603,7 @@
finally:
self.program_counter[:] = current_pc
- deferred.addCallback(callback_wrapper, *args, **kwargs)
+ return deferred.addCallback(callback_wrapper, *args, **kwargs)
@increment_pc
def synchronize(self):
diff -r ade6aff2dde2 -r d6ff18bd643c viff/test/test_active_runtime.py
--- a/viff/test/test_active_runtime.py Mon May 04 13:05:21 2009 +0200
+++ b/viff/test/test_active_runtime.py Mon May 04 14:04:36 2009 +0200
@@ -88,7 +88,7 @@
double = runtime.double_share_random(T, runtime.threshold,
2*runtime.threshold, self.Zp)
- double.addCallback(check)
+ runtime.schedule_callback(double, check)
return double
@protocol
@@ -116,7 +116,7 @@
count, triples = runtime.generate_triples(self.Zp)
self.assertEquals(count, runtime.num_players - 2*runtime.threshold)
- triples.addCallback(check)
+ runtime.schedule_callback(triples, check)
return triples
_______________________________________________
viff-commits mailing list
[email protected]
http://lists.viff.dk/listinfo.cgi/viff-commits-viff.dk