首页 \ 问答 \ Java的Atomic *类中的lazySet如何实现?(How is lazySet in Java's Atomic* classes implemented?)

Java的Atomic *类中的lazySet如何实现?(How is lazySet in Java's Atomic* classes implemented?)

在关于Disruptor的一个并发框架的视频中 ,提到了Java的Atomic *类(例如AtomicLong)的lazySet方法。 根据文件 ,这种方法“最终设定为给定值”。

有没有人知道底层机制是如何实现的(特别是在Windows上的x86上,如果这是相关的)。 它不能是InterlockedExchange() ,因为如果我没有弄错的话,它会设置值并确保缓存行在返回之前被刷新。


In this video about Disruptor, a concurrency framework, the lazySet method of Java's Atomic* classes (e.g. AtomicLong) is mentioned. According to the documentation, this method "eventually sets to the given value".

Does anybody know what the underlying mechanism is to implement this (specifically on x86 on Windows, if that is relevant). It can't be InterlockedExchange(), because that would set the value and make sure cache lines are flushed before returning, if I'm not mistaken.


原文:https://stackoverflow.com/questions/8381440
更新时间:2023-05-14 15:05

相关问答

更多
  • 您不能这样做的原因是因为在编译期间不能解析和替换非常数表达式。 它们可能在运行时更改,这将需要在运行时生成新的模板,这是不可能的,因为模板是编译时的概念。 这是标准允许非类型模板参数(14.1 [temp.param] p4): 非类型模板参数应具有以下(可选cv限定)类型之一: 整数或枚举类型, 指向对象或指向函数的指针, lvalue引用对象或lvalue引用函数, 指向会员, std::nullptr_t 。 The reason you can't do this is because non-co ...
  • 在data声明中, 类型构造函数是等号左侧的东西。 数据构造函数是等号右侧的事物。 您可以使用期望类型的类型构造函数,并且使用预期值的数据构造函数。 数据构造函数 为了使事情变得简单,我们可以从代表颜色的类型开始。 data Colour = Red | Green | Blue 在这里,我们有三个数据构造函数。 Colour是一种类型, Green是一个包含Colour类型的构造函数。 类似地, Red和Blue都是构造Colour类型的构造函数。 我们可以想象一下,尽管它可以打扰! data Colo ...
  • 是的,有点。 事情是每次你实例化一个模板时,编译器都会为这个特定的类型参数化生成特定的代码。 举例来说,在你的例子中,如果你有foo<3>和foo<5> ,编译器将生成两个独立函数的代码,其中T=3和T=5 所以是的,它的工作原理是因为T不能改变,它为什么起作用的机制稍微复杂一点,但...... Yeah, kind of. Thing is every time you instantiate a template the compiler will generate specific code for ...
  • 但我知道的所有这些变通方法仅适用于类型参数 没有一种解决方法是特定于类型的 - 重点是在构造函数中插入一些可以推导出来的东西。 所以如果我们想要一个类型,我们会做类似的事情: template struct tag { }; struct S { template S(tag); }; 如果我们想要一个int ,我们做同样的事情: template struct val { }; struct S { templat ...
  • 没有进一步的限制,这样的类型是无用的 - 没有什么可以真正用它们做,期望正确地传递它们。 但实际上情况与签名相同a -> Int :如果没有人知道a ,那么你也无法做到! 但是,与例如toInteger :: Integral a => a -> Integer ,向参数添加约束可以让你做一些事情。 例如, import Data.Foldable import Prelude hiding (foldr) x' :: (Foldable a, Integral b) => a b -> Integer ...
  • 你可以为此使用GADT 。 {-# LANGUAGE GADTs #-} data Option a where Help :: Option () Opt1 :: Int -> Double -> String -> Option (Int, Double, String) handleOption :: Option a -> IO () handleOption option = case option of Help -> handleHelp ...
  • 你不能以你描述的方式真正做到这一点。 因为Player接受一个参数( pName ),所以Player本身的类型是String -> Object ,所以它不适合你的Table类型。 正如您的编辑中所建议的那样,您应该创建一个单独的枚举类型,而不需要专门针对Table参数: data ObjectType = PlayerType | MonsterType | ... 根据如何定义Object的其他构造函数,您可能能够避免重复,例如 data Object = Object { objectType : ...
  • 行为的原因是一个名为ExtendedDefaultRules的ghc 扩展 。 从链接引用: 然而,用户必须指定类型是很烦人的,所以GHCi扩展了Haskell的类型违约规则(Haskell 2010 Report的4.3.4节),如下所示。 标准规则为每个类型变量a采用每组约束(C1a,C2a,...,Cna),并且默认类型变量if 类型变量a不会出现在其他约束中 所有Ci类都是标准的。 至少有一个类Ci是数字。 在GHCi提示符处或者GHC中,如果给出-XExtendedDefaultRules标志,则 ...
  • 您需要重新指定模板参数 template FixedVector::FixedVector() { data = new T[length]; } You need to re-specify the template parameters template FixedVector::FixedVector() { data = new ...
  • Numero的表达 (Monomio (Numero (Integer 15)) (Integer 20)) 不是一个类型 - 而是一个 类型 值构造函数,所以你需要它来构造一个Elemento类型的值。 一种方法是使用fromIntegral来实现“自动”转换。 对于String类型,你有OverloadedStrings -Language扩展,但对于数字类型,没有像这样的东西(至少据我所知)。 注意:我认为这让你的代码更加混乱,因为你有一种Numero和一个Numero的类型构造器,后者构造了Ele ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。