diff options
Diffstat (limited to 'examples/thread')
-rw-r--r-- | examples/thread/dispatcher.cc | 12 | ||||
-rw-r--r-- | examples/thread/dispatcher2.cc | 14 | ||||
-rw-r--r-- | examples/thread/thread.cc | 2 | ||||
-rw-r--r-- | examples/thread/threadpool.cc | 4 |
4 files changed, 16 insertions, 16 deletions
diff --git a/examples/thread/dispatcher.cc b/examples/thread/dispatcher.cc index 21833e7f..e58cb227 100644 --- a/examples/thread/dispatcher.cc +++ b/examples/thread/dispatcher.cc @@ -29,7 +29,7 @@ namespace class ThreadProgress { public: - explicit ThreadProgress(int id); + explicit ThreadProgress(int the_id); virtual ~ThreadProgress(); int id() const; @@ -78,10 +78,10 @@ public: void operator()(T ptr) const { delete ptr; } }; -ThreadProgress::ThreadProgress(int id) +ThreadProgress::ThreadProgress(int the_id) : - thread_ (0), - id_ (id), + thread_ (nullptr), + id_ (the_id), progress_ (0) { // Connect to the cross-thread signal. @@ -91,7 +91,7 @@ ThreadProgress::ThreadProgress(int id) ThreadProgress::~ThreadProgress() { // It is an error if the thread is still running at this point. - g_return_if_fail(thread_ == 0); + g_return_if_fail(thread_ == nullptr); } int ThreadProgress::id() const @@ -134,7 +134,7 @@ void ThreadProgress::thread_function() { Glib::Rand rand; - for (int i = 0; i < ITERATIONS; ++i) + for (auto i = 0; i < ITERATIONS; ++i) { Glib::usleep(rand.get_int_range(2000, 20000)); diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc index dd7d7de8..cd0faf26 100644 --- a/examples/thread/dispatcher2.cc +++ b/examples/thread/dispatcher2.cc @@ -77,7 +77,7 @@ ThreadTimer::ThreadTimer() // Create a new Glib::Dispatcher that is attached to the default main context, signal_increment_ (), // This pointer will be initialized later by the 2nd thread. - signal_finished_ptr_ (NULL) + signal_finished_ptr_ (nullptr) { // Connect the cross-thread signal. signal_increment_.connect(sigc::mem_fun(*this, &ThreadTimer::timer_increment)); @@ -99,7 +99,7 @@ void ThreadTimer::launch() sigc::mem_fun(*this, &ThreadTimer::thread_function)); // Wait for the 2nd thread's startup notification. - while(signal_finished_ptr_ == NULL) + while(!signal_finished_ptr_) startup_cond_.wait(startup_mutex_); } @@ -109,10 +109,10 @@ void ThreadTimer::signal_finished_emit() signal_finished_ptr_->emit(); // wait for the thread to join - if(thread_ != NULL) + if(thread_) thread_->join(); - signal_finished_ptr_ = NULL; + signal_finished_ptr_ = nullptr; } void ThreadTimer::print() const @@ -156,9 +156,9 @@ bool ThreadTimer::timeout_handler() void ThreadTimer::thread_function() { // create a new Main Context - Glib::RefPtr<Glib::MainContext> context = Glib::MainContext::create(); + auto context = Glib::MainContext::create(); // create a new Main Loop - Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(context, true); + auto mainloop = Glib::MainLoop::create(context, true); // attach a timeout handler, that is called every second, to the // newly created MainContext @@ -189,7 +189,7 @@ ThreadTimer::type_signal_end ThreadTimer::signal_end_; ThreadDispatcher::ThreadDispatcher() : - timer_ (NULL) + timer_ (nullptr) { std::cout << "Thread Dispatcher Example #2" << std::endl; diff --git a/examples/thread/thread.cc b/examples/thread/thread.cc index ad7cfebd..6fb546c1 100644 --- a/examples/thread/thread.cc +++ b/examples/thread/thread.cc @@ -36,7 +36,7 @@ void MessageQueue::producer() { Glib::Rand rand (1234); - for(int i = 0; i < 200; ++i) + for(auto i = 0; i < 200; ++i) { { Glib::Threads::Mutex::Lock lock (mutex_); diff --git a/examples/thread/threadpool.cc b/examples/thread/threadpool.cc index 632a77af..557997f4 100644 --- a/examples/thread/threadpool.cc +++ b/examples/thread/threadpool.cc @@ -15,7 +15,7 @@ void print_char(char c) { Glib::Rand rand; - for(int i = 0; i < 100; ++i) + for(auto i = 0; i < 100; ++i) { { Glib::Threads::Mutex::Lock lock (mutex); @@ -33,7 +33,7 @@ int main(int, char**) { Glib::ThreadPool pool (10); - for(char c = 'a'; c <= 'z'; ++c) + for(auto c = 'a'; c <= 'z'; ++c) { pool.push(sigc::bind<1>(sigc::ptr_fun(&print_char), c)); } |