Debian Codegraph @

external/rx/Rx/NET/Source/System.Reactive.Core/Reactive/Concurrency/DisableOptimizationsScheduler.cs

raw
1 // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
2
3 using System;
4 using System.Linq;
5
6 #if !NO_WEAKTABLE
7 using System.Runtime.CompilerServices;
8 #endif
9
10 namespace System.Reactive.Concurrency
11 {
12 class DisableOptimizationsScheduler : SchedulerWrapper
13 {
14 private readonly Type[] _optimizationInterfaces;
15
16 public DisableOptimizationsScheduler(IScheduler scheduler)
17 : base(scheduler)
18 {
19 _optimizationInterfaces = Scheduler.OPTIMIZATIONS;
20 }
21
22 public DisableOptimizationsScheduler(IScheduler scheduler, Type[] optimizationInterfaces)
23 : base(scheduler)
24 {
25 _optimizationInterfaces = optimizationInterfaces;
26 }
27
28 #if !NO_WEAKTABLE
29 public DisableOptimizationsScheduler(IScheduler scheduler, Type[] optimizationInterfaces, ConditionalWeakTable<IScheduler, IScheduler> cache)
30 : base(scheduler, cache)
31 {
32 _optimizationInterfaces = optimizationInterfaces;
33 }
34
35 protected override SchedulerWrapper Clone(IScheduler scheduler, ConditionalWeakTable<IScheduler, IScheduler> cache)
36 {
37 return new DisableOptimizationsScheduler(scheduler, _optimizationInterfaces, cache);
38 }
39 #else
40 protected override SchedulerWrapper Clone(IScheduler scheduler)
41 {
42 return new DisableOptimizationsScheduler(scheduler, _optimizationInterfaces);
43 }
44 #endif
45
46 protected override bool TryGetService(IServiceProvider provider, Type serviceType, out object service)
47 {
48 service = null;
49 return _optimizationInterfaces.Contains(serviceType);
50 }
51 }
52 }