Package net.sf.eBus.config
Class ThreadAffinity
- java.lang.Object
-
- net.sf.eBus.config.ThreadAffinity
-
public final class ThreadAffinity extends Object
Provides interface to OpenHFT Thread Affinity Library based on a givenThreadAffinityConfigure. The idea is that by binding a thread to a core thread performance is improved. But this improvement can only be realized if the core is isolated from operating system use. Otherwise the thread still faces losing its core to the OS, having to wait to gain the core again with its cache wrecked by the OS thread.Please see
ThreadAffinityConfigurefor a detailed discussion on how to configure thread affinity.This class is designed for use with
net.sf.eBus.net.SelectorThreadandnet.sf.eBus.net.client.EClient.RQThreadboth of which may be bound to a core. This would normally be done when the thread is configured as spinning.- Author:
- Charles W. Rapp
- See Also:
ThreadAffinityConfigure
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static net.openhft.affinity.AffinityLockacquireLock(net.openhft.affinity.AffinityLock lock, ThreadAffinityConfigure config)Returns an OpenHFT thread affinity lock based on an existing lock and CPU strategy configuration.static net.openhft.affinity.AffinityLockacquireLock(ThreadAffinityConfigure config)Returns an OpenHFT thread affinity lock.
-
-
-
Method Detail
-
acquireLock
public static net.openhft.affinity.AffinityLock acquireLock(ThreadAffinityConfigure config)
Returns an OpenHFT thread affinity lock.- Parameters:
config-- Returns:
- thread affinity lock. This lock should be
releasedwhen the thread stops. - Throws:
IllegalStateException- ifconfig.affinityTypeisAffinityType.CPU_STRATEGIESwhich requires an existingAffinityLockto work.- See Also:
acquireLock(AffinityLock, ThreadAffinityConfigure)
-
acquireLock
public static net.openhft.affinity.AffinityLock acquireLock(net.openhft.affinity.AffinityLock lock, ThreadAffinityConfigure config)Returns an OpenHFT thread affinity lock based on an existing lock and CPU strategy configuration. The idea is OpenHFT will select a CPU based on the existing lock's CPU and the CPU selection strategies. Please not that the final strategy isAffinityStrategies.ANYallowing any CPU to be chosen if no available CPU matches the previous strategies.- Parameters:
lock- existing affinity lock.config- CPU selection strategy.- Returns:
- thread affinity lock. This lock should be
releasedwhen the thread stops. - Throws:
NullPointerException- iflockorconfigisnull.IllegalArgumentException- ifconfigaffinity type is notAffinityType.CPU_STRATEGIES.- See Also:
acquireLock(ThreadAffinityConfigure)
-
-