capric 最近的时间轴更新
capric

capric

V2EX 第 228267 号会员,加入于 2017-04-29 07:50:15 +08:00
今日活跃度排名 12749
capric 最近回复了
6 天前
回复了 bli22ard 创建的主题 Rust rust TcpStream 为什么设计读写一体
@bli22ard 实现在这里,就是很简单的 Arc 和 clone
```rust
/// Owned read half of a [`TcpStream`], created by [`into_split`].
///
/// Reading from an `OwnedReadHalf` is usually done using the convenience methods found
/// on the [`AsyncReadExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`into_split`]: TcpStream::into_split()
/// [`AsyncReadExt`]: trait@crate::io::AsyncReadExt
#[derive(Debug)]
pub struct OwnedReadHalf {
inner: Arc<TcpStream>,
}

/// Owned write half of a [`TcpStream`], created by [`into_split`].
///
/// Note that in the [`AsyncWrite`] implementation of this type, [`poll_shutdown`] will
/// shut down the TCP stream in the write direction. Dropping the write half
/// will also shut down the write half of the TCP stream.
///
/// Writing to an `OwnedWriteHalf` is usually done using the convenience methods found
/// on the [`AsyncWriteExt`] trait.
///
/// [`TcpStream`]: TcpStream
/// [`into_split`]: TcpStream::into_split()
/// [`AsyncWrite`]: trait@crate::io::AsyncWrite
/// [`poll_shutdown`]: fn@crate::io::AsyncWrite::poll_shutdown
/// [`AsyncWriteExt`]: trait@crate::io::AsyncWriteExt
#[derive(Debug)]
pub struct OwnedWriteHalf {
inner: Arc<TcpStream>,
shutdown_on_drop: bool,
}

pub(crate) fn split_owned(stream: TcpStream) -> (OwnedReadHalf, OwnedWriteHalf) {
let arc = Arc::new(stream);
let read = OwnedReadHalf {
inner: Arc::clone(&arc),
};
let write = OwnedWriteHalf {
inner: arc,
shutdown_on_drop: true,
};
(read, write)
}
```
7 天前
回复了 bli22ard 创建的主题 Rust rust TcpStream 为什么设计读写一体
39 天前
回复了 7911364440 创建的主题 Windows windows 怎么永久关闭自动更新
39 天前
回复了 Ritr 创建的主题 程序员 我想请教一下,如何发送鼠标或者键盘事件
你点击控件成功之后,给 A 窗口发送最小化消息 SendMessage(HWND, SC_MINIMIZE)就可以了吧
91 天前
回复了 KaynW 创建的主题 摄影 家用照片打印机有推荐的吗
@capric 6, 8, 10, A4 的相纸都支持,调整进纸仓的卡扣就行
91 天前
回复了 KaynW 创建的主题 摄影 家用照片打印机有推荐的吗
我家用惠普 4160L 喷墨自动双面,打 7 寸彩色照片或者 1 寸证件都很不能,咸鱼上收的,400-500 块,连供墨仓,墨水买兼容的,很便宜
@clevertension 你这个 rtmp 是实时流吗,如果是实时流,一般只有 25/30/60 几种,不会有 7600 那么高,你统计出来 7600 fps ,应该绝大多数 frame 都是 None 。另外可以用 multiprocessing 和 queue 分发。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2340 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 10:57 · PVG 18:57 · LAX 03:57 · JFK 06:57
Developed with CodeLauncher
♥ Do have faith in what you're doing.