summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-27 19:06:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-27 19:07:55 (GMT)
commit6810a2896f27e7ee07aee847f5e8dbccd1f6ec89 (patch)
treef7ea87f030e57cb4494a4f897506fb18fc3d2241 /Swiften/Network/BoostConnection.cpp
parenta7da393cfc807048d320ddba8a1c7d24ef23a46e (diff)
downloadswift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.zip
swift-contrib-6810a2896f27e7ee07aee847f5e8dbccd1f6ec89.tar.bz2
Remove MainEventLoop singleton.
The event loop now needs to be explicitly passed to clients using it.
Diffstat (limited to 'Swiften/Network/BoostConnection.cpp')
-rw-r--r--Swiften/Network/BoostConnection.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp
index 8cd19f2..6ec8460 100644
--- a/Swiften/Network/BoostConnection.cpp
+++ b/Swiften/Network/BoostConnection.cpp
@@ -10,7 +10,7 @@
#include <boost/bind.hpp>
#include <boost/thread.hpp>
-#include "Swiften/EventLoop/MainEventLoop.h"
+#include "Swiften/EventLoop/EventLoop.h"
#include "Swiften/Base/String.h"
#include "Swiften/Base/ByteArray.h"
#include "Swiften/Network/HostAddressPort.h"
@@ -42,8 +42,8 @@ class SharedBuffer {
// -----------------------------------------------------------------------------
-BoostConnection::BoostConnection(boost::asio::io_service* ioService) :
- socket_(*ioService), readBuffer_(BUFFER_SIZE) {
+BoostConnection::BoostConnection(boost::asio::io_service* ioService, EventLoop* eventLoop) :
+ eventLoop(eventLoop), socket_(*ioService), readBuffer_(BUFFER_SIZE) {
}
BoostConnection::~BoostConnection() {
@@ -73,11 +73,11 @@ void BoostConnection::write(const ByteArray& data) {
void BoostConnection::handleConnectFinished(const boost::system::error_code& error) {
if (!error) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), false), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), false), shared_from_this());
doRead();
}
else if (error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), true), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onConnectFinished), true), shared_from_this());
}
}
@@ -89,26 +89,26 @@ void BoostConnection::doRead() {
void BoostConnection::handleSocketRead(const boost::system::error_code& error, size_t bytesTransferred) {
if (!error) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDataRead), ByteArray(&readBuffer_[0], bytesTransferred)), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onDataRead), ByteArray(&readBuffer_[0], bytesTransferred)), shared_from_this());
doRead();
}
else if (error == boost::asio::error::eof) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
}
else if (error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), ReadError), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), ReadError), shared_from_this());
}
}
void BoostConnection::handleDataWritten(const boost::system::error_code& error) {
if (!error) {
- MainEventLoop::postEvent(boost::ref(onDataWritten), shared_from_this());
+ eventLoop->postEvent(boost::ref(onDataWritten), shared_from_this());
}
if (error == boost::asio::error::eof) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), boost::optional<Error>()), shared_from_this());
}
else if (error && error != boost::asio::error::operation_aborted) {
- MainEventLoop::postEvent(boost::bind(boost::ref(onDisconnected), WriteError), shared_from_this());
+ eventLoop->postEvent(boost::bind(boost::ref(onDisconnected), WriteError), shared_from_this());
}
}