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.kqueue;
17
18 import io.netty.channel.IoOps;
19
20 /**
21 * Implementation of {@link IoOps} for
22 * that is used by {@link KQueueIoHandler} and so for kqueue based transports.
23 */
24 public final class KQueueIoOps implements IoOps {
25 private final short filter;
26 private final short flags;
27 private final int fflags;
28 private final long data;
29
30 /**
31 * Creates a new {@link KQueueIoOps}.
32 *
33 * @param filter the filter for this event.
34 * @param flags the general flags.
35 * @param fflags filter-specific flags.
36 * @return {@link KQueueIoOps}.
37 */
38 public static KQueueIoOps newOps(short filter, short flags, int fflags) {
39 return new KQueueIoOps(filter, flags, fflags, 0);
40 }
41
42 private KQueueIoOps(short filter, short flags, int fflags, long data) {
43 this.filter = filter;
44 this.flags = flags;
45 this.fflags = fflags;
46 this.data = data;
47 }
48
49 /**
50 * Returns the filter for this event.
51 *
52 * @return filter.
53 */
54 public short filter() {
55 return filter;
56 }
57
58 /**
59 * Returns the general flags.
60 *
61 * @return flags.
62 */
63 public short flags() {
64 return flags;
65 }
66
67 /**
68 * Returns filter-specific flags.
69 *
70 * @return fflags.
71 */
72 public int fflags() {
73 return fflags;
74 }
75
76 /**
77 * Returns filter-specific data.
78 *
79 * @return data.
80 */
81 public long data() {
82 return data;
83 }
84
85 @Override
86 public String toString() {
87 return "KQueueIoOps{" +
88 "filter=" + filter +
89 ", flags=" + flags +
90 ", fflags=" + fflags +
91 ", data=" + data +
92 '}';
93 }
94 }