changeset 1174:ade6aff2dde2

Added @increment_pc to schedule_callback() to enable multiple callbacks.
author Marcel Keller <mkeller@cs.au.dk>
date Mon, 04 May 2009 13:05:21 +0200
parents 8d439efb4a90
children d6ff18bd643c
files viff/active.py viff/passive.py viff/runtime.py viff/test/test_basic_runtime.py
diffstat 4 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/viff/active.py	Fri Apr 24 14:00:00 2009 +0200
+++ b/viff/active.py	Mon May 04 13:05:21 2009 +0200
@@ -502,6 +502,7 @@
         result = Share(self, share_x.field)
         # This is the Deferred we will do processing on.
         triple = self.get_triple(share_x.field)
+        triple.addCallback(gather_shares)
         self.schedule_callback(triple, finish_mul)
         # We add the result to the chains in triple.
         triple.chainDeferred(result)
--- a/viff/passive.py	Fri Apr 24 14:00:00 2009 +0200
+++ b/viff/passive.py	Mon May 04 13:05:21 2009 +0200
@@ -98,7 +98,7 @@
                         d = Share(self, share.field, (share.field(peer_id), share))
                     else:
                         d = self._expect_share(peer_id, share.field)
-                        self.schedule_callback(d, lambda s, peer_id: (s.field(peer_id), s), peer_id)
+                        d.addCallback(lambda s, peer_id: (s.field(peer_id), s), peer_id)
                     deferreds.append(d)
                 return recombine(deferreds)
 
--- a/viff/runtime.py	Fri Apr 24 14:00:00 2009 +0200
+++ b/viff/runtime.py	Mon May 04 13:05:21 2009 +0200
@@ -572,6 +572,7 @@
         dl = DeferredList(vars)
         dl.addCallback(lambda _: self.shutdown())
 
+    @increment_pc
     def schedule_callback(self, deferred, func, *args, **kwargs):
         """Schedule a callback on a deferred with the correct program
         counter.
--- a/viff/test/test_basic_runtime.py	Fri Apr 24 14:00:00 2009 +0200
+++ b/viff/test/test_basic_runtime.py	Mon May 04 13:05:21 2009 +0200
@@ -62,13 +62,13 @@
         """
 
         def verify_program_counter(_):
-            self.assertEquals(runtime.program_counter, [0])
+            self.assertEquals(runtime.program_counter, [1, 0])
 
         d = Deferred()
         runtime.schedule_callback(d, verify_program_counter)
 
         runtime.synchronize()
-        self.assertEquals(runtime.program_counter, [1])
+        self.assertEquals(runtime.program_counter, [2])
 
         # Now trigger verify_program_counter.
         d.callback(None)
@@ -129,8 +129,6 @@
         d2.callback(None)
 
         return gatherResults([d1, d2])
-    test_multiple_callbacks.skip = ("TODO: Scheduling callbacks fails to "
-                                    "increment program counter!")
 
     @protocol
     def test_multi_send(self, runtime):