Coder Social home page Coder Social logo

event 处理并发安全咨询 about squirrel HOT 1 OPEN

yinwoods avatar yinwoods commented on June 2, 2024
event 处理并发安全咨询

from squirrel.

Comments (1)

yinwoods avatar yinwoods commented on June 2, 2024

我再补充下场景描述,对于一个线性变化的状态机来说,如果中间某个状态流转足够快(比如直接 return),那么通过线程池异步 fire 对应的 event 可能与上一个 event 近乎同时进入 queuedEvents
image

如下图所示,两个线程,其中一个刚好执行到 processEvents 中 data.read.currentRawState() 位置(持有写锁,标记 status 为 busy,e1 进入 queuedEvents),另一个刚刚提交 e2 进入 queuedEvents 并进入 processEvents 方法,那么两个线程都从 processEvents 方法返回后,queuedEvents 中还会存留一个 e2,如果后续不再有新的 event 进入队列,触发 processEvents(),则这个 e2 就不再会被处理,造成状态机状态流转卡住的现象
image

from squirrel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.