@@ -106,13 +106,15 @@ public void TestSubscriptionNack()
106
106
Assert . AreEqual ( 0 , ok . MessageCount ) ;
107
107
}
108
108
109
- private abstract class SubscriptionDrainer
109
+ private class SubscriptionDrainer
110
110
{
111
111
protected Subscription m_subscription ;
112
+ protected bool m_ack ;
112
113
113
- public SubscriptionDrainer ( Subscription sub )
114
+ public SubscriptionDrainer ( Subscription sub , bool ack )
114
115
{
115
116
m_subscription = sub ;
117
+ m_ack = ack ;
116
118
}
117
119
118
120
public void Drain ( )
@@ -140,26 +142,15 @@ public void Drain()
140
142
#pragma warning restore
141
143
}
142
144
143
- protected abstract void PostProcess ( ) ;
144
- }
145
-
146
- private class AckingDrainer : SubscriptionDrainer
147
- {
148
- public AckingDrainer ( Subscription sub ) : base ( sub ) { }
149
-
150
- override protected void PostProcess ( )
145
+ protected void PostProcess ( )
151
146
{
152
- m_subscription . Ack ( ) ;
153
- }
154
- }
155
-
156
- private class NackingDrainer : SubscriptionDrainer
157
- {
158
- public NackingDrainer ( Subscription sub ) : base ( sub ) { }
159
-
160
- override protected void PostProcess ( )
161
- {
162
- m_subscription . Nack ( false , false ) ;
147
+ if ( m_ack )
148
+ {
149
+ m_subscription . Ack ( ) ;
150
+ } else
151
+ {
152
+ m_subscription . Nack ( false , false ) ;
153
+ }
163
154
}
164
155
}
165
156
@@ -172,7 +163,7 @@ public void TestConcurrentIterationAndAck()
172
163
PreparedQueue ( q ) ;
173
164
for ( int i = 0 ; i < 10 ; i ++ )
174
165
{
175
- SubscriptionDrainer drainer = new AckingDrainer ( sub ) ;
166
+ SubscriptionDrainer drainer = new SubscriptionDrainer ( sub , true ) ;
176
167
Thread t = new Thread ( drainer . Drain ) ;
177
168
t . Start ( ) ;
178
169
}
@@ -187,7 +178,7 @@ public void TestConcurrentIterationAndNack()
187
178
PreparedQueue ( q ) ;
188
179
for ( int i = 0 ; i < 10 ; i ++ )
189
180
{
190
- SubscriptionDrainer drainer = new NackingDrainer ( sub ) ;
181
+ SubscriptionDrainer drainer = new SubscriptionDrainer ( sub , false ) ;
191
182
Thread t = new Thread ( drainer . Drain ) ;
192
183
t . Start ( ) ;
193
184
}
0 commit comments