Exemple #1
0
  def process_sender(self, link, connection):
    if link.source is None: return
    key = (connection.container_id, link.name)
    source = self.sources[key]
    while link.capacity() > 0:
      tag, xfr = source.get()
      if xfr is None:
        link.drained()
        break
      else:
        link.send(delivery_tag = tag, message_format = xfr.message_format,
                  settled = link.snd_settle_mode == 1, # XXX: enums
                  payload = xfr.payload)

    for t, l, r in link.get_remote(modified=True):
      if l.resumed:
        link.settle(t, None)
      elif r.settled or r.state is not None:
        def doit(t=t, s=r.state):
          state = source.settle(t, r.state)
          link.settle(t, state)
        def undo(t=t):
          pass
        if r.state:
          txn = self.coordinator.get_transaction(r.state)
        else:
          txn = None
        if txn:
          txn.add_work(doit, undo)
        else:
          doit()
      r.modified = False
Exemple #2
0
  def process_receiver(self, link, connection):
    if link.target is None: return
    key = (connection.container_id, link.name)
    target = self.targets[key]

    for t, l, r in link.get_remote():
      if l.resumed:
        link.settle(t, None)
      elif r.settled and not isinstance(l.state, TransactionalState):
        state = target.settle(t, l.state)
        link.settle(t, state)

    if target.capacity() and link.credit() < 10: link.flow(10)