Skip to content

Commit 40104ef

Browse files
committed
peter-lawrey#19 Test to handle when no more locks available (which have an id of -1)
1 parent 3e7aef9 commit 40104ef

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/test/java/vanilla/java/affinity/AffinityLockTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import vanilla.java.affinity.impl.VanillaCpuLayout;
2121

2222
import java.io.IOException;
23+
import java.util.ArrayList;
24+
import java.util.List;
2325

2426
import static org.junit.Assert.assertEquals;
2527
import static org.junit.Assert.assertNotSame;
@@ -142,4 +144,19 @@ public void testIssue21() {
142144
alForAnotherThread2.release();
143145
}
144146

147+
@Test
148+
public void testIssue19() {
149+
AffinityLock al = AffinityLock.acquireLock();
150+
List<AffinityLock> locks = new ArrayList<AffinityLock>();
151+
locks.add(al);
152+
for (int i = 0; i < 256; i++)
153+
locks.add(al = al.acquireLock(AffinityStrategies.DIFFERENT_SOCKET,
154+
AffinityStrategies.DIFFERENT_CORE,
155+
AffinityStrategies.SAME_SOCKET,
156+
AffinityStrategies.ANY));
157+
for (AffinityLock lock : locks) {
158+
lock.release();
159+
}
160+
}
161+
145162
}

0 commit comments

Comments
 (0)