Giter VIP home page Giter VIP logo

Comments (2)

emirpasic avatar emirpasic commented on August 15, 2024

@shindanai-midas the mutex is unnecessary here in the GetIterator function. You can generate as many iterators as you want and they are not shared among each other, so mutex here is irrelevant. A new iterator is generated each time you call the Iterator() function and each iterator is independent of one another. An iterator is simply a pointer to the underlying data structure to provide some traversal mechanism.

So I am not sure what it is that you would like to achieve here? To protect the underlying data structure or protect access to the same iterator by multiple go routines?

from gods.

shindanai-midas avatar shindanai-midas commented on August 15, 2024

@emirpasic I want to protect access to the iterator by multiple goroutines. At first I'm not sure that if I get multiple iterators from the same tree will affected each other while they're traversing concurrently, especially calling Next() function. And as you said

"A new iterator is generated each time you call the Iterator() function and each iterator is independent of one another"

so I knew that it's ok to use iterators concurrently even if it came from the same tree.

Thank you

from gods.

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.