+int eThread::runAsync(int prio, int policy)
+{
+ eDebug("before: %d", m_state.value());
+ /* the thread might already run. */
+ if (sync())
+ return -1;
+
+ eDebug("after: %d", m_state.value());
+ ASSERT(m_state.value() == 1); /* sync postconditions */
+ ASSERT(!m_alive);
+ m_state.down();
+ ASSERT(m_state.value() == 0);
+
+ m_alive = 1;
+ m_started = 0;
+
+ /* start thread. */
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+
+ if (prio || policy)
+ {
+ struct sched_param p;
+ p.__sched_priority=prio;
+ pthread_attr_setschedpolicy(&attr, policy);
+ pthread_attr_setschedparam(&attr, &p);
+ }
+
+ if (pthread_create(&the_thread, &attr, wrapper, this))
+ {
+ pthread_attr_destroy(&attr);
+ m_alive = 0;
+ eDebug("couldn't create new thread");
+ return -1;
+ }
+
+ pthread_attr_destroy(&attr);
+ return 0;
+}
+
+int eThread::run(int prio, int policy)