-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 向插件提供并发落锁 API #1204
base: master
Are you sure you want to change the base?
feat: 向插件提供并发落锁 API #1204
Conversation
@@ -80,6 +80,9 @@ type ExtInfo struct { | |||
// 为Storage使用互斥锁,并根据ID佬的说法修改为合适的名称 | |||
dbMu sync.Mutex `yaml:"-"` // 互斥锁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此处的dbMu
是否已经实现此 pr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
让我看看
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个好像是用来处理插件数据库初始化/关闭时的并发问题的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另,我的想法是不添加新的函数,而是保证 storageGet
和 storageSet
的并发安全性,以避免增加开发成本
我觉得这是几乎不可实现的。
这种情况下数据竞争必然发生。 理论上可以在通过「进行异步调用之后(比如 也可能是我对 JS 和 jsvm 的理解还是有问题 |
我注意到在 这里 你的每次 |
这里提供一个我的解决方案(AGPL 协议注意)https://github.com/Szzrain/sealdice-Enhanced-DnD/blob/master/src/io/io_helper.ts |
非常好思路,使我插件旋转(我去试试喵) 非常坏海豹 API 😤 |
尽管海豹的 jsvm 的事件循环是单线程的,js 内部的变量无需考虑并发数据竞争。然而,涉及使用
storageGet
与storageSet
读写外部数据时,仍然存在数据竞争的可能。因此,向插件提供并发落锁 API 以解决此问题。