Comments (6)
没有用过,这个库和reactor-core对比呢
reactor,rxjava,mutiny本质上都差不多,选一个用就好了 这边我选mutiny只是个人爱好
from panamauring.
没有用过,这个库和reactor-core对比呢
from panamauring.
感觉实现不了。。。
这样这样的一个接口(这里的实现是错的)
protected Uni<Integer> writeUnsafeLazy(int offset, MemorySegment memorySegment) {
if (closed.get()) {
throw new NativeCallException("file has closed");
}
Uni<Integer> lazyRes = Uni.createFrom()
.emitter((ue) -> {
AtomicLong userDataLazy = new AtomicLong();
long userData = ioUring.prep_write_and_get_user_data(writeFd(), offset, memorySegment,
(writeRes) -> {
ue.complete(writeRes);
});
if (userData == IOUring.NO_SQE) {
ue.fail(new NotEnoughSqeException());
return;
}
ue.context().put(USER_DATA_KEY, userData);
userDataLazy.set(userData);
});
return lazyRes.withContext((uni, c) -> {
Long userData = c.get(USER_DATA_KEY);
// uni.onCancellation() .call(() -> eventLoop.cancelAsync(userData, 0, true));
// 这个call的语义是The upstream is not cancelled yet, but will be cancelled when the returned {@link Uni} completes
// 所以无论是否取消成功他都会设置流为取消状态
//思考这样一个场景,MemorySement为一池化内存,下游在cancel的回调里面设置当cancel时归还内存
//此时发起取消,但是此时已经进去写fd的环节导致取消失败,但是由于直接设置流为cancel 内存可以被复用了,
//此时有个其余的线程拿到了这个MemorySegement并进行写入操作,此时os仍在写入fd,写入的东西就是不可预知的了
return uni.onCancellation()
.call(() -> eventLoop.cancelAsync(userData, 0, true));
});
}
from panamauring.
【【达坦科技】4.8 Beijing Rust Meetup|茌海《Monoio:一个基于 io-uring 的 Rust Runtime》-哔哩哔哩】 https://b23.tv/JVkyPFO
我可能从一开始就是错的。。。异步所有权的问题
看起来得做点更复杂的取消逻辑 or 干脆摆烂不做取消
甚至重新设计。。。
from panamauring.
目前采用构建所有权的方式实现
给出一个
public interface OwnershipMemory {
MemorySegment resource();
void drop();
}
这样的接口给用户,以示转移所有权给io_uring侧,若用户和io_uring侧同时都在修改这个资源甚至用户把他释放了,这种情况属于UB。。。。没有办法通过编译器来约束,只能做个约定
from panamauring.
目前改造使用所有权的约定,只有当异步操作正常完成且没有被cancel的场景才将OwnershipMemory发送到下游,其余情况直接在io_uring eventloop侧释放这个所有权
from panamauring.
Related Issues (20)
- AsyncServerSocket multi shot accept接口实现问题 HOT 1
- jdk20新ffi api更改的适配
- 更少的拷贝
- io_uring异常唤醒
- 抛弃生成的代码 进行瘦身
- 缺少对应的c头文件,方便用jexract去生成abi HOT 2
- ring_message支持
- io_uring_prep_splice
- C abi ffi生成器适配 HOT 5
- Struct 生成器支持NativeArray类 HOT 1
- native call 返回指针时错误取值问题 HOT 1
- invokedynamic惰性初始化对应的native call生成 HOT 1
- native-image适配 HOT 5
- jdk22适配-生成器适配 HOT 1
- jdk22适配-PanamaUring适配 HOT 1
- 字符串模板相关代码回滚
- 移除mutiny依赖 HOT 1
- 柔性数组支持
- 提供尽可能简单且扩展好的EpollEventLoop实现
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from panamauring.