- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个需要共享流所有权的流适配器。
将流(私下)存储在 Pin<Arc<Mutex<impl Stream>>>
中是否正确? ?
如何调用poll_next(self: Pin<&mut Stream>
在流?
最佳答案
Mutex
没有所谓的结构钉扎,这在 std::pin
中有描述。模块文档:
It turns out that it is actually up to the author of the data structure to decide whether the pinned projection for a particular field turns
Pin<&mut Struct>
intoPin<&mut Field>
or&mut Field
. [...] As the author of a data structure you get to decide for each field whether pinning "propagates" to this field or not. Pinning that propagates is also called "structural", because it follows the structure of the type.
Mutex<T>
没有结构固定,因为结构(
Mutex
)的固定不会传播到字段(
T
) - 获得未固定的
&mut T
是安全的来自
Pin<&mut Mutex<T>>
(即,通过使用
Deref
而不是
DerefMut
并锁定互斥锁),即使
T
和
Mutex<T>
是
!Unpin
.
&mut T
变成
Pin<&mut T>
,你必须做另一层未经检查的保证,使用
unsafe
和
Pin::new_unchecked
, 来证明
T
本身永远不会移动。这似乎违背了“外部”的目的
Pin
.
Arc<Mutex>
编写包装器固定 Mutex
的内容通过 Pin
访问时(您无法实现 Deref
,但您可以编写返回 MutexGuard
并在内部执行 Pin
-wrapping 的方法)Stream
的类型中,如果你的数据结构允许的话。 关于rust - 如何从 Pin<Arc<Mutex<T>>> 中获取 Pin<&mut T>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60248333/
我知道您可以使用 -fno-objc-arc 标志对 ARC 项目中不支持 ARC 的文件禁用 ARC。 有什么方法可以在非 ARC 项目中为支持 ARC 的文件启用 ARC 吗? 谢谢! 最佳答案
ARC 代表自动引用计数。 我刚刚升级了我的项目以使用 ARC。虽然不是全部。只是一些。 我怎么知道? 最佳答案 要查看默认值,您必须检查目标属性(您的目标 -> build设置 -> Apple L
我有一个框架 A,它是 ARC。这会消耗一些来自非 ARC 框架 B 的 API。 框架B示例代码(非ARC): @interface Settings : NSObject { NSDict
我一直避免升级 Xcode,直到某个特定项目完成(即将推出)。我希望能够在未来的项目中使用 ARC,同时保留维护和调查先前软件产品问题的能力。 问题是可以通过安装一次 Xcode 来完成此操作吗?当我
我正在开发一个非常旧的非基于 ARC 的项目,并添加了一些基于 ARC 的新 UIViewController(可以通过在构建阶段设置 -fobjc-arc 标志来实现) . 由于ARC和非ARC的混
这个问题在这里已经有了答案: How do you enable ARC project-wide in Xcode 4.2 (3 个答案) How to automatically conver
我是 iPhone 开发的新手。我了解到ARC是现在IOS引入的新特性。我的问题是,我有一个手动编写版本的旧非 ARC 项目,是否可以将该项目从非 ARC 切换到 ARC ? 谢谢, 拉吉 最佳答案
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 7年前关闭。 Improve this questi
我的项目是在 ARC 打开的情况下创建的,现在我使用的是第三方框架,该框架很可能不是用 ARC 构建的。这样做会有什么问题吗?我现在遇到了框架中某个地方发生的崩溃,但我没有得到有关崩溃的太多详细信息。
我猜这是一个简单的问题,但我无法弄清楚: 我的项目中存在三个与构建阶段中设置的链接器标志 -fno-obj-arc 不 ARC 兼容的文件。 但是据我所知,这些标志被忽略了。编译器仍然提示向对象发送保
我认为标题很好地解释了我的问题,我目前正在开发一个满足我个人需求的小型框架,并考虑使用 ARC 构建它(如果可能的话?),并在旧项目中使用它是在 ARC 之前 build 的吗? 最佳答案 是的,但有
我正在努力让现有的启用 ARC 的控件在不启用 ARC 的项目中在 Xcode 4.2 (OSX Snow Leopard) 下运行,并且我面临着各种问题: 我应该如何解决以下问题? 在属性中使用(s
我想知道如何更改 Arc 中的值,然后使 Arc 的其他副本再次有效。 use std::sync::Arc; use std::thread; use std::error::Error; use
ARC 运行时版本:我不知道,但我在这个网站上下载了它,https://chrome.google.com/webstore/detail/arc-welder/emfinbmielocnlhgmfk
当我将 iPhone 项目转换为 Objective - c ARC 时,我总是遇到相同的错误: /Applications/Xcode.app/Contents/Developer/Platform
如何在没有 ARC 的情况下为使用 ARC 的项目构建静态库? 我找到了一些静态库的源代码,我想为我的项目构建它,但我使用的是 ARC。 最佳答案 静态库可以在没有 ARC 的情况下构建,并且可以使用
我有一个使用 ARC 的 A 类和不使用 ARC 的其他 B 类和 C 类。如果 A 包含 B 类对象而 B 包含 C 类对象,那么 ARC 如何工作以及当 B 类和 C 类中的内存管理处理不当时会发
一旦我将 -fno-objc-arc 标志添加到构建阶段中的一个或多个单独的文件,我的 MyProject-Prefix.pch 文件就会进入非 ARC 模式,导致 150 条警告,如“警告:没有‘分
在某些情况下,我需要为几个非 ARC xcode 项目中的许多文件启用 ARC。我不想完全转换为 ARC,只需要使用 arc 启用几个文件。 有许多解决方案使用 XCode 控制台将 -fobjc-a
我还没有使用过 ARC,只是在它通过第 3 方代码强制进入项目时处理它。我已经阅读了所有 ARC 文档,但还没有看到这个问题的答案: 如果我在使用 -fobjc-arc 编译的模块中定义了一个类,我能
我是一名优秀的程序员,十分优秀!