use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.
the class DisruptorUtil method createDisruptor.
/**
* create a disruptor
*
* @param name The title of the disruptor
* @param ringBufferSize The size of ringBuffer
*/
public void createDisruptor(String name, int ringBufferSize) {
if (DISRUPTOR_MAP.keySet().contains(name)) {
throw new NulsRuntimeException(ErrorCode.FAILED, "create disruptor faild,the name is repetitive!");
}
Disruptor<DisruptorEvent> disruptor = new Disruptor<DisruptorEvent>(EVENT_FACTORY, ringBufferSize, new NulsThreadFactory(ModuleService.getInstance().getModuleId(EventBusModuleBootstrap.class), name), ProducerType.SINGLE, new BlockingWaitStrategy());
// SleepingWaitStrategy
// disruptor.handleEventsWith(new EventHandler<DisruptorEvent>() {
// @Override
// public void onEvent(DisruptorEvent disruptorEvent, long l, boolean b) throws Exception {
// Log.debug(disruptorEvent.getData() + "");
// }
// });
DISRUPTOR_MAP.put(name, disruptor);
}
use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.
the class ProcessorManager method init.
public final void init() {
pool = TaskManager.createThreadPool(EventBusConstant.THREAD_COUNT, 0, new NulsThreadFactory(NulsConstant.MODULE_ID_EVENT_BUS, EventBusConstant.THREAD_POOL_NAME));
disruptorService.createDisruptor(disruptorName, EventBusConstant.DEFAULT_RING_BUFFER_SIZE);
List<EventDispatchThread> handlerList = new ArrayList<>();
for (int i = 0; i < EventBusConstant.THREAD_COUNT; i++) {
EventDispatchThread handler = new EventDispatchThread(this);
handlerList.add(handler);
}
disruptorService.handleEventsWithWorkerPool(disruptorName, handlerList.toArray(new EventDispatchThread[handlerList.size()]));
disruptorService.start(disruptorName);
}
use of io.nuls.core.thread.manager.NulsThreadFactory in project nuls by nuls-io.
the class QueueManager method start.
public static void start() {
ScheduledExecutorService service = TaskManager.createScheduledThreadPool(new NulsThreadFactory(NulsConstant.MODULE_ID_MICROKERNEL, "queueStatusLogPool"));
service.scheduleAtFixedRate(new StatusLogThread(), 0, QueueManager.getLatelySecond(), TimeUnit.SECONDS);
Running = true;
}
Aggregations