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


C# ReaderWriterLock.ReleaseReaderLock方法代码示例

本文整理汇总了C#中System.Threading.ReaderWriterLock.ReleaseReaderLock方法的典型用法代码示例。如果您正苦于以下问题:C# ReaderWriterLock.ReleaseReaderLock方法的具体用法?C# ReaderWriterLock.ReleaseReaderLock怎么用?C# ReaderWriterLock.ReleaseReaderLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.ReaderWriterLock的用法示例。


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

示例1: TestIsReaderLockHeld

		public void TestIsReaderLockHeld ()
		{
			rwlock = new ReaderWriterLock ();
			Assert ("a1", !rwlock.IsReaderLockHeld);
			rwlock.AcquireReaderLock (500);
			Assert ("a2", rwlock.IsReaderLockHeld);
			RunThread (new ThreadStart (IsReaderLockHeld_2));
			rwlock.ReleaseReaderLock ();
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:9,代码来源:ReaderWriterLockTest.cs

示例2: TestIsReaderLockHeld

		public void TestIsReaderLockHeld ()
		{
			rwlock = new ReaderWriterLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld, "#1");
			rwlock.AcquireReaderLock (500);
			Assert.IsTrue (rwlock.IsReaderLockHeld, "#1");
			RunThread (new ThreadStart (IsReaderLockHeld_2));
			rwlock.ReleaseReaderLock ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:9,代码来源:ReaderWriterLockTest.cs

示例3: DowngradeTest

		public void DowngradeTest ()
		{
			LockCookie lc1, lc2, lc3, lc4;

			rwlock = new ReaderWriterLock ();

			rwlock.AcquireReaderLock (Timeout.Infinite);
			lc1 = rwlock.UpgradeToWriterLock (Timeout.Infinite);
			rwlock.AcquireReaderLock (Timeout.Infinite);
			lc2 = rwlock.UpgradeToWriterLock (Timeout.Infinite);
			rwlock.AcquireReaderLock (Timeout.Infinite);
			lc3 = rwlock.UpgradeToWriterLock (Timeout.Infinite);
			rwlock.AcquireReaderLock (Timeout.Infinite);
			lc4 = rwlock.UpgradeToWriterLock (Timeout.Infinite);

			rwlock.DowngradeFromWriterLock (ref lc2);

			Assert.IsFalse (rwlock.IsReaderLockHeld, "A1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "A2");

			rwlock.ReleaseReaderLock ();

			Assert.IsFalse (rwlock.IsReaderLockHeld, "B1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "B2");

			rwlock.DowngradeFromWriterLock (ref lc4);

			Assert.IsFalse (rwlock.IsReaderLockHeld, "C1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "C2");

			rwlock.ReleaseReaderLock ();

			Assert.IsFalse (rwlock.IsReaderLockHeld, "D1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "D2");

			rwlock.DowngradeFromWriterLock (ref lc3);

			Assert.IsFalse (rwlock.IsReaderLockHeld, "E1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "E2");

			rwlock.ReleaseReaderLock ();

			Assert.IsFalse (rwlock.IsReaderLockHeld, "F1");
			Assert.IsTrue (rwlock.IsWriterLockHeld, "F2");

			rwlock.DowngradeFromWriterLock (ref lc1);

			Assert.IsTrue (rwlock.IsReaderLockHeld, "G1");
			Assert.IsFalse (rwlock.IsWriterLockHeld, "G2");

			rwlock.ReleaseReaderLock ();

			Assert.IsFalse (rwlock.IsReaderLockHeld, "H1");
			Assert.IsFalse (rwlock.IsWriterLockHeld, "H2");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:55,代码来源:ReaderWriterLockTest.cs

示例4: TestBug_55909

		public void TestBug_55909 ()
		{
			rwlock = new ReaderWriterLock ();
			ThreadRunner tr = StartThread (new ThreadStart(Bug_55909_Thread2));
			Thread.Sleep (200);
			rwlock.AcquireReaderLock (Timeout.Infinite);
			try {
				LockCookie lc = rwlock.UpgradeToWriterLock (Timeout.Infinite);
				Thread.Sleep (500);
			}
			finally { rwlock.ReleaseReaderLock(); }
			
			tr.Join ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:14,代码来源:ReaderWriterLockTest.cs

示例5: TestBug_55911

		public void TestBug_55911 ()
		{
			rwlock = new ReaderWriterLock ();
			
			rwlock.AcquireReaderLock (Timeout.Infinite);
			try {
				LockCookie lc = rwlock.UpgradeToWriterLock (Timeout.Infinite);
			}
			finally { rwlock.ReleaseReaderLock(); }
			
			rwlock.AcquireReaderLock (Timeout.Infinite);
			try {
				LockCookie lc = rwlock.UpgradeToWriterLock (Timeout.Infinite);
			}
			finally { rwlock.ReleaseReaderLock(); }
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:ReaderWriterLockTest.cs

示例6: TestReaderMustWaitWriter

		public void TestReaderMustWaitWriter ()
		{
			// A thread cannot get the reader lock if there are other threads
			// waiting for the writer lock.
			
			rwlock = new ReaderWriterLock ();
			rwlock.AcquireWriterLock (200);
			
			ThreadRunner tr = StartThread (new ThreadStart (ReaderMustWaitWriter_2));
			Thread.Sleep (200);
			
			RunThread (new ThreadStart (AcquireLock_readerFails));
			
			rwlock.ReleaseReaderLock ();
			tr.Join ();
		}
开发者ID:nlhepler,项目名称:mono,代码行数:16,代码来源:ReaderWriterLockTest.cs

示例7: TestReaderInsideWriter

		public void TestReaderInsideWriter ()
		{
			// Reader acquires and releases work like the writer equivalent
			
			rwlock = new ReaderWriterLock ();
			rwlock.AcquireWriterLock (-1);
			rwlock.AcquireReaderLock (-1);
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (rwlock.IsWriterLockHeld);
			rwlock.AcquireReaderLock (-1);
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (rwlock.IsWriterLockHeld);
			rwlock.ReleaseWriterLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (rwlock.IsWriterLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (rwlock.IsWriterLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (!rwlock.IsWriterLockHeld);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:22,代码来源:ReaderWriterLockTest.cs

示例8: TestUpgradeDowngradeLock

		public void TestUpgradeDowngradeLock ()
		{
			rwlock = new ReaderWriterLock ();
			rwlock.AcquireReaderLock (200);
			rwlock.AcquireReaderLock (200);
			
			LockCookie co = rwlock.UpgradeToWriterLock (200);
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
			Assert.IsTrue (rwlock.IsWriterLockHeld);
			RunThread (new ThreadStart (AcquireLock_writerFails));
			
			rwlock.DowngradeFromWriterLock (ref co);
			Assert.IsTrue (rwlock.IsReaderLockHeld);
			Assert.IsTrue (!rwlock.IsWriterLockHeld);
			RunThread (new ThreadStart (AcquireLock_readerWorks));
			
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (rwlock.IsReaderLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:21,代码来源:ReaderWriterLockTest.cs

示例9: GetWebDomainData

 //- @GetWebDomainData -//
 /// <summary>
 /// Returns the WebDomainData object for a particular web domain. 
 /// </summary>
 /// <param name="webDomainName">The web domain name used to lookup the web domain.</param>
 /// <returns>A WebDomainData object or null if the web domain name is invalid.</returns>
 public static WebDomainData GetWebDomainData(String webDomainName)
 {
     var readerWriterLock = new ReaderWriterLock();
     readerWriterLock.AcquireReaderLock(Timeout.Infinite);
     try
     {
         if (String.IsNullOrEmpty(webDomainName))
         {
             webDomainName = "root";
         }
         //+
         return WebDomainDataList.AllWebDomainData.SingleOrDefault(p => p.Name == webDomainName);
     }
     finally
     {
         readerWriterLock.ReleaseReaderLock();
     }
 }
开发者ID:davidbetz,项目名称:themelia,代码行数:24,代码来源:WebDomainOld.cs

示例10: FindFirstMatch

        internal virtual RewriteRule FindFirstMatch(HttpApplication app, out string requestUrl, RewriteRuleCollection rules, ReaderWriterLock ruleCollectionLock)
        {
            requestUrl = null;
            RewriteRule matchedRule = null;
            ruleCollectionLock.AcquireReaderLock(0);
            try
            {
                foreach (var rule in rules)
                {
                    if ((rule.Rewrite & RewriteOption.Domain) != 0)
                        requestUrl = app.Request.Url.AbsoluteUri;
                    else
                        requestUrl = app.Request.RawUrl;

                    if (rule.IsRewrite(requestUrl))
                    {
                        matchedRule = rule;
                        break;
                    }
                }
            }
            finally
            {
                ruleCollectionLock.ReleaseReaderLock();
            }
            return matchedRule;
        }
开发者ID:modulexcite,项目名称:UrlRewritingNet-1,代码行数:27,代码来源:UrlRewriteModule.cs

示例11: AcquireReaderLock

 public static IDisposable AcquireReaderLock(ReaderWriterLock rwl)
 {
     rwl.AcquireReaderLock(Timeout.Infinite);
     return new Disposer(() => rwl.ReleaseReaderLock());
 }
开发者ID:Zoumaho,项目名称:Backload,代码行数:5,代码来源:StreamWriterCache.cs

示例12: ReaderWriter_WhenUpgradedWriteLockReleased_EdgesDeleteFromGraph

        public void ReaderWriter_WhenUpgradedWriteLockReleased_EdgesDeleteFromGraph()
        {
            ReaderWriterLock rwl = new ReaderWriterLock();
            Barrier barrier = new Barrier(3);
            Barrier barrier2 = new Barrier(3);


            Task t1 = new Task(() =>
                                    {
                                        rwl.AcquireReaderLock(Timeout.Infinite);
                                        rwl.UpgradeToWriterLock(Timeout.Infinite);
                                        rwl.ReleaseWriterLock();
                                        barrier.SignalAndWait();
                                        barrier2.SignalAndWait();
                                        lock (rwl)
                                        {
                                            Thread.Sleep(100);
                                        }
                                    });

            Task t2 = new Task(() =>
                                    {
                                        barrier.SignalAndWait();
                                        lock (rwl)
                                        {
                                            barrier2.SignalAndWait();
                                            rwl.AcquireWriterLock(Timeout.Infinite);
                                        }
                                    });

            t1.Start();
            t2.Start();

            barrier.SignalAndWait();
            rwl.AcquireReaderLock(Timeout.Infinite);
            barrier2.SignalAndWait();
            Thread.Sleep(500);
            rwl.ReleaseReaderLock();

            Task.WaitAll(new[] { t1, t2 });
        }
开发者ID:olachan,项目名称:PostSharp-Toolkits,代码行数:41,代码来源:DetectDeadlocksTests.cs

示例13: ReaderWriter_When2CycleDetected_DoesNotThrows

        public void ReaderWriter_When2CycleDetected_DoesNotThrows()
        {
            ReaderWriterLock rwl = new ReaderWriterLock();
            Barrier barrier = new Barrier(2);

            Action t1 = () =>
                            {
                                rwl.AcquireReaderLock(Timeout.Infinite);
                                barrier.SignalAndWait();
                                rwl.UpgradeToWriterLock(Timeout.Infinite);
                                rwl.ReleaseWriterLock();
                            };

            Action t2 = () =>
                            {
                                rwl.AcquireReaderLock(Timeout.Infinite);
                                barrier.SignalAndWait();
                                Thread.Sleep(500);
                                rwl.ReleaseReaderLock();
                            };

            TestHelpers.InvokeSimultaneouslyAndWait(t1, t2);
        }
开发者ID:olachan,项目名称:PostSharp-Toolkits,代码行数:23,代码来源:DetectDeadlocksTests.cs

示例14: TestReaderInsideWriter

		public void TestReaderInsideWriter ()
		{
			// Reader acquires and releases work like the writer equivalent
			
			rwlock = new ReaderWriterLock ();
			rwlock.AcquireWriterLock (-1);
			rwlock.AcquireReaderLock (-1);
			Assert ("u1", !rwlock.IsReaderLockHeld);
			Assert ("u2", rwlock.IsWriterLockHeld);
			rwlock.AcquireReaderLock (-1);
			Assert ("u3", !rwlock.IsReaderLockHeld);
			Assert ("u4", rwlock.IsWriterLockHeld);
			rwlock.ReleaseWriterLock ();
			Assert ("u5", !rwlock.IsReaderLockHeld);
			Assert ("u6", rwlock.IsWriterLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert ("u7", !rwlock.IsReaderLockHeld);
			Assert ("u8", rwlock.IsWriterLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert ("u9", !rwlock.IsReaderLockHeld);
			Assert ("u10", !rwlock.IsWriterLockHeld);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:22,代码来源:ReaderWriterLockTest.cs

示例15: TestReleaseRestoreReaderLock

		public void TestReleaseRestoreReaderLock ()
		{
			rwlock = new ReaderWriterLock ();
			rwlock.AcquireReaderLock (500);
			rwlock.AcquireReaderLock (500);
			Assert.IsTrue (rwlock.IsReaderLockHeld);
			
			LockCookie co = rwlock.ReleaseLock ();
			RunThread (new ThreadStart (AcquireLock_writerWorks));
			
			rwlock.RestoreLock (ref co);
			RunThread (new ThreadStart (AcquireLock_writerFails));
			
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (rwlock.IsReaderLockHeld);
			rwlock.ReleaseReaderLock ();
			Assert.IsTrue (!rwlock.IsReaderLockHeld);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:18,代码来源:ReaderWriterLockTest.cs


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