2012/11/12 Gaetano Mendola <mend...@gmail.com>:
> 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(f) 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

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to