public class NonForkingAffinityLock extends AffinityLock implements ThreadLifecycleListener
AFFINITY_RESERVED, BASE_AFFINITY, PROCESSORS, RESERVED_AFFINITY| Modifier and Type | Method and Description |
|---|---|
static AffinityLock |
acquireCore()
Assign any free core to this thread.
|
static AffinityLock |
acquireCore(boolean bind)
Assign a core(and all its cpus) which can be bound to the current thread or another thread.
|
static AffinityLock |
acquireLock()
Assign any free cpu to this thread.
|
static AffinityLock |
acquireLock(boolean bind)
Assign a cpu which can be bound to the current thread or another thread.
|
void |
bind(boolean wholeCore)
Bind the current thread to this reservable lock.
|
static CpuLayout |
cpuLayout() |
static void |
cpuLayout(CpuLayout cpuLayout)
Set the CPU layout for this machine.
|
static String |
dumpLocks() |
void |
release()
Release the current AffinityLock which can be discarded.
|
void |
started(Thread t)
The specified thread is about to be started.
|
void |
startFailed(Thread t)
The specified thread failed to start.
|
void |
terminated(Thread t)
The specified thread has been terminated.
|
acquireLock, bind, close, cpuId, finalize, isAllocated, isBound, main, toStringpublic static AffinityLock acquireLock()
public static AffinityLock acquireCore()
In reality, only one cpu is assigned, the rest of the threads for that core are reservable so they are not used.
public static AffinityLock acquireLock(boolean bind)
This can be used for defining your thread layout centrally and passing the handle via dependency injection.
bind - if true, bind the current thread, if false, reserve a cpu which can be bound later.public static AffinityLock acquireCore(boolean bind)
This can be used for defining your thread layout centrally and passing the handle via dependency injection.
bind - if true, bind the current thread, if false, reserve a cpu which can be bound later.public static void cpuLayout(@NotNull
CpuLayout cpuLayout)
Changing the layout will have no impact on thread which have already been assigned. It only affects subsequent assignments.
cpuLayout - for this application to use for this machine.@NotNull public static CpuLayout cpuLayout()
@NotNull public static String dumpLocks()
public void bind(boolean wholeCore)
AffinityLockbind in class AffinityLockwholeCore - if true, also reserve the whole core.public void release()
AffinityLockrelease in class AffinityLockpublic void started(Thread t)
ThreadLifecycleListenerstarted in interface ThreadLifecycleListenert - the thread which is being startedpublic void startFailed(Thread t)
ThreadLifecycleListenerstartFailed in interface ThreadLifecycleListenert - the thread that had a failed startpublic void terminated(Thread t)
ThreadLifecycleListenerterminated in interface ThreadLifecycleListenert - the thread that has been terminatedCopyright © 2016. All rights reserved.