/// <summary> /// Fork a stamp into 4 distinct stamps (as out parameters) /// </summary> /// <param name="source">The source stamp.</param> /// <param name="s1">1st stamp with a unique identity and a copy of the causal history.</param> /// <param name="s2">2nd stamp with a unique identity and a copy of the causal history.</param> /// <param name="s3">3rd stamp with a unique identity and a copy of the causal history.</param> /// <param name="s4">4th stamp with a unique identity and a copy of the causal history.</param> /// <remarks> /// A convenience method when out parameters are preferred over a return 4-tuple. /// </remarks> public static void Fork(this Stamp source, out Stamp s1, out Stamp s2, out Stamp s3, out Stamp s4) { var forked = source.Fork4(); s1 = forked.Item1; s2 = forked.Item2; s3 = forked.Item3; s4 = forked.Item4; }
/// <inheritdoc/> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string text = value as string; if (text != null) { return(Stamp.Parse(text)); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Fork a stamp into 3 distinct stamps (returns a 3-tuple) /// </summary> /// <param name="source">The source stamp.</param> /// <returns>A 3-tuple, each with a unique identity and a copy of the causal history.</returns> /// <remarks> /// A convenience method for forking 1 stamp into 3 unique stamps. /// </remarks> public static (Stamp, Stamp, Stamp) Fork3(this Stamp source) { (Stamp, Stamp)fork = source.Fork(); Stamp a = fork.Item1; Stamp c = fork.Item2; (Stamp, Stamp)fork1 = a.Fork(); a = fork1.Item1; Stamp b = fork1.Item2; return(a, b, c); }
/// <summary> /// Indicates whether the source stamp is equivalent (causally equal) with the other stamp. /// </summary> /// <param name="source">The source.</param> /// <param name="other">The other, for comparison.</param> /// <returns><c>true</c> if a.leq(b) Λ b.leq(a); otherwise <c>false</c>.</returns> public static bool Equivalent(this Stamp source, Stamp other) { return(source.Leq(other) && other.Leq(source)); }
/// <summary> /// Indicates whether the source stamp is concurrent with the other stamp. /// </summary> /// <param name="source">The source.</param> /// <param name="other">The other, for comparison.</param> /// <returns><c>true</c> if ¬(a.leq(b)) and ¬(b.leq(a)); otherwise, <c>false</c>.</returns> public static bool Concurrent(this Stamp source, Stamp other) { return(!source.Leq(other) && !other.Leq(source)); }
public static (Stamp, Stamp) Sync(this Stamp source, Stamp other) { return(source.Join(other).Fork()); }
public static Stamp Receive(this Stamp source, Stamp other) { return(source.Join(other).Event()); }