Thread model?
Hello everyone, Im investigating Pippo for some projects and I couldn't find any information about the threading model. And by that, I mean how are routes/controllers instantiated and maintained throughout the request/response/process lifecycle, in order to ensure code thread safety. As a developer, do I have to worry about thread safety at all ? or thread safety is provided by the framework (like, for exaple, vertx) ? If we have to handle this manually, is there any advice, good practice, documentation or guide written about this? Thank you!
I don't think you need to worry about thread-safety as long as you do not use instance variables in Route
Right, but what if you do? An example would be any heavy/long initialization object: like a connection pool for example. Maybe It makes sense to create it only once and reuse between executions, instead of creating the connection every time the controller is executed. I am not saying this is the case of pippo, but because I do not know what the model is, i can not be sure. I guess the question is towards understanding what the instance lifecycle is for the different components and manage the threading based on that.
I have a mistake in last comment, in pippo Route is a singleton instance, but Controller will be created a new instance for each request and thread. so if you have some heavy/long initialization object for a handler, you can create it in Route, but if you need to use it in Controller, you should give a singleton instance or use ioc container like pippo-spring
Information posted by ScienJus is right. If you need more details please let me know. Also, if you see some improvements I would be happy to encapsulate them. I will improve the documentation related to this subject.