Skip to content

Commit b925ac7

Browse files
Merge pull request #24 from dreamlike-ocean/feature-Mutiny
Feature mutiny
2 parents a843713 + 476d9ee commit b925ac7

File tree

223 files changed

+2073
-7868
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+2073
-7868
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
/target/
33
.idea
44
*.log
5-
*.iml
5+
*.iml
6+
*/target
7+
*/*.iml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ API仍在变动之中**
6464
> 注意 jdk版本不能升级也不能降级,Panama api可能不一致
6565
6666
- Maven 3.8.4
67-
- OpenJDK 20
67+
- OpenJDK 21
6868
- Linux >= 5.10
6969

7070
构建非常简单

demo.txt

100755100644
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
ateastd
2-
ddd
3-
dddddd
4-
dddddadasd
5-
dasdawdawdefevadwadmawlkdmdlkwamdm追加写东西追加写东西
6-
追加写东西追加写东西追加写东西追加写东西追加写东西追加写东西追加写东西追加写东西追加写东西追加写东西
1+
追加写东西Lazy追加写东西Lazy

example/pom.xml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
<kotlin.version>1.9.10</kotlin.version>
1617
</properties>
1718
<dependencies>
1819
<dependency>
@@ -25,6 +26,80 @@
2526
<artifactId>panama-uring-linux-x86_64</artifactId>
2627
<scope>compile</scope>
2728
</dependency>
29+
<dependency>
30+
<groupId>org.jetbrains.kotlin</groupId>
31+
<artifactId>kotlin-stdlib-jdk8</artifactId>
32+
<version>${kotlin.version}</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.jetbrains.kotlin</groupId>
36+
<artifactId>kotlin-test</artifactId>
37+
<version>${kotlin.version}</version>
38+
<scope>test</scope>
39+
</dependency>
2840
</dependencies>
2941

42+
<build>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.jetbrains.kotlin</groupId>
46+
<artifactId>kotlin-maven-plugin</artifactId>
47+
<version>${kotlin.version}</version>
48+
<executions>
49+
<execution>
50+
<id>compile</id>
51+
<phase>compile</phase>
52+
<goals>
53+
<goal>compile</goal>
54+
</goals>
55+
<configuration>
56+
<sourceDirs>
57+
<source>src/main/java</source>
58+
<source>target/generated-sources/annotations</source>
59+
</sourceDirs>
60+
</configuration>
61+
</execution>
62+
<execution>
63+
<id>test-compile</id>
64+
<phase>test-compile</phase>
65+
<goals>
66+
<goal>test-compile</goal>
67+
</goals>
68+
</execution>
69+
</executions>
70+
<configuration>
71+
<jvmTarget>1.8</jvmTarget>
72+
</configuration>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<executions>
78+
<execution>
79+
<id>default-compile</id>
80+
<phase>none</phase>
81+
</execution>
82+
<execution>
83+
<id>default-testCompile</id>
84+
<phase>none</phase>
85+
</execution>
86+
<execution>
87+
<id>compile</id>
88+
<phase>compile</phase>
89+
<goals>
90+
<goal>compile</goal>
91+
</goals>
92+
</execution>
93+
<execution>
94+
<id>testCompile</id>
95+
<phase>test-compile</phase>
96+
<goals>
97+
<goal>testCompile</goal>
98+
</goals>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
</plugins>
103+
</build>
104+
30105
</project>

example/src/main/java/iouring/AsyncAcceptEpollExample.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
2222
System.out.println("vertx remote:" + ns.remoteAddress().port());
2323
});
2424
EpollAsyncSocket epollAsyncSocket = serverSocket.accept().get();
25-
26-
System.out.println(epollAsyncSocket);
2725
}
2826
}

example/src/main/java/iouring/AsyncSocketExample.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import java.util.concurrent.CountDownLatch;
99
import java.util.concurrent.ExecutionException;
10-
import java.util.concurrent.Flow;
1110
import java.util.concurrent.atomic.AtomicInteger;
1211

1312
public class AsyncSocketExample {
@@ -46,19 +45,11 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
4645
//recv示例
4746
// String s = new String(asyncSocket.recvSelected(1024).get());
4847
byte[] buf = new byte[1024];
49-
Integer recvRes = asyncSocket.recv(buf).get();
50-
String hello = new String(buf, 0, recvRes);
48+
Long recvRes = asyncSocket.recv(buf).get();
49+
String hello = new String(buf, 0, recvRes.intValue());
5150
System.out.println("client recv:" + hello);
5251
CountDownLatch count = new CountDownLatch(10);
5352

54-
Flow.Subscription recvMulti = asyncSocket.recvMulti(bytes -> {
55-
System.out.println("GET:" + new String(bytes));
56-
count.countDown();
57-
});
58-
recvMulti.request(10);
59-
count.await();
60-
61-
recvMulti.cancel();
6253
vertx.close();
6354
} catch (Exception e) {
6455
}

example/src/main/java/iouring/AsyncWatchServiceExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
1717
var watchService = new AsyncWatchService(ioUringEventLoop);
1818
int demoFd = watchService.register(Path.of("demo.txt"), inotify_h.IN_MODIFY()).get();
1919
System.out.println(demoFd);
20-
int dirFd = watchService.register(Path.of("/home/dreamlike/uringDemo"), inotify_h.IN_CREATE()).get();
20+
int dirFd = watchService.register(Path.of(""), inotify_h.IN_CREATE()).get();
2121
System.out.println(dirFd);
2222
System.out.println("select");
2323
while (true) {

example/src/main/java/iouring/EpollExample.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import java.lang.foreign.Arena;
66
import java.lang.foreign.MemorySegment;
7+
import java.lang.foreign.ValueLayout;
78
import java.util.ArrayList;
89

910
import static top.dreamlike.nativeLib.epoll.epoll_h.EPOLLIN;
@@ -15,7 +16,7 @@
1516
*/
1617
public class EpollExample {
1718
public static void main(String[] args) {
18-
try (Arena allocator = Arena.openConfined()) {
19+
try (Arena allocator = Arena.ofConfined()) {
1920
MemorySegment memorySegment = allocator.allocate(1024);
2021
int flags = fcntl(0, F_GETFL(), 0);
2122
int res = fcntl(0, F_SETFL(), flags | O_NONBLOCK());
@@ -28,6 +29,7 @@ public static void main(String[] args) {
2829

2930
long read = read(0, memorySegment, memorySegment.byteSize());
3031
System.out.println(read);
32+
System.out.println(new String(memorySegment.reinterpret(read).toArray(ValueLayout.JAVA_BYTE)));
3133
}
3234

3335

example/src/main/java/iouring/EpollSocketExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void main(String[] args) throws ExecutionException, InterruptedExc
4343
byte[] bytes = new byte[1024];
4444
//socket read 基于epoll做的 这里简单直接get阻塞到完成
4545
Integer recvLength = socket.recv(bytes)
46-
.get();
46+
.get().intValue();
4747
System.out.println(new String(bytes, 0, recvLength));
4848
}
4949
}

example/src/main/java/iouring/EventFdExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static void main(String[] args) throws InterruptedException {
1212

1313
EpollEventLoop epollEventLoop = new EpollEventLoop();
1414
epollEventLoop.start();
15-
epollEventLoop.registerEvent(eventFd.getFd(), EPOLLIN(), (i) -> {
15+
epollEventLoop.registerReadEvent(eventFd.getFd(), EPOLLIN(), (i) -> {
1616
System.out.println(eventFd.readSync());
1717
});
1818

0 commit comments

Comments
 (0)