git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Automatic message catalog update
[enigma2.git]
/
lib
/
base
/
thread.cpp
diff --git
a/lib/base/thread.cpp
b/lib/base/thread.cpp
index 8dded28ab9de8dc4474bd9c11ba60c452534153b..fa923debe3ddf08aed24ec059b663a1b7486e071 100644
(file)
--- a/
lib/base/thread.cpp
+++ b/
lib/base/thread.cpp
@@
-9,12
+9,9
@@
void eThread::thread_completed(void *ptr)
eThread *p = (eThread*) ptr;
p->m_alive = 0;
eThread *p = (eThread*) ptr;
p->m_alive = 0;
- /* recover state */
- if (!p->m_state.value())
- {
- p->m_state.up();
- assert(p->m_state.value() == 1);
- }
+ /* recover state in case thread was cancelled before calling hasStarted */
+ if (!p->m_started)
+ p->hasStarted();
p->thread_finished();
}
p->thread_finished();
}
@@
-42,11
+39,13
@@
int eThread::runAsync(int prio, int policy)
return -1;
eDebug("after: %d", m_state.value());
return -1;
eDebug("after: %d", m_state.value());
-
assert
(m_state.value() == 1); /* sync postconditions */
-
assert
(!m_alive);
+
ASSERT
(m_state.value() == 1); /* sync postconditions */
+
ASSERT
(!m_alive);
m_state.down();
m_state.down();
+ ASSERT(m_state.value() == 0);
m_alive = 1;
m_alive = 1;
+ m_started = 0;
/* start thread. */
pthread_attr_t attr;
/* start thread. */
pthread_attr_t attr;
@@
-88,19
+87,23
@@
eThread::~eThread()
int eThread::sync(void)
{
int res;
int eThread::sync(void)
{
int res;
+ int debug_val_before = m_state.value();
m_state.down(); /* this might block */
res = m_alive;
m_state.down(); /* this might block */
res = m_alive;
- assert(m_state.value() == 0);
+ if (m_state.value() != 0)
+ eFatal("eThread::sync: m_state.value() == %d - was %d before", m_state.value(), debug_val_before);
+ ASSERT(m_state.value() == 0);
m_state.up();
return res; /* 0: thread is guaranteed not to run. 1: state unknown. */
}
m_state.up();
return res; /* 0: thread is guaranteed not to run. 1: state unknown. */
}
-
void
eThread::sendSignal(int sig)
+
int
eThread::sendSignal(int sig)
{
if (m_alive)
{
if (m_alive)
- pthread_kill(the_thread, sig);
+
return
pthread_kill(the_thread, sig);
else
eDebug("send signal to non running thread");
else
eDebug("send signal to non running thread");
+ return -1;
}
void eThread::kill(bool sendcancel)
}
void eThread::kill(bool sendcancel)
@@
-119,6
+122,7
@@
void eThread::kill(bool sendcancel)
void eThread::hasStarted()
{
void eThread::hasStarted()
{
- assert(!m_state.value());
+ ASSERT(!m_state.value());
+ m_started = 1;
m_state.up();
}
m_state.up();
}