2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.yang.netty.threadgroup;
10 import io.netty.channel.nio.NioEventLoopGroup;
11 import java.util.concurrent.TimeUnit;
13 public class NioEventLoopGroupCloseable extends NioEventLoopGroup implements AutoCloseable {
14 private NioEventLoopGroupCloseable(final int threadCount) {
18 private NioEventLoopGroupCloseable() {
22 public void close() throws Exception {
23 shutdownGracefully(0, 1, TimeUnit.SECONDS);
26 public static NioEventLoopGroupCloseable newInstance(final Integer threadCount) {
27 if(threadCount == null || threadCount <= 0) {
28 return new NioEventLoopGroupCloseable();
31 return new NioEventLoopGroupCloseable(threadCount);