1+ /*
2+ * Copyright (C) 2010 Emweb bvba, Kessel-Lo, Belgium.
3+ *
4+ * See the LICENSE file for terms of use.
5+ */
16#include <Wt/WApplication>
27#include <Wt/WContainerWidget>
38#include <Wt/WPushButton>
611#include <iostream>
712#include <boost/thread.hpp>
813
9- using namespace Wt ;
10-
1114/*
1215 * This is a minimal server push example, which is used to update the GUI
1316 * while a big work is computing in another thread.
1417 */
1518
16- class BigWorkWidget : public WContainerWidget
19+ class BigWorkWidget : public Wt :: WContainerWidget
1720{
1821public :
19- BigWorkWidget (WContainerWidget * parent )
22+ BigWorkWidget (Wt :: WContainerWidget * parent )
2023 : WContainerWidget (parent )
2124 {
22- startButton_ = new WPushButton ("Start" , this );
23- startButton_ -> clicked ().connect (startButton_ , & WPushButton ::disable );
25+ startButton_ = new Wt :: WPushButton ("Start" , this );
26+ startButton_ -> clicked ().connect (startButton_ , & Wt :: WPushButton ::disable );
2427 startButton_ -> clicked ().connect (this , & BigWorkWidget ::startBigWork );
2528
26- resultText_ = new WText (this );
29+ resultText_ = new Wt :: WText (this );
2730 resultText_ -> setInline (false);
2831 }
2932
3033private :
31- WPushButton * startButton_ ;
32- WText * resultText_ ;
34+ Wt :: WPushButton * startButton_ ;
35+ Wt :: WText * resultText_ ;
3336
3437 boost ::thread workThread_ ;
3538
3639 void startBigWork () {
37- WApplication * app = WApplication ::instance ();
40+ Wt :: WApplication * app = Wt :: WApplication ::instance ();
3841
3942 // Enable server push
4043 app -> enableUpdates (true);
@@ -53,23 +56,23 @@ private:
5356 * that use thread-local storage. We can only access WApplication::instance()
5457 * after we have grabbed its update-lock.
5558 */
56- void doBigWork (WApplication * app )
59+ void doBigWork (Wt :: WApplication * app )
5760 {
5861 for (unsigned i = 0 ; i < 20 ; ++ i ) {
5962 // Do 50 ms of hard work.
6063 boost ::this_thread ::sleep (boost ::posix_time ::milliseconds (50 ));
6164
6265 // Get the application update lock to update the user-interface
6366 // with a progress indication.
64- WApplication ::UpdateLock uiLock = app -> getUpdateLock ();
67+ Wt :: WApplication ::UpdateLock uiLock = app -> getUpdateLock ();
6568
6669 resultText_ -> setText (resultText_ -> text () + "." );
6770
6871 app -> triggerUpdate ();
6972 }
7073
7174
72- WApplication ::UpdateLock uiLock = app -> getUpdateLock ();
75+ Wt :: WApplication ::UpdateLock uiLock = app -> getUpdateLock ();
7376
7477 resultText_ -> setText ("That was hefty!" );
7578 startButton_ -> enable ();
@@ -82,9 +85,9 @@ private:
8285 }
8386};
8487
85- WApplication * createApplication (const WEnvironment & env )
88+ Wt :: WApplication * createApplication (const Wt :: WEnvironment & env )
8689{
87- WApplication * app = new WApplication (env );
90+ Wt :: WApplication * app = new Wt :: WApplication (env );
8891 new BigWorkWidget (app -> root ());
8992
9093 return app ;
0 commit comments