Git Product home page Git Product logo

Comments (9)

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

Yes you are right, I am not yet sure if I want to use the RWMutex or just to get rid of the goroutines and the whole async strategy. Any pull request (with tests) is welcome ;)

from go-observable.

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

I want also to benchmark the 2 strategies async vs sync

from go-observable.

jpillora avatar jpillora commented on July 17, 2024

Sync could work, users could make triggers async with go o.Trigger(...). I guess there's an issue of each event would trigger in series. Another option is o.GoTrigger(...), which internally would call each callback in it's own goroutine.

RE: Performance: I think just go with a Mutex for now, modifying a map and unlocking is much faster than any use of reflect, so I don't think it will matter too much at this point.

from go-observable.

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

thanks for the hint I will come back here asap without changing tha API of the script

from go-observable.

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

the new version should be thread safe.. can you please have a look?

from go-observable.

jpillora avatar jpillora commented on July 17, 2024

Still appears to have possible races. Every instance in the code which performs a write (e.g. o.Callbacks[event] = ...) could possibly be run concurrently should be protected with a sync lock. Note, concurrent reads are okay if there are no concurrent writes.

from go-observable.

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

But running go test -race there are no errors traced anymore. Can you provide an example I could test where there could be a race condition?

from go-observable.

jpillora avatar jpillora commented on July 17, 2024

I don't actually use go test -race much, though I probably should. I just
think about which code paths which could possibly be run by multiple CPUs
at once. I probably should use go test -race more...

On Thu, Jan 21, 2016 at 9:22 PM Gianluca Guarini [email protected]
wrote:

But running go test -race there are no errors traced anymore. Can you
provide an example I could test where there could be a race condition?


Reply to this email directly or view it on GitHub
#2 (comment)
.

from go-observable.

GianlucaGuarini avatar GianlucaGuarini commented on July 17, 2024

this issue was solved with 0ca0ceb thank you for your help

from go-observable.

Related Issues (2)

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.