Steve Hull wrote: > BUT Rails is essentially single-threaded (only a single request > processed at a time), so if I have only a single call to my singleton > instance method per http request, then it should be impossible to get > concurrency problems with it. Right? >
It's actually possible to write various kinds of concurrent code in Rails -- it really ALWAYS was possible to have some concurrency, but not concurrent request handling, and whatever concurrency you added you'd add yourself. But in more recent versions of Rails, even some concurrent request handling is supported. allow_concurrency!. And perhaps Passenger in certain modes as Roderick says, I'm not familiar with Passenger. But you're basically right about the 'ordinary' mode of Rails execution, that only a single request will be processed at a time. This is increasingly not the only option for Rails though. But, yeah, you're also right that if you had Rails executing in a mode that allowed concurrent request handling, you'd need to take care of making sure your singleton object itself is concurrent-access safe -- the singleton pattern will take care of _instantiation_ of the Singleton object being concurrency-safe, but can't take care of it's own internal logic. So you can either do that -- or you can note in comments that this thing isn't concurrency-safe, and shouldn't be used in a concurrent-request environment. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---