viff

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 diff
     1.1 --- a/viff/active.py	Fri Apr 24 14:00:00 2009 +0200
     1.2 +++ b/viff/active.py	Mon May 04 13:05:21 2009 +0200
     1.3 @@ -502,6 +502,7 @@
     1.4          result = Share(self, share_x.field)
     1.5          # This is the Deferred we will do processing on.
     1.6          triple = self.get_triple(share_x.field)
     1.7 +        triple.addCallback(gather_shares)
     1.8          self.schedule_callback(triple, finish_mul)
     1.9          # We add the result to the chains in triple.
    1.10          triple.chainDeferred(result)
     2.1 --- a/viff/passive.py	Fri Apr 24 14:00:00 2009 +0200
     2.2 +++ b/viff/passive.py	Mon May 04 13:05:21 2009 +0200
     2.3 @@ -98,7 +98,7 @@
     2.4                          d = Share(self, share.field, (share.field(peer_id), share))
     2.5                      else:
     2.6                          d = self._expect_share(peer_id, share.field)
     2.7 -                        self.schedule_callback(d, lambda s, peer_id: (s.field(peer_id), s), peer_id)
     2.8 +                        d.addCallback(lambda s, peer_id: (s.field(peer_id), s), peer_id)
     2.9                      deferreds.append(d)
    2.10                  return recombine(deferreds)
    2.11  
     3.1 --- a/viff/runtime.py	Fri Apr 24 14:00:00 2009 +0200
     3.2 +++ b/viff/runtime.py	Mon May 04 13:05:21 2009 +0200
     3.3 @@ -572,6 +572,7 @@
     3.4          dl = DeferredList(vars)
     3.5          dl.addCallback(lambda _: self.shutdown())
     3.6  
     3.7 +    @increment_pc
     3.8      def schedule_callback(self, deferred, func, *args, **kwargs):
     3.9          """Schedule a callback on a deferred with the correct program
    3.10          counter.
     4.1 --- a/viff/test/test_basic_runtime.py	Fri Apr 24 14:00:00 2009 +0200
     4.2 +++ b/viff/test/test_basic_runtime.py	Mon May 04 13:05:21 2009 +0200
     4.3 @@ -62,13 +62,13 @@
     4.4          """
     4.5  
     4.6          def verify_program_counter(_):
     4.7 -            self.assertEquals(runtime.program_counter, [0])
     4.8 +            self.assertEquals(runtime.program_counter, [1, 0])
     4.9  
    4.10          d = Deferred()
    4.11          runtime.schedule_callback(d, verify_program_counter)
    4.12  
    4.13          runtime.synchronize()
    4.14 -        self.assertEquals(runtime.program_counter, [1])
    4.15 +        self.assertEquals(runtime.program_counter, [2])
    4.16  
    4.17          # Now trigger verify_program_counter.
    4.18          d.callback(None)
    4.19 @@ -129,8 +129,6 @@
    4.20          d2.callback(None)
    4.21  
    4.22          return gatherResults([d1, d2])
    4.23 -    test_multiple_callbacks.skip = ("TODO: Scheduling callbacks fails to "
    4.24 -                                    "increment program counter!")
    4.25  
    4.26      @protocol
    4.27      def test_multi_send(self, runtime):