Hey Gaetano, On Mon, Nov 12, 2012 at 8:35 PM, Gaetano Mendola <mend...@gmail.com> wrote: > I have read recently in your Doxygen documentation related to > > template<typename F > > boost::function< void()> Wt::WApplication::bind ( const F & f > ) > > the following statement: > > "in the same way as how a signal automatically disconnects slots from > objects that are being deleted" > > Since wt slots are implemented in terms of boost signals you have to > keep in mind the fact that issuing a > connection::disconnect() doesn't avoid the fact that the signal is > delivered to disconnected "slot" if you perform the disconnection > while the signal is being delivered. > > To be clear, if you do: > > connection con1 = signal.connect(&foo); > connection con2 = signal.connect(&bar); > > and then: > > signal(); > > if another thread performs: con2.disconnect(); > > then bar() will be called as well even if the signal() call is "executing" > foo.
There are actually two layers: - WServer::post(sessionId, f) protects against simultaneous access to a single session, by running the function f only after acquiring the session lock for 'sessionId'; - WApplication::bind(b) protects against a previous deallocation of an object involved in the function f, by running the function f only if none of the objects bound to f are still alive -- bind() itself is not thread-safe (for the simple reason that the application object itself is not thread-safe to use) and therefore you should do the bind at same time that you are binding the arguments of the function (i.e. you should usually have wApp->bind(boost::bind(...)) You should never have two threads at the same time touching the same session, and WApplication::bind() does nothing to protect you from doing that. Regards, koen ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ witty-interest mailing list witty-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/witty-interest