Coder Social home page Coder Social logo

Comments (8)

welcome avatar welcome commented on July 17, 2024

Thanks for opening your first issue here! ๐ŸŽ‰ Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

from fiber.

ReneWerner87 avatar ReneWerner87 commented on July 17, 2024

https://docs.gofiber.io/#zero-allocation
image
correct, the request/response context is not thread safe or cannot be used in other concurrent go routines outside of this flow

you need to make copies of the values you want to use in this flow

we achieve this performance in our framework by reusing this context after the run for the next one

image

from fiber.

ReneWerner87 avatar ReneWerner87 commented on July 17, 2024

@omaskery does it answer your question?

from fiber.

omaskery avatar omaskery commented on July 17, 2024

Ah, so to me the wording of the documentation makes it clear that you should not keep references to Ctx that outlive the handler's execution, but it does not make clear to me that it isn't thread-safe during the execution of a handler.

If I'm understanding you correctly that the fiber.Ctx is not thread-safe, even within the handler's duration, then I think you've answered my question, thank you.

I do feel that it might be worth explicitly stating in the documentation that this struct is not thread-safe. What do you think?

from fiber.

ReneWerner87 avatar ReneWerner87 commented on July 17, 2024

I do feel that it might be worth explicitly stating in the documentation that this struct is not thread-safe. What do you think?

yes that would be good

can you provide this as a contribution to our current documentation ?

from fiber.

omaskery avatar omaskery commented on July 17, 2024

Yeah I'm willing to give that a go :)

from fiber.

umardev500 avatar umardev500 commented on July 17, 2024

I still never get it, hard to understand for me haha

from fiber.

ReneWerner87 avatar ReneWerner87 commented on July 17, 2024

I still never get it, hard to understand for me haha

what do you not understand ? the context cannot be torn out of its process and simply be used in a parallel process
because it is reused after the request response process
and it is not designed to access the methods in parallel, there might be problems in some places
therefore you should extract the values beforehand and use them in the parallel run

from fiber.

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.