Hey Gaetano, In such cases, I tend to use a shared_pointer to manage the lifetime of the WtTerminal object. As such, the DTOR would be called after the queued posts have disappeared.
I'll let Koen comment on the proposed modification to post(). Similar to shared_pointer, if you pass an object with a special destructor that tells WtTerminal when it's destroyed, you could get WtTerminal to count how many of your messages are still unhandled in the post() queue. But that's a bit more clumsy for the user, I guess. BR, Wim. 2011/4/18 Gaetano Mendola <[email protected]>: > Hi guys, > due to some critical race in my application using the UpdateLock > method I converted my application > to use the Wt::WServer::post. > > Basicaly what I'm doing is now: > > Wt::WServer::instance()->post(theSessionId, > > boost::bind(&WtTerminal::swapModel, > this, > > myDataModelBuffer)); > > Due the fact the calls are now asynchronus I have to make the object > instances (this) passed to the > post to survive the Session, otherwise some posts are called on dead objects. > > So in WtTerminal DTOR I have to wait that all queued posts where > called or discarded (due > the session id not found) or that the sessionId is not valid. > > Looking at the API it doesn't seems this is possible. Is there a way I > didn't see? > > I have tried this: > > Wt::WServer::instance()->post(boost::bind(&WtTerminal::postsDone, > const_cast<WtTerminal*>(this))); > > (supposing all the posts are threated in a FIFO policy) and then > waiting that the method has been > called, but the Wt::WServer::post(const boost::function<void()>&) is private. > > > It doesn't seem that a Wt::WApplication instance can emit a signal > when is destroyed ( I can inherit from > it and specialize the WApplication::finalize() in order to emit a message). > > It would be usefull if the Wt::WServer::instance()->post(const > std::string& sessionID, ....) could take two > function. The first is called if the sessionId exists, the second if > the sessionId doesn't exist ( I can provide > a patch for this in case). > > > Regards > Gaetano Mendola > > -- > cpp-today.blogspot.com > > ------------------------------------------------------------------------------ > Benefiting from Server Virtualization: Beyond Initial Workload > Consolidation -- Increasing the use of server virtualization is a top > priority.Virtualization can reduce costs, simplify management, and improve > application availability and disaster protection. Learn more about boosting > the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev > _______________________________________________ > witty-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/witty-interest > ------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
