changeset 594:770b59e49e81

Renamed Runtime.callback to Runtime.schedule_callback.
author Martin Geisler <mg@daimi.au.dk>
date Sat, 22 Mar 2008 14:59:27 +0100
parents b892c3460a13
children 3630428d6a51
files NEWS viff/comparison.py viff/runtime.py viff/test/test_basic_runtime.py
diffstat 4 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Sat Mar 22 14:41:00 2008 +0100
+++ b/NEWS	Sat Mar 22 14:59:27 2008 +0100
@@ -18,7 +18,8 @@
 
 The Runtime class has been split into several parts and two new mixin
 classes provide different comparison protocols. Several coercion
-problems were fixed.
+problems were fixed. The Runtime.callback method was renamed to
+Runtime.schedule_callback.
 
 Details:
 
--- a/viff/comparison.py	Sat Mar 22 14:41:00 2008 +0100
+++ b/viff/comparison.py	Sat Mar 22 14:59:27 2008 +0100
@@ -94,7 +94,7 @@
         T = self.open(2**t - int_b + a)
 
         result = gather_shares([T] + bit_bits)
-        self.callback(result, self._finish_greater_than_equal, l)
+        self.schedule_callback(result, self._finish_greater_than_equal, l)
         return result
 
     @increment_pc
@@ -268,9 +268,9 @@
         z = share_a - share_b + 2**l
         c = self.open(r_full + z)
 
-        self.callback(c, self._finish_greater_than_equal,
-                      field, smallField, s_bit, s_sign, mask,
-                      r_modl, r_bits, z)
+        self.schedule_callback(c, self._finish_greater_than_equal,
+                               field, smallField, s_bit, s_sign, mask,
+                               r_modl, r_bits, z)
         return c
 
     @increment_pc
--- a/viff/runtime.py	Sat Mar 22 14:41:00 2008 +0100
+++ b/viff/runtime.py	Sat Mar 22 14:59:27 2008 +0100
@@ -501,7 +501,7 @@
         dl = DeferredList(vars)
         dl.addCallback(lambda _: self.shutdown())
 
-    def callback(self, deferred, func, *args, **kwargs):
+    def schedule_callback(self, deferred, func, *args, **kwargs):
         """Schedule a callback on a deferred with the correct program
         counter.
 
@@ -659,14 +659,14 @@
                         d = Share(self, share.field, (share.field(id), share))
                     else:
                         d = self._expect_share(id, share.field)
-                        self.callback(d, lambda s, id: (s.field(id), s), id)
+                        self.schedule_callback(d, lambda s, id: (s.field(id), s), id)
                     deferreds.append(d)
                 # TODO: This list ought to trigger as soon as more than
                 # threshold shares has been received.
                 return self._recombine(deferreds, threshold)
 
         result = share.clone()
-        self.callback(result, exchange)
+        self.schedule_callback(result, exchange)
         if self.id in receivers:
             return result
 
@@ -717,8 +717,9 @@
 
         result = gather_shares([share_a, share_b])
         result.addCallback(lambda (a, b): a * b)
-        self.callback(result, self._shamir_share)
-        self.callback(result, self._recombine, threshold=2*self.threshold)
+        self.schedule_callback(result, self._shamir_share)
+        self.schedule_callback(result, self._recombine,
+                               threshold=2*self.threshold)
         return result
 
     @increment_pc
@@ -853,7 +854,7 @@
                 # convert the resulting -1/1 share into a 0/1 share.
                 return Share(self, field, (share/root + 1) / 2)
 
-        self.callback(result, finish, share, binary)
+        self.schedule_callback(result, finish, share, binary)
         return result
 
     @increment_pc
--- a/viff/test/test_basic_runtime.py	Sat Mar 22 14:41:00 2008 +0100
+++ b/viff/test/test_basic_runtime.py	Sat Mar 22 14:59:27 2008 +0100
@@ -67,7 +67,7 @@
             self.assertEquals(runtime.program_counter, [0])
 
         d = Deferred()
-        runtime.callback(d, verify_program_counter)
+        runtime.schedule_callback(d, verify_program_counter)
 
         runtime.synchronize()
         self.assertEquals(runtime.program_counter, [1])
@@ -121,8 +121,8 @@
         def method_a(runtime):
             self.assertEquals(runtime.program_counter, [1, 0])
 
-            runtime.callback(d1, verify_program_counter, 1)
-            runtime.callback(d2, verify_program_counter, 2)
+            runtime.schedule_callback(d1, verify_program_counter, 1)
+            runtime.schedule_callback(d2, verify_program_counter, 2)
 
         method_a(runtime)