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 @NotNull CpuLayout |
cpuLayout() |
static void |
cpuLayout(@NotNull CpuLayout cpuLayout)
Set the CPU layout for this machine.
|
static @NotNull 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, toString
public 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 @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 @NotNull CpuLayout cpuLayout()
@NotNull public static @NotNull String dumpLocks()
public void bind(boolean wholeCore)
AffinityLock
bind
in class AffinityLock
wholeCore
- if true, also reserve the whole core.public void release()
AffinityLock
release
in class AffinityLock
public void started(Thread t)
ThreadLifecycleListener
started
in interface ThreadLifecycleListener
t
- the thread which is being startedpublic void startFailed(Thread t)
ThreadLifecycleListener
startFailed
in interface ThreadLifecycleListener
t
- the thread that had a failed startpublic void terminated(Thread t)
ThreadLifecycleListener
terminated
in interface ThreadLifecycleListener
t
- the thread that has been terminatedCopyright © 2016. All rights reserved.