首页 \ 问答 \ LMAX Disruptor事件中的类字段是否需要易变?(Do class fields within an LMAX Disruptor event need to be volatile?)

LMAX Disruptor事件中的类字段是否需要易变?(Do class fields within an LMAX Disruptor event need to be volatile?)

LMAX Disruptor“入门”的示例代码......

public class LongEvent
{
    private long value;

    public void set(long value)
    {
        this.value = value;
    }
}

参考: https//github.com/LMAX-Exchange/disruptor/wiki/Getting-Started

为什么不将private long value声明为volatile

我问,因为隐含于Disruptor模式,数据在线程(生产者 - >消费者)之间共享。

我的猜测:生产者和消费者线程之间已经存在(至少)一个内存栅栏。


Sample code from the LMAX Disruptor "Getting Started"...

public class LongEvent
{
    private long value;

    public void set(long value)
    {
        this.value = value;
    }
}

Ref: https://github.com/LMAX-Exchange/disruptor/wiki/Getting-Started

Why isn't private long value declared as volatile?

I ask because, implicit to the Disruptor pattern, data is shared between threads (producer -> consumer).

My guess: There is already (at least) one memory fence between the producer and consumer threads.


原文:https://stackoverflow.com/questions/34706920
更新时间:2024-03-07 21:03

最满意答案

它确实使密码更难破解。

这是因为组合效应。 密码越长,尝试成功找到密码的组合就越多。

在您的用例中不会有太大的性能损失。 唯一的缺点,如果有的话; 是用户必须选择更长的密码。


It does make the password harder to crack.

This is because of the combinatorial effect. The longer the password the more combinations to try to successfully find the password.

There will not be much of a performance hit in your use case. The only downside, if there is one; is that users have to choose a longer password.

相关问答

更多
  • 特别是如果你已经使用了一个子类UserCreationForm ,我会说你应该只是添加验证。 您应该能够覆盖clean_password上的clean_password方法: def clean_password(self): password = self.cleaned_data.get('password1') if len(password) < 8: raise ValidationError('Password too short') return sup ...
  • 你的$pw_length包含一个string 。 对于你的-lt操作,你需要它是一个integer 。 解决方案:像这样投射你的变量。 [int]$pw_length = $NumberBox1.Text 要么 $pw_length = $NumberBox1.Text -as [int] Your $pw_length contains a string. For your -lt operation, you need it to be an integer. Solution: Cast your ...
  • 您也可以使用正则表达式来验证长度在8到16之间的模式,允许大写和小写字母,数字,句点和下划线。 You can also use Regular Expression which will ...
  • 散列是一种单向函数 ,它会产生一个长度恒定的字符串。 (至少,常见的,包括sha-512。我不知道哈希的定义是否保证了常量长度。) 如果你考虑哈希的作用,这应该是显而易见的。 哈希将任何字符串转换为例如32个字符的字符串。 当然,并非所有关于任意长字符串的信息都可以存储在有限的预定长度的字符串中! 因此,根据鸽子原则 ,必须存在哈希冲突 - 两个字符串散列到相同值的情况。 你不能把n只鸽子放进n-1鸽笼里! 由于我们知道存在无限的哈希冲突(因为存在无限可能的字符串),我们可以证明至少2个(实际上是无限的)不 ...
  • function CheckLength(name) { var password = document.getElementById(name).value; if (password.length < 4) alert('should have miniumum 4 chars'); }
  • 我也在使用Bcrypt。 这似乎对我有用: has_secure_password validates :password, length: { minimum: 6, maximum: 20 }, on: :create I'm using Bcrypt, too. This seems to work for me: has_secure_password validates :password, length: { minimum: 6, maximum: 20 }, on: :create
  • 它确实使密码更难破解。 这是因为组合效应。 密码越长,尝试成功找到密码的组合就越多。 在您的用例中不会有太大的性能损失。 唯一的缺点,如果有的话; 是用户必须选择更长的密码。 It does make the password harder to crack. This is because of the combinatorial effect. The longer the password the more combinations to try to successfully find the pa ...
  • 在调用auth.define_tables()之前,请按如下所示设置最小密码长度: auth.settings.password_min_length = 8 或者,您可以将IS_STRONG验证程序添加到密码字段,或将其默认的CRYPT验证程序替换为指定min_length=8的版本。 Before calling auth.define_tables(), set the minimum password length as follows: auth.settings.password_min_le ...
  • SHA-256显然有256位。 最小UTF-8字符长度是一个字节,即8位。 因此,任何长度超过256/8 = 32个字符的密码都很可能与较短的密码冲突。 这是你的意思吗? SHA-256 has 256 bits, obviously. The minimum UTF-8 character length is one byte, i.e. 8 bits. Therefore, any password longer than 256/8=32 characters is guaranteed extrem ...
  • 6个字符的密码很短,可能太短。 此外,拥有最大密码大小是没有意义的,因为您应该只存储一个哈希值(或更好的输出bcrypt,scrypt或PBKDF2)。 也就是说,它取决于系统如何处理密码,如果它是安全的。 例如,PIN通常约为4..6 位 。 它仍然非常安全,因为您的银行可能只允许您在PIN被阻止之前输入大约3到5个错误的PIN条目。 如果您使用密码作为密钥来加密数据,而无需系统来控制对所述数据的访问(将文件加密到可以被盗的硬盘上),那么6个字符就会很短。 您将需要一个完整的密码和密钥派生方案,以使加密容 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)