summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-08-10 11:11:50 +0100
committerNick Dedekind <nicholas.dedekind@gmail.com>2012-08-10 11:11:50 +0100
commit67afba9fb1e1db24d17f30e2af094613ab283f08 (patch)
treee0545d7a81251f94ccf938a724044ba4e489a632 /unity-shared
parentab02de632756e0f264469efb7f1b7f4755fa109a (diff)
Switched thumbnail generation idle sources to timers
(bzr r2419.4.58)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/ThumbnailGenerator.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/unity-shared/ThumbnailGenerator.cpp b/unity-shared/ThumbnailGenerator.cpp
index e94d0d5af..0245f5f03 100644
--- a/unity-shared/ThumbnailGenerator.cpp
+++ b/unity-shared/ThumbnailGenerator.cpp
@@ -119,8 +119,8 @@ private:
private:
ThumbnailGenerator* parent_;
- glib::Source::UniquePtr idle_;
- glib::Source::UniquePtr idle_return_;
+ glib::Source::UniquePtr thread_create_timer_;
+ glib::Source::UniquePtr thread_return_timer_;
/* Our mutex used when accessing data shared between the main thread and the
thumbnail thread, i.e. the thumbnail_thread_is_running flag and the
@@ -179,9 +179,9 @@ ThumbnailNotifier::Ptr ThumbnailGeneratorImpl::GetThumbnail(std::string const& u
complete_thumbnails_.push_back(complete_thumb);
// Delay the thumbnail update until after this method has returned with the notifier
- if (!idle_return_)
+ if (!thread_return_timer_)
{
- idle_return_.reset(new glib::Idle(sigc::mem_fun(this, &ThumbnailGeneratorImpl::OnThumbnailComplete), glib::Source::Priority::LOW));
+ thread_return_timer_.reset(new glib::Timeout(0, sigc::mem_fun(this, &ThumbnailGeneratorImpl::OnThumbnailComplete), glib::Source::Priority::LOW));
}
pthread_mutex_unlock (&thumbnails_mutex_);
@@ -196,13 +196,14 @@ ThumbnailNotifier::Ptr ThumbnailGeneratorImpl::GetThumbnail(std::string const& u
* MUTEX LOCKED
*********************************/
- if (!idle_ && thumbnail_thread_is_running_ == false)
+ if (!thread_create_timer_ && thumbnail_thread_is_running_ == false)
{
- idle_.reset(new glib::Idle([&]()
+
+ thread_create_timer_.reset(new glib::Timeout(0, [&]()
{
thumbnail_thread_is_running_ = true;
pthread_create (&thumbnail_thread_, NULL, thumbnail_thread_start, this);
- idle_.reset();
+ thread_create_timer_.reset();
return false;
}, glib::Source::Priority::LOW));
}
@@ -271,9 +272,9 @@ void ThumbnailGeneratorImpl::RunGenerate()
complete_thumbnails_.push_back(complete_thumb);
- if (!idle_return_)
+ if (!thread_return_timer_)
{
- idle_return_.reset(new glib::Idle(sigc::mem_fun(this, &ThumbnailGeneratorImpl::OnThumbnailComplete), glib::Source::Priority::LOW));
+ thread_return_timer_.reset(new glib::Timeout(0, sigc::mem_fun(this, &ThumbnailGeneratorImpl::OnThumbnailComplete), glib::Source::Priority::LOW));
}
pthread_mutex_unlock (&thumbnails_mutex_);
@@ -291,7 +292,7 @@ bool ThumbnailGeneratorImpl::OnThumbnailComplete()
if (complete_thumbnails_.size() == 0)
{
- idle_return_.reset();
+ thread_return_timer_.reset();
pthread_mutex_unlock (&thumbnails_mutex_);
return false;
}