mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
* #18666: eventhread: use pthread instead of cc++/ucommon thread
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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__
|
||||
|
@ -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"
|
||||
|
@ -52,6 +52,8 @@
|
||||
#include <queue>
|
||||
#endif
|
||||
|
||||
#include "cc_thread.h"
|
||||
|
||||
#include "sipaccount.h"
|
||||
#include "voiplink.h"
|
||||
#include "siptransport.h"
|
||||
|
Reference in New Issue
Block a user