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.uring;
17  
18  import io.netty.channel.IoEvent;
19  
20  /**
21   * {@link IoEvent} that will be produced as an result of a {@link IoUringIoOps}.
22   */
23  public final class IoUringIoEvent implements IoEvent {
24  
25      private byte opcode;
26      private int res;
27      private int flags;
28      private short data;
29  
30      /**
31       * Create a new instance
32       *
33       * @param res       the result.
34       * @param flags     the flags
35       * @param opcode    the op code
36       * @param data      the user data that was given as part of the submission.
37       */
38      public IoUringIoEvent(int res, int flags, byte opcode, short data) {
39          this.res = res;
40          this.flags = flags;
41          this.opcode = opcode;
42          this.data = data;
43      }
44  
45      // Used internally to reduce object creation
46      void update(int res, int flags, byte opcode, short data) {
47          this.res = res;
48          this.flags = flags;
49          this.opcode = opcode;
50          this.data = data;
51      }
52  
53      /**
54       * Returns the result.
55       *
56       * @return  the result
57       */
58      public int res() {
59          return res;
60      }
61  
62      /**
63       * Returns the flags.
64       *
65       * @return flags
66       */
67      public int flags() {
68          return flags;
69      }
70  
71      /**
72       * Returns the op code of the {@link IoUringIoOps}.
73       *
74       * @return  opcode
75       */
76      public byte opcode() {
77          return opcode;
78      }
79  
80      /**
81       * Returns the data that is passed as part of {@link IoUringIoOps}.
82       *
83       * @return  data.
84       */
85      public short data() {
86          return data;
87      };
88  
89      @Override
90      public String toString() {
91          return "IOUringIoEvent{" +
92                  "opcode=" + opcode +
93                  ", res=" + res +
94                  ", flags=" + flags +
95                  ", data=" + data +
96                  '}';
97      }
98  }