Path: blob/master/src/java.net.http/share/classes/jdk/internal/net/http/AsyncTriggerEvent.java
41171 views
/*1* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package jdk.internal.net.http;2627import java.io.IOException;28import java.nio.channels.SelectableChannel;29import java.util.Objects;30import java.util.function.Consumer;3132/**33* An asynchronous event which is triggered only once from the selector manager34* thread as soon as event registration are handled.35*/36final class AsyncTriggerEvent extends AsyncEvent{3738private final Runnable trigger;39private final Consumer<? super IOException> errorHandler;40AsyncTriggerEvent(Consumer<? super IOException> errorHandler,41Runnable trigger) {42super(0);43this.trigger = Objects.requireNonNull(trigger);44this.errorHandler = Objects.requireNonNull(errorHandler);45}46/** Returns null */47@Override48public SelectableChannel channel() { return null; }49/** Returns 0 */50@Override51public int interestOps() { return 0; }52@Override53public void handle() { trigger.run(); }54@Override55public void abort(IOException ioe) { errorHandler.accept(ioe); }56@Override57public boolean repeating() { return false; }58}596061