Skip to content

Commit 8378b8a

Browse files
Reduce duplication
Two attempts to refactor further segfault .NET Core. Oh well.
1 parent 341c89c commit 8378b8a

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

projects/client/Unit/src/unit/TestConcurrentAccessWithSharedConnection.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,25 @@ namespace RabbitMQ.Client.Unit {
5151
[TestFixture]
5252
public class TestConcurrentAccessWithSharedConnection : IntegrationFixture {
5353

54+
protected const int threads = 32;
55+
protected CountdownEvent latch;
56+
57+
[SetUp]
58+
public void Init()
59+
{
60+
latch = new CountdownEvent(threads);
61+
}
62+
63+
[TearDown]
64+
public void Dispose()
65+
{
66+
latch.Dispose();
67+
}
68+
5469
[Test]
5570
public void TestConcurrentChannelOpenWithPublishing()
5671
{
57-
var n = 32;
58-
var latch = new CountdownEvent(n);
59-
foreach (var i in Enumerable.Range(0, n))
72+
foreach (var i in Enumerable.Range(0, threads))
6073
{
6174
var t = new Thread(() => {
6275
// publishing on a shared channel is not supported
@@ -77,12 +90,12 @@ public void TestConcurrentChannelOpenWithPublishing()
7790
Assert.IsTrue(latch.Wait(TimeSpan.FromSeconds(90)));
7891
}
7992

93+
// note: refactoring this further to use an Action causes .NET Core 1.x
94+
// to segfault on OS X for no obvious reason
8095
[Test]
8196
public void TestConcurrentChannelOpenCloseLoop()
8297
{
83-
var n = 32;
84-
var latch = new CountdownEvent(n);
85-
foreach (var i in Enumerable.Range(0, n))
98+
foreach (var i in Enumerable.Range(0, threads))
8699
{
87100
var t = new Thread(() => {
88101
foreach (var j in Enumerable.Range(0, 100))

0 commit comments

Comments
 (0)