* #18666: eventhread: use pthread instead of cc++/ucommon thread

This commit is contained in:
Tristan Matthews
2012-12-18 15:17:35 -05:00
parent 482e46988e
commit b78fe9b3b2
4 changed files with 32 additions and 8 deletions

View File

@ -31,13 +31,29 @@
#include "eventthread.h"
#include "voiplink.h"
EventThread::EventThread(VoIPLink *link) : ost::Thread(), link_(link)
EventThread::EventThread(VoIPLink *link) : link_(link)
{}
EventThread::~EventThread()
{
pthread_join(thread_, NULL);
}
void EventThread::start()
{
pthread_create(&thread_, NULL, &runCallback, this);
}
void *
EventThread::runCallback(void *data)
{
EventThread *context = static_cast<EventThread*>(data);
context->run();
return NULL;
}
void EventThread::run()
{
while (link_->getEvent())
yield(); // noop
ost::Thread::exit();
pthread_yield();
}

View File

@ -31,25 +31,30 @@
#ifndef EVENT_THREAD_H_
#define EVENT_THREAD_H_
#include "cc_thread.h"
#include "noncopyable.h"
#include <pthread.h>
class VoIPLink;
/**
* @file eventthread.h
* @brief Thread which listens to VoIP events continuously
* @brief Runs thread which listens to VoIP events continuously
*/
class EventThread : public ost::Thread {
class EventThread {
public:
EventThread(VoIPLink* link);
void run();
~EventThread();
// spawns thread
void start();
private:
NON_COPYABLE(EventThread);
// VoIPLink is the object being called by getEvents() method
VoIPLink* link_;
pthread_t thread_;
void run();
static void *runCallback(void *);
};
#endif // EVENT_THREAD_H__

View File

@ -37,6 +37,7 @@
#endif
#include "account.h"
#include "cc_thread.h"
#include "voiplink.h"
#include "audio/codecs/audiocodec.h" // for DEC_BUFFER_SIZE
#include "sfl_types.h"

View File

@ -52,6 +52,8 @@
#include <queue>
#endif
#include "cc_thread.h"
#include "sipaccount.h"
#include "voiplink.h"
#include "siptransport.h"