Example #1
0
 private void EnsureLightHandlerExists <T>(RdContext <T> context)
 {
     Assertion.Assert(!context.IsHeavy, "!key.IsHeavy");
     if (!myHandlersMap.ContainsKey(context))
     {
         DoAddHandler(context, new LightSingleContextHandler <T>(context));
     }
 }
Example #2
0
 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);
 }
Example #3
0
 private void DoAddHandler <T>(RdContext <T> context, ISingleContextHandler <T> handler)
 {
     if (myHandlersMap.TryAdd(context, handler))
     {
         context.RegisterOn(SerializationContext.Serializers);
         lock (myOrderingLock)
             myHandlerOrder.Add(handler);
     }
 }
Example #4
0
 /// <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);
     }
 }
Example #5
0
 internal ISingleContextHandler <T> GetHandlerForContext <T>(RdContext <T> context)
 {
     return((ISingleContextHandler <T>)myHandlersMap[context]);
 }
Example #6
0
 /// <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);
 }
Example #7
0
 public LightSingleContextHandler(RdContext <T> context)
 {
     Context = context;
 }
Example #8
0
 public RdPerContextMap(RdContext <K> context, Func <bool, V> valueFactory)
 {
     myValueFactory = valueFactory;
     Context        = context;
     myMap          = new ViewableMap <K, V>();
 }