Пример #1
0
 /// <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
        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();
                }
            }
        }
 public TrackingWorkspaceStateProvider(WorkspaceExclusiveLockProvider workspaceExclusiveLockProvider)
 {
     this.workspaceExclusiveLockProvider = workspaceExclusiveLockProvider;
 }
 public TrackingWorkspaceStateProvider(WorkspaceExclusiveLockProvider workspaceExclusiveLockProvider)
 {
     this.workspaceExclusiveLockProvider = workspaceExclusiveLockProvider;
 }