Skip to content

Commit 5dcbd82

Browse files
PeterPeter
authored andcommitted
Version 1.5.3 - Build on Windows cleanly and added Unix profile.
1 parent e44ae9d commit 5dcbd82

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/main/java/vanilla/java/affinity/AffinityLock.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ public void bind(boolean wholeCore) {
278278
if (LOGGER.isLoggable(Level.INFO))
279279
LOGGER.info("Assigning cpu " + id + " to " + assignedThread);
280280
}
281-
AffinitySupport.setAffinity(1L << id);
281+
if (id >= 0)
282+
AffinitySupport.setAffinity(1L << id);
282283
}
283284

284285
private boolean canReserve() {

src/main/java/vanilla/java/affinity/impl/WindowsJNAAffinity.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.logging.Logger;
2929

3030
/**
31-
* Implementation of {@link IAffinity} based on JNA call of
31+
* Implementation of {@link vanilla.java.affinity.IAffinity} based on JNA call of
3232
* sched_SetThreadAffinityMask/GetProcessAffinityMask from Windows 'kernel32' library. Applicable for
3333
* most windows platforms
3434
* <p/> *
@@ -87,14 +87,12 @@ public long getAffinity() {
8787
@Override
8888
public void setAffinity(final long affinity) {
8989
final CLibrary lib = CLibrary.INSTANCE;
90-
try {
91-
92-
WinDef.DWORD aff = new WinDef.DWORD(affinity);
9390

91+
WinDef.DWORD aff = new WinDef.DWORD(affinity);
92+
try {
9493
lib.SetThreadAffinityMask(lib.GetCurrentThread(), aff);
9594

9695
} catch (LastErrorException e) {
97-
e.printStackTrace();
9896
throw new IllegalStateException("sched_getaffinity((" + Long.SIZE / 8 + ") , &(" + affinity + ") ) errorNo=" + e.getErrorCode(), e);
9997
}
10098
}

0 commit comments

Comments
 (0)