Re: How to keep persistent socket connections?

Steve Hull
Wed, 27 May 2009 04:02:28 -0000

Roy,

thanks!! That did help.  I also found that a solution to my problem: I
used a singleton connection manager.  This avoided all my problems.  :)

I have a question regarding thread safety, but I think I''ll post a new
thread for it.  The general gist is: if I have a singleton class (by
using the Singleton mixin), I understand it''s thread-safe in that it
ensures only a single instance of this class will be created.  BUT (in
theory), the instance methods of my singleton instance could be accessed
concurrently by various threads, thus causing a concurrency issue.
Right?

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 per http request, then it should be impossible to get
concurrency problems with it.  Right?