aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/SmartThreadPool/WIGStartInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ThirdParty/SmartThreadPool/WIGStartInfo.cs270
1 files changed, 171 insertions, 99 deletions
diff --git a/ThirdParty/SmartThreadPool/WIGStartInfo.cs b/ThirdParty/SmartThreadPool/WIGStartInfo.cs
index 150317f..e5ff150 100644
--- a/ThirdParty/SmartThreadPool/WIGStartInfo.cs
+++ b/ThirdParty/SmartThreadPool/WIGStartInfo.cs
@@ -1,99 +1,171 @@
1// Ami Bar 1using System;
2// amibar@gmail.com 2
3 3namespace Amib.Threading
4namespace Amib.Threading 4{
5{ 5 /// <summary>
6 /// <summary> 6 /// Summary description for WIGStartInfo.
7 /// Summary description for WIGStartInfo. 7 /// </summary>
8 /// </summary> 8 public class WIGStartInfo
9 public class WIGStartInfo 9 {
10 { 10 private bool _useCallerCallContext;
11 /// <summary> 11 private bool _useCallerHttpContext;
12 /// Use the caller's security context 12 private bool _disposeOfStateObjects;
13 /// </summary> 13 private CallToPostExecute _callToPostExecute;
14 private bool _useCallerCallContext; 14 private PostExecuteWorkItemCallback _postExecuteWorkItemCallback;
15 15 private bool _startSuspended;
16 /// <summary> 16 private WorkItemPriority _workItemPriority;
17 /// Use the caller's HTTP context 17 private bool _fillStateWithArgs;
18 /// </summary> 18
19 private bool _useCallerHttpContext; 19 protected bool _readOnly;
20 20
21 /// <summary> 21 public WIGStartInfo()
22 /// Dispose of the state object of a work item 22 {
23 /// </summary> 23 _fillStateWithArgs = SmartThreadPool.DefaultFillStateWithArgs;
24 private bool _disposeOfStateObjects; 24 _workItemPriority = SmartThreadPool.DefaultWorkItemPriority;
25 25 _startSuspended = SmartThreadPool.DefaultStartSuspended;
26 /// <summary> 26 _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback;
27 /// The option to run the post execute 27 _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute;
28 /// </summary> 28 _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects;
29 private CallToPostExecute _callToPostExecute; 29 _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext;
30 30 _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext;
31 /// <summary> 31 }
32 /// A post execute callback to call when none is provided in 32
33 /// the QueueWorkItem method. 33 public WIGStartInfo(WIGStartInfo wigStartInfo)
34 /// </summary> 34 {
35 private PostExecuteWorkItemCallback _postExecuteWorkItemCallback; 35 _useCallerCallContext = wigStartInfo.UseCallerCallContext;
36 36 _useCallerHttpContext = wigStartInfo.UseCallerHttpContext;
37 /// <summary> 37 _disposeOfStateObjects = wigStartInfo.DisposeOfStateObjects;
38 /// Indicate the WorkItemsGroup to suspend the handling of the work items 38 _callToPostExecute = wigStartInfo.CallToPostExecute;
39 /// until the Start() method is called. 39 _postExecuteWorkItemCallback = wigStartInfo.PostExecuteWorkItemCallback;
40 /// </summary> 40 _workItemPriority = wigStartInfo.WorkItemPriority;
41 private bool _startSuspended; 41 _startSuspended = wigStartInfo.StartSuspended;
42 42 _fillStateWithArgs = wigStartInfo.FillStateWithArgs;
43 public WIGStartInfo() 43 }
44 { 44
45 _useCallerCallContext = SmartThreadPool.DefaultUseCallerCallContext; 45 protected void ThrowIfReadOnly()
46 _useCallerHttpContext = SmartThreadPool.DefaultUseCallerHttpContext; 46 {
47 _disposeOfStateObjects = SmartThreadPool.DefaultDisposeOfStateObjects; 47 if (_readOnly)
48 _callToPostExecute = SmartThreadPool.DefaultCallToPostExecute; 48 {
49 _postExecuteWorkItemCallback = SmartThreadPool.DefaultPostExecuteWorkItemCallback; 49 throw new NotSupportedException("This is a readonly instance and set is not supported");
50 _startSuspended = SmartThreadPool.DefaultStartSuspended; 50 }
51 } 51 }
52 52
53 public WIGStartInfo(WIGStartInfo wigStartInfo) 53 /// <summary>
54 { 54 /// Get/Set if to use the caller's security context
55 _useCallerCallContext = wigStartInfo._useCallerCallContext; 55 /// </summary>
56 _useCallerHttpContext = wigStartInfo._useCallerHttpContext; 56 public virtual bool UseCallerCallContext
57 _disposeOfStateObjects = wigStartInfo._disposeOfStateObjects; 57 {
58 _callToPostExecute = wigStartInfo._callToPostExecute; 58 get { return _useCallerCallContext; }
59 _postExecuteWorkItemCallback = wigStartInfo._postExecuteWorkItemCallback; 59 set
60 _startSuspended = wigStartInfo._startSuspended; 60 {
61 } 61 ThrowIfReadOnly();
62 62 _useCallerCallContext = value;
63 public bool UseCallerCallContext 63 }
64 { 64 }
65 get { return _useCallerCallContext; } 65
66 set { _useCallerCallContext = value; } 66
67 } 67 /// <summary>
68 68 /// Get/Set if to use the caller's HTTP context
69 public bool UseCallerHttpContext 69 /// </summary>
70 { 70 public virtual bool UseCallerHttpContext
71 get { return _useCallerHttpContext; } 71 {
72 set { _useCallerHttpContext = value; } 72 get { return _useCallerHttpContext; }
73 } 73 set
74 74 {
75 public bool DisposeOfStateObjects 75 ThrowIfReadOnly();
76 { 76 _useCallerHttpContext = value;
77 get { return _disposeOfStateObjects; } 77 }
78 set { _disposeOfStateObjects = value; } 78 }
79 } 79
80 80
81 public CallToPostExecute CallToPostExecute 81 /// <summary>
82 { 82 /// Get/Set if to dispose of the state object of a work item
83 get { return _callToPostExecute; } 83 /// </summary>
84 set { _callToPostExecute = value; } 84 public virtual bool DisposeOfStateObjects
85 } 85 {
86 86 get { return _disposeOfStateObjects; }
87 public PostExecuteWorkItemCallback PostExecuteWorkItemCallback 87 set
88 { 88 {
89 get { return _postExecuteWorkItemCallback; } 89 ThrowIfReadOnly();
90 set { _postExecuteWorkItemCallback = value; } 90 _disposeOfStateObjects = value;
91 } 91 }
92 92 }
93 public bool StartSuspended 93
94 { 94
95 get { return _startSuspended; } 95 /// <summary>
96 set { _startSuspended = value; } 96 /// Get/Set the run the post execute options
97 } 97 /// </summary>
98 } 98 public virtual CallToPostExecute CallToPostExecute
99} 99 {
100 get { return _callToPostExecute; }
101 set
102 {
103 ThrowIfReadOnly();
104 _callToPostExecute = value;
105 }
106 }
107
108
109 /// <summary>
110 /// Get/Set the default post execute callback
111 /// </summary>
112 public virtual PostExecuteWorkItemCallback PostExecuteWorkItemCallback
113 {
114 get { return _postExecuteWorkItemCallback; }
115 set
116 {
117 ThrowIfReadOnly();
118 _postExecuteWorkItemCallback = value;
119 }
120 }
121
122
123 /// <summary>
124 /// Get/Set if the work items execution should be suspended until the Start()
125 /// method is called.
126 /// </summary>
127 public virtual bool StartSuspended
128 {
129 get { return _startSuspended; }
130 set
131 {
132 ThrowIfReadOnly();
133 _startSuspended = value;
134 }
135 }
136
137
138 /// <summary>
139 /// Get/Set the default priority that a work item gets when it is enqueued
140 /// </summary>
141 public virtual WorkItemPriority WorkItemPriority
142 {
143 get { return _workItemPriority; }
144 set { _workItemPriority = value; }
145 }
146
147 /// <summary>
148 /// Get/Set the if QueueWorkItem of Action&lt;...&gt;/Func&lt;...&gt; fill the
149 /// arguments as an object array into the state of the work item.
150 /// The arguments can be access later by IWorkItemResult.State.
151 /// </summary>
152 public virtual bool FillStateWithArgs
153 {
154 get { return _fillStateWithArgs; }
155 set
156 {
157 ThrowIfReadOnly();
158 _fillStateWithArgs = value;
159 }
160 }
161
162 /// <summary>
163 /// Get a readonly version of this WIGStartInfo
164 /// </summary>
165 /// <returns>Returns a readonly reference to this WIGStartInfoRO</returns>
166 public WIGStartInfo AsReadOnly()
167 {
168 return new WIGStartInfo(this) { _readOnly = true };
169 }
170 }
171}