View Javadoc
1   /*
2    * Copyright 2024 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel;
17  
18  /**
19   * A registration for IO.
20   *
21   */
22  public interface IoRegistration {
23  
24      /**
25       * Implementation specific attachment, which might be {@code null}.
26       *
27       * @return  attachment.
28       */
29      <T> T attachment();
30  
31      /**
32       * Submit the {@link IoOps} to the registration.
33       *
34       * @param   ops ops.
35       * @return  an identifier for the operation, which might be unique or not (depending on the implementation).
36       */
37      long submit(IoOps ops);
38  
39      /**
40       * Returns {@code true} if the registration is still valid. Once {@link #cancel()} is called this
41       * will return {@code false}.
42       *
43       * @return  valid.
44       */
45      boolean isValid();
46  
47      /**
48       * Cancel the registration.
49       *
50       * @return {@code true} if cancellation was successful, {@code false} otherwise.
51       */
52      boolean cancel();
53  }