summaryrefslogtreecommitdiffstats
path: root/gui/action.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2015-01-09 22:52:51 +0100
committerthat <github@that.at>2015-01-09 22:52:51 +0100
commit7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d (patch)
tree44d371177bd9da4d42b7b87833527b75afe83c5e /gui/action.cpp
parentRun some actions in a separate thread (diff)
downloadandroid_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar.gz
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar.bz2
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar.lz
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar.xz
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.tar.zst
android_bootable_recovery-7d3b54f3c23b28c28f0b8dfc9b3e73ef344e772d.zip
Diffstat (limited to 'gui/action.cpp')
-rw-r--r--gui/action.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/gui/action.cpp b/gui/action.cpp
index d54ea0a03..750d73b8d 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -98,18 +98,18 @@ ActionThread::~ActionThread()
pthread_mutex_destroy(&m_act_lock);
}
-void ActionThread::threadActions(GUIAction *act, size_t start_index)
+void ActionThread::threadActions(GUIAction *act)
{
pthread_mutex_lock(&m_act_lock);
if (m_thread_running) {
pthread_mutex_unlock(&m_act_lock);
- LOGERR("Another threaded action is already running -- not running actions '%s' and following\n", act->mActions[start_index].mFunction.c_str());
+ LOGERR("Another threaded action is already running -- not running %u actions starting with '%s'\n",
+ act->mActions.size(), act->mActions[0].mFunction.c_str());
} else {
m_thread_running = true;
pthread_mutex_unlock(&m_act_lock);
ThreadData *d = new ThreadData;
d->act = act;
- d->start_index = start_index;
pthread_create(&m_thread, NULL, &ActionThread_work_wrapper, d);
}
@@ -121,7 +121,7 @@ void ActionThread::run(void *data)
GUIAction* act = d->act;
std::vector<GUIAction::Action>::iterator it;
- for (it = act->mActions.begin() + d->start_index; it != act->mActions.end(); ++it)
+ for (it = act->mActions.begin(); it != act->mActions.end(); ++it)
act->doAction(*it);
pthread_mutex_lock(&m_act_lock);
@@ -380,18 +380,24 @@ int GUIAction::doActions()
if (mActions.size() < 1)
return -1;
+ bool needThread = false;
std::vector<Action>::iterator it;
for (it = mActions.begin(); it != mActions.end(); ++it)
{
if (needsToRunInSeparateThread(*it))
{
- // run all remaining actions in a separate thread
- action_thread.threadActions(this, it - mActions.begin());
- // ...and we're done here
+ needThread = true;
break;
}
-
- doAction(*it);
+ }
+ if (needThread)
+ {
+ action_thread.threadActions(this);
+ }
+ else
+ {
+ for (it = mActions.begin(); it != mActions.end(); ++it)
+ doAction(*it);
}
return 0;