private void EnsureLightHandlerExists <T>(RdContext <T> context) { Assertion.Assert(!context.IsHeavy, "!key.IsHeavy"); if (!myHandlersMap.ContainsKey(context)) { DoAddHandler(context, new LightSingleContextHandler <T>(context)); } }
public HeavySingleContextHandler(RdContext <T> context, ProtocolContexts handler) { myHandler = handler; Context = context; myInternRoot = new InternRoot <T>(context.ReadDelegate, context.WriteDelegate); myProtocolValueSet = new RdSet <T>(context.ReadDelegate, context.WriteDelegate, new ViewableSet <T>(new ConcurrentSet <T>())); myModificationCookieValueSet = new ModificationCookieViewableSet <T, ProtocolContexts.SendWithoutContextsCookie>(myHandler.CreateSendWithoutContextsCookie, myProtocolValueSet); }
private void DoAddHandler <T>(RdContext <T> context, ISingleContextHandler <T> handler) { if (myHandlersMap.TryAdd(context, handler)) { context.RegisterOn(SerializationContext.Serializers); lock (myOrderingLock) myHandlerOrder.Add(handler); } }
/// <summary> /// Registers a context to be used with this context handler. Must be invoked on protocol's scheduler /// </summary> public void RegisterContext <T>(RdContext <T> context) { if (myHandlersMap.ContainsKey(context)) { return; } if (context.IsHeavy) { EnsureHeavyHandlerExists(context); } else { EnsureLightHandlerExists(context); } }
internal ISingleContextHandler <T> GetHandlerForContext <T>(RdContext <T> context) { return((ISingleContextHandler <T>)myHandlersMap[context]); }
/// <summary> /// Get a value set for a given key. The values are local relative to transform /// </summary> public IViewableSet <T> GetValueSet <T>(RdContext <T> context) { Assertion.Assert(context.IsHeavy, "Only heavy keys have value sets, key {0} is light", context.Key); return(((HeavySingleContextHandler <T>)GetHandlerForContext(context)).LocalValueSet); }
public LightSingleContextHandler(RdContext <T> context) { Context = context; }
public RdPerContextMap(RdContext <K> context, Func <bool, V> valueFactory) { myValueFactory = valueFactory; Context = context; myMap = new ViewableMap <K, V>(); }