Clocks and Synchronization - kombu.clocks

kombu.clocks

Logical Clocks and Synchronization.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

class kombu.clocks.LamportClock(initial_value=0)

Lamport’s logical clock.

From Wikipedia:

A Lamport logical clock is a monotonically incrementing software counter maintained in each process. It follows some simple rules:

  • A process increments its counter before each event in that process;
  • When a process sends a message, it includes its counter value with the message;
  • On receiving a message, the receiver process sets its counter to be greater than the maximum of its own value and the received value before it considers the message received.

Conceptually, this logical clock can be thought of as a clock that only has meaning in relation to messages moving between processes. When a process receives a message, it resynchronizes its logical clock with the sender.

Usage

When sending a message use forward() to increment the clock, when receiving a message use adjust() to sync with the time stamp of the incoming message.

adjust(other)
forward()
value = 0

The clocks current value.

Table Of Contents

Previous topic

Mixin Classes - kombu.mixins

Next topic

kombu.compat

This Page