コード例 #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));
     }
 }
コード例 #2
0
ファイル: HeavySingleContextHandler.cs プロジェクト: yvvan/rd
 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);
 }
コード例 #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);
     }
 }
コード例 #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);
     }
 }
コード例 #5
0
 internal ISingleContextHandler <T> GetHandlerForContext <T>(RdContext <T> context)
 {
     return((ISingleContextHandler <T>)myHandlersMap[context]);
 }
コード例 #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);
 }
コード例 #7
0
 public LightSingleContextHandler(RdContext <T> context)
 {
     Context = context;
 }
コード例 #8
0
 public RdPerContextMap(RdContext <K> context, Func <bool, V> valueFactory)
 {
     myValueFactory = valueFactory;
     Context        = context;
     myMap          = new ViewableMap <K, V>();
 }