当前位置: 首页>>代码示例>>C#>>正文


C# AtomicReference类代码示例

本文整理汇总了C#中AtomicReference的典型用法代码示例。如果您正苦于以下问题:C# AtomicReference类的具体用法?C# AtomicReference怎么用?C# AtomicReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AtomicReference类属于命名空间,在下文中一共展示了AtomicReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CuratorFrameworkImpl

        public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)
        {
            IZookeeperFactory localZookeeperFactory = makeZookeeperFactory(builder.GetZookeeperFactory());
            this.client = new CuratorZookeeperClient(localZookeeperFactory,
                                                        builder.GetEnsembleProvider(),
                                                        builder.GetSessionTimeoutMs(),
                                                        builder.GetConnectionTimeoutMs(),
                                                        new WatchedWatcher(this),
                                                        builder.GetRetryPolicy(),
                                                        builder.CanBeReadOnly());

            listeners = new ListenerContainer<ICuratorListener>();
            unhandledErrorListeners = new ListenerContainer<IUnhandledErrorListener>();
            backgroundOperations = new DelayQueue<OperationAndData<object>>();
            @namespace = new NamespaceImpl(this, builder.GetNamespace());
            maxCloseWaitMs = builder.GetMaxCloseWaitMs();
            connectionStateManager = new ConnectionStateManager(this, builder.GetEventQueueSize());
            compressionProvider = builder.GetCompressionProvider();
            aclProvider = builder.GetAclProvider();
            state = new AtomicReference<CuratorFrameworkState>(CuratorFrameworkState.LATENT);
            useContainerParentsIfAvailable = builder.UseContainerParentsIfAvailable();

            byte[] builderDefaultData = builder.GetDefaultData();
            byte[] destDefaults = new byte[builderDefaultData.Length];
            Array.Copy(builderDefaultData, destDefaults, builderDefaultData.Length);
            defaultData = (builderDefaultData != null)
                            ?  destDefaults
                            : new byte[0];
            authInfos = buildAuths(builder);

            failedDeleteManager = new FailedDeleteManager(this);
            namespaceWatcherMap = new NamespaceWatcherMap(this);
            namespaceFacadeCache = new NamespaceFacadeCache(this);
        }
开发者ID:Lagrang,项目名称:CuratorNet,代码行数:34,代码来源:CuratorFrameworkImpl.cs

示例2: CompareAndSet_when_equal_returns_true

        public void CompareAndSet_when_equal_returns_true()
        {
            var expected = new object();
            var obj = new AtomicReference<object>(expected);

            Assert.IsTrue(obj.CompareAndSet(expected, new object()));
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:7,代码来源:AtomicReferenceTests.cs

示例3: ToString_returns_a_string_representation_of_the_object

        public void ToString_returns_a_string_representation_of_the_object()
        {
            var shared = new AtomicReference<object>();

            const string expected = "AtomicReference<System.Object>";

            Assert.AreEqual(expected, shared.ToString());
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:8,代码来源:AtomicReferenceTests.cs

示例4: AtomicReference_IEquatable_Of_Ref_Should_Compare

        public void AtomicReference_IEquatable_Of_Ref_Should_Compare()
        {
            IEquatable<object> firstAtomic = new AtomicReference<object>(new object());
            IEquatable<object> secondAtomic = new AtomicReference<object>(null);

            Assert.False(firstAtomic.Equals(false));
            Assert.False(secondAtomic.Equals(true));
        }
开发者ID:szKarlen,项目名称:atomics.net,代码行数:8,代码来源:AtomicReferenceEqualityTests.cs

示例5: GetAndSet_sets_new_value

        public void GetAndSet_sets_new_value()
        {
            var obj = new AtomicReference<object>();
            var value = new object();

            obj.GetAndSet(value);

            Assert.AreEqual(value, obj.Value);
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:9,代码来源:AtomicReferenceTests.cs

示例6: GetAndSet_returns_old_value

        public void GetAndSet_returns_old_value()
        {
            var value = new object();
            var obj = new AtomicReference<object>(value);

            var actual = obj.GetAndSet(new object());

            Assert.AreEqual(value, actual);
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:9,代码来源:AtomicReferenceTests.cs

示例7: Constructor_when_given_a_value_instantiates_with_it

        public void Constructor_when_given_a_value_instantiates_with_it()
        {
            var value = new object();
            var obj = new AtomicReference<object>(value);

            var actual = obj.Value;

            Assert.AreEqual(value, actual);
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:9,代码来源:AtomicReferenceTests.cs

示例8: ObjectDirectory

 /// <summary>
 /// Initialize a reference to an on-disk object directory.
 /// </summary>
 /// <param name="dir">the location of the <code>objects</code> directory.</param>
 /// <param name="alternateObjectDir">a list of alternate object directories</param>
 public ObjectDirectory(DirectoryInfo dir, DirectoryInfo[] alternateObjectDir)
 {
     _objects = dir;
     _alternateObjectDir = alternateObjectDir;
     _infoDirectory = new DirectoryInfo(_objects.FullName + "/info");
     _packDirectory = new DirectoryInfo(_objects.FullName + "/pack");
     _alternatesFile = new FileInfo(_infoDirectory + "/alternates");
     _packList = new AtomicReference<PackList>(NoPacks);
 }
开发者ID:dev218,项目名称:GitSharp,代码行数:14,代码来源:ObjectDirectory.cs

示例9: CompareAndSet_when_not_equal_does_not_set_value

        public void CompareAndSet_when_not_equal_does_not_set_value()
        {
            var initial = new object();
            var obj = new AtomicReference<object>(initial);

            obj.CompareAndSet(new object(), new object());

            Assert.AreEqual(initial, obj.Value);
        }
开发者ID:ondfisk,项目名称:C5.Concurrent,代码行数:9,代码来源:AtomicReferenceTests.cs

示例10: EnsurePath

 protected EnsurePath(String path, 
                         AtomicReference<Helper> helper, 
                         bool makeLastNode, 
                         IInternalACLProvider aclProvider)
 {
     this.path = path;
     this.makeLastNode = makeLastNode;
     this.aclProvider = aclProvider;
     this.helper = helper ?? new AtomicReference<Helper>(new InitialHelper(this));
 }
开发者ID:Lagrang,项目名称:CuratorNet,代码行数:10,代码来源:EnsurePath.cs

示例11: AtomicReference_Implicit_Reassignment_Should_Change_Reference

        public void AtomicReference_Implicit_Reassignment_Should_Change_Reference()
        {
            var firstAtomic = new AtomicReference<object>(new object());
            var secondAtomic = firstAtomic;

            firstAtomic = false;

            Assert.NotEqual(secondAtomic, firstAtomic);
            Assert.False(object.ReferenceEquals(secondAtomic, firstAtomic));
        }
开发者ID:szKarlen,项目名称:atomics.net,代码行数:10,代码来源:AtomicReferenceEqualityTests.cs

示例12: AtomicReference_Implicit_Ref_AcqRel_Should_Success

        public void AtomicReference_Implicit_Ref_AcqRel_Should_Success()
        {
            var source = new object();
            var atomicReference = new AtomicReference<object>(source);

            var func = new Func<object, object>(i => i);

            Assert.NotEqual(source, func(atomicReference));
            Assert.Equal(source, func(atomicReference.Value));
        }
开发者ID:szKarlen,项目名称:atomics.net,代码行数:10,代码来源:AtomicReferenceEqualityTests.cs

示例13: ShouldExchangeAndReturnOldValue

    public void ShouldExchangeAndReturnOldValue() {
      ReferenceMock reference = Reference;

      AtomicReference<ReferenceMock> ar =
        new AtomicReference<ReferenceMock>(reference);

      ReferenceMock new_mock = new ReferenceMock("new_mock");
      ReferenceMock old_mock = ar.Exchange(new_mock);
      Assert.AreEqual(new_mock, ar.Value);
      Assert.AreEqual(reference, old_mock);
    }
开发者ID:joethinh,项目名称:nohros-must,代码行数:11,代码来源:AtomicReferenceTests.cs

示例14: ShouldNotUpdateWhenComparisonIsFalseAndReturnOldValue

    public void ShouldNotUpdateWhenComparisonIsFalseAndReturnOldValue() {
      ReferenceMock reference = Reference;

      AtomicReference<ReferenceMock> ar =
        new AtomicReference<ReferenceMock>(reference);

      ReferenceMock new_mock = new ReferenceMock("new-mock");
      ReferenceMock old_mock = ar.CompareExchange(new_mock, new_mock);
      Assert.AreEqual(reference, ar.Value);
      Assert.AreEqual(reference, old_mock);
    }
开发者ID:joethinh,项目名称:nohros-must,代码行数:11,代码来源:AtomicReferenceTests.cs

示例15: AtomicReference_Should_Implement_Reference_Equality

        public void AtomicReference_Should_Implement_Reference_Equality()
        {
            var firstAtomic = new AtomicReference<object>(new object());
            var secondAtomic = new AtomicReference<object>(null);

            Assert.False(firstAtomic.Equals(secondAtomic));
            Assert.False(secondAtomic.Equals(firstAtomic));

            // self equality
            Assert.True(firstAtomic.Equals(firstAtomic));
            Assert.True(secondAtomic.Equals(secondAtomic));
        }
开发者ID:szKarlen,项目名称:atomics.net,代码行数:12,代码来源:AtomicReferenceEqualityTests.cs


注:本文中的AtomicReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。