コード例 #1
0
ファイル: WorkspaceFacade.cs プロジェクト: nemanjazz/iog
 /// <summary>
 /// Creates new instance of WorkspaceFacade type
 /// </summary>
 /// <param name="commitDataService">Commit data service</param>
 /// <param name="workspaceStateProvider">Workspace state tracker</param>
 public WorkspaceFacade(CommitDataService commitDataService, TrackingWorkspaceStateProvider workspaceStateProvider, ISubscriptionManagerService subscriptionManagerService, SnapshotsService snapshotsService, WorkspaceExclusiveLockProvider workspaceExclusiveLockProvider)
 {
     this.commitDataService = commitDataService;
     this.workspaceStateProvider = workspaceStateProvider;
     this.subscriptionManagerService = subscriptionManagerService;
     this.snapshotsService = snapshotsService;
     this.workspaceExclusiveLockProvider = workspaceExclusiveLockProvider;
 }
コード例 #2
0
ファイル: ExclusiveLockTest.cs プロジェクト: nemanjazz/iog
        public void TestMethod1()
        {
            int nrThreads = 33;
            int nrRepeats = 300;
            int counter = 0;

            for (int j = 0; j < nrRepeats; j++)
            {
                WorkspaceExclusiveLockProvider provider = new WorkspaceExclusiveLockProvider();
                Collection<Thread> threads = new Collection<Thread>();

                for (int i = 0; i < nrThreads; i++)
                {
                    Thread t = new Thread(() =>
                    {
                        provider.EnterLockExclusive();
                        Interlocked.Increment(ref counter);

                        Assert.AreEqual(1, counter);

                        Interlocked.Decrement(ref counter);

                        provider.ExitLockExclusive();
                    });

                    threads.Add(t);
                }

                foreach (var t in threads)
                {
                    t.Start();
                }

                foreach (var t in threads)
                {
                    t.Join();
                }
            }
        }
コード例 #3
0
 public TrackingWorkspaceStateProvider(WorkspaceExclusiveLockProvider workspaceExclusiveLockProvider)
 {
     this.workspaceExclusiveLockProvider = workspaceExclusiveLockProvider;
 }
コード例 #4
0
 public TrackingWorkspaceStateProvider(WorkspaceExclusiveLockProvider workspaceExclusiveLockProvider)
 {
     this.workspaceExclusiveLockProvider = workspaceExclusiveLockProvider;
 }