本文整理汇总了Java中net.openhft.affinity.AffinitySupport类的典型用法代码示例。如果您正苦于以下问题:Java AffinitySupport类的具体用法?Java AffinitySupport怎么用?Java AffinitySupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AffinitySupport类属于net.openhft.affinity包,在下文中一共展示了AffinitySupport类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGettid
import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
@Test
public void testGettid() {
System.out.println("pid=" + getImpl().getProcessId());
System.out.println("tid=" + getImpl().getThreadId());
AffinitySupport.setThreadId();
for (int j = 0; j < 3; j++) {
final int runs = 100000;
long tid = 0;
long time = 0;
for (int i = 0; i < runs; i++) {
long start = System.nanoTime();
tid = Thread.currentThread().getId();
time += System.nanoTime() - start;
assertTrue(tid > 0);
assertTrue(tid < 1 << 16);
}
System.out.printf("gettid took an average of %,d ns, tid=%d%n", time / runs, tid);
}
}
示例2: setAffinity
import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
private static void setAffinity(final int cpuAffinity)
{
if(cpuAffinity != Config.NO_AFFINITY)
{
System.out.println("Setting journaller thread affinity to cpu: " + cpuAffinity);
final long cpuListBitMask = cpuListToBitMask(new int[]{cpuAffinity});
AffinitySupport.setAffinity(cpuListBitMask);
}
}
示例3: acquireCHM
import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
static ChronicleMap<String, BondVOInterface> acquireCHM() throws IOException {
// ensure thread ids are globally unique.
AffinitySupport.setThreadId();
return ChronicleMapBuilder.of(String.class, BondVOInterface.class)
.entries(16)
.averageKeySize("369604101".length()).create();
}
示例4: populate
import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
public static void populate(int n) {
AffinitySupport.setThreadId();
long start = System.currentTimeMillis();
BigDataStuff value = new BigDataStuff(0);
for (long i = n; i < MAXSIZE; i += 4) {
if (n == 0 && i % (10 * 1000 * 1000) == 0) {
System.out.println("Now inserted to " + i + " seconds since start = " + ((System.currentTimeMillis() - start) / 1000L));
}
value.x = i;
value.y.setLength(0);
value.y.append(i);
theMap.put(i, value);
}
}
示例5: _test
import net.openhft.affinity.AffinitySupport; //导入依赖的package包/类
public static void _test() {
// improves logging of these threads.
AffinitySupport.setThreadId();
try {
test();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}