Changeset - 9b97425c18ce
[Not reviewed]
0 1 0
HanzZ - 14 years ago 2011-10-11 00:34:38
hanzz.k@gmail.com
Debug for event loop
1 file changed with 7 insertions and 0 deletions:
0 comments (0 inline, 0 general)
backends/libpurple/spectrumeventloop.cpp
Show inline comments
 
@@ -18,32 +18,38 @@
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 
 */
 

	
 
#include "spectrumeventloop.h"
 
#include "purple.h"
 

	
 
#include <iostream>
 

	
 
#ifdef WITH_LIBEVENT
 
#include <event.h>
 
#endif
 

	
 
#include "log4cxx/logger.h"
 

	
 
using namespace log4cxx;
 

	
 
static LoggerPtr logger = Logger::getLogger("SpectrumEventLoop");
 

	
 
using namespace Swift;
 

	
 
static SpectrumEventLoop *loop;
 

	
 
// Fires the event's callback and frees the event
 
static gboolean processEvent(void *data) {
 
	Event *ev = (Event *) data;
 
	LOG4CXX_INFO(logger, "got event in main thread " << ev);
 
	loop->handle(ev);
 
	return FALSE;
 
}
 

	
 
SpectrumEventLoop::SpectrumEventLoop() : m_isRunning(false) {
 
	m_loop = NULL;
 
	loop = this;
 
	if (true) {
 
		m_loop = g_main_loop_new(NULL, FALSE);
 
	}
 
#ifdef WITH_LIBEVENT
 
	else {
 
@@ -84,14 +90,15 @@ void SpectrumEventLoop::stop() {
 
		m_loop = NULL;
 
	}
 
#ifdef WITH_LIBEVENT
 
	else {
 
		event_loopexit(NULL);
 
	}
 
#endif
 
}
 

	
 
void SpectrumEventLoop::post(const Event& event) {
 
	// pass copy of event to main thread
 
	Event *ev = new Event(event);
 
	LOG4CXX_INFO(logger, "posting event to main thread " << ev);
 
	purple_timeout_add(0, processEvent, ev);
 
}
0 comments (0 inline, 0 general)