V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  capric  ›  全部回复第 1 页 / 共 2 页
回复总数  30
1  2  
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 分发。
cv2.VideoCapture 的 read 是调用 ffmpeg 库实现的,涉及到几个耗时操作,解析 rtmp 封装,H.264/H.264 视频解码(最占用 CPU),yuv 颜色空间转换成 rgb24 ,打包成 numpy 数组。如果你是在 pc 在操作,需要自己重新编译 ffmpeg ,启用 nvdec/qsv 硬件加速,这个解码负载就可以移动到 GPU 上来做,CPU 占用就很低了。
@zhixiz1007 会降,下午问了银行,每年 1 月 1 日调整
2023-09-20 10:43:24 +08:00
回复了 hez2010 创建的主题 程序员 WSL2 今天史诗级更新
Windows 10 企业版 LTSC 21H2 (19044.3448)直接安装 github release 2.0.0 之后更新.wslconfig 后重启,再打开现有 linux
wsl: 不支持镜像网络模式,正在回退到 NAT 网络
wsl: Hyper-V 防火墙不受支持
wsl: DNS 隧道不受支持
2021-06-19 18:33:30 +08:00
回复了 manami 创建的主题 ACG 有没有什么好看的动画推荐?
京阿尼的紫罗兰永恒花园,吹响吧上低音号, 轻音少女,凉宫春日系列
风灵玉秀,某科学的电磁炮, 装甲重拳,灵笼,雾山五行
一人之下,少年歌行,金光布袋戏
2021-04-29 20:22:36 +08:00
回复了 unilink233 创建的主题 问与答 windows 下摄像头当监控来用 有没有好一点软件来实现?
win32 api 采集摄像头数据, mf 编码成 mp4(h264/h265)本地存储
如果需要远程查看, 文件分小片, 一个 http 服务启 hls, 或者实时上传到去服务器
2019-09-25 17:17:27 +08:00
回复了 Dustyposa 创建的主题 Python 如何利用 websocket 给子进程传输 stdin
windows 用 pipe,linux 用 sock
2019-05-21 16:06:18 +08:00
回复了 codechaser 创建的主题 C CMake 中如何指定一个 target 执行文件的输出位置?
改输出名字也是可以的
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(suffix "64")
else()
set(suffix "32")
endif()

# set_target_properties(${name} PROPERTIES OUTPUT_NAME "dense_mapping${suffix}")
2019-05-21 16:04:19 +08:00
回复了 codechaser 创建的主题 C CMake 中如何指定一个 target 执行文件的输出位置?
set_target_properties(
dense_mapping
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../../rundir"
)

${CMAKE_BINARY_DIR} 是默认输出位置
2019-04-08 10:21:08 +08:00
回复了 anonymoustian 创建的主题 Python Python 如何提取非结构化数据
src = 'ad=0 cd=0 rcode=ok qdcount=1 ancount=0 nscount=0 arcount=1 src=232.190.252.222 dst=45.80.170.1'
dst = dict(parts.split('=') for parts in src.split())
print(dst.get('ad'))
2019-01-28 14:18:02 +08:00
回复了 frylkrttj 创建的主题 git git 怎么删除 指定 commit 快照 ?
@frylkrttj 退出的时候,自动生成的备注是 commit msg,是可以全部删除,自己编辑的,也可以保留一部分,删除不要的
1  2  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2155 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 54ms · UTC 15:26 · PVG 23:26 · LAX 08:26 · JFK 11:26
Developed with CodeLauncher
♥ Do have faith in what you're doing.