private void assertKQueue(String message, boolean expected, Transport transport) throws Exception { Field group = null; Class<?> transportType = transport.getClass(); while (transportType != null && group == null) { try { group = transportType.getDeclaredField("group"); } catch (NoSuchFieldException error) { transportType = transportType.getSuperclass(); if (Object.class.equals(transportType)) { transportType = null; } } } assertNotNull("Transport implementation unknown", group); group.setAccessible(true); if (expected) { assertTrue(message, group.get(transport) instanceof KQueueEventLoopGroup); } else { assertFalse(message, group.get(transport) instanceof KQueueEventLoopGroup); } }
@Override public EventLoopGroup newEventLoopGroup(int threads, ThreadFactory factory) { return new KQueueEventLoopGroup(threads, factory); }
private boolean useKQueue(EventLoopGroup group) { if (group instanceof ColocatedEventLoopGroup) { group = ((ColocatedEventLoopGroup) group).get(); } return group instanceof KQueueEventLoopGroup; }