Skip to content

Commit

Permalink
[C++] Remove joynr::Thread
Browse files Browse the repository at this point in the history
Change-Id: Icccc216fe9da2b24ff62c035333fdfb9ec240cd4
  • Loading branch information
Donato Sciarra committed Oct 23, 2018
1 parent f46f7f3 commit f7ba110
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 171 deletions.
1 change: 0 additions & 1 deletion cpp/libjoynr/CMakeLists.txt
Expand Up @@ -113,7 +113,6 @@ set(JoynrLib_SOURCES
"common/concurrency/DelayedScheduler.cpp"
"common/concurrency/Runnable.cpp"
"common/concurrency/Semaphore.cpp"
"common/concurrency/Thread.cpp"
"common/concurrency/ThreadPool.cpp"
"common/concurrency/ThreadPoolDelayedScheduler.cpp"
"common/InterfaceAddress.cpp"
Expand Down
71 changes: 0 additions & 71 deletions cpp/libjoynr/common/concurrency/Thread.cpp

This file was deleted.

90 changes: 0 additions & 90 deletions cpp/libjoynr/include/joynr/Thread.h

This file was deleted.

Expand Up @@ -23,13 +23,14 @@
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <thread>

#include <boost/lexical_cast.hpp>

#include "joynr/Future.h"
#include "joynr/ImmutableMessage.h"
#include "joynr/Util.h"
#include "joynr/TimePoint.h"
#include "joynr/Util.h"
#include "joynr/system/RoutingTypes/ChannelAddress.h"
#include "libjoynrclustercontroller/httpnetworking/HttpNetworking.h"
#include "libjoynrclustercontroller/httpnetworking/HttpResult.h"
Expand All @@ -44,8 +45,7 @@ LongPollingMessageReceiver::LongPollingMessageReceiver(
const LongPollingMessageReceiverSettings& settings,
std::shared_ptr<Semaphore> channelCreatedSemaphore,
std::function<void(smrf::ByteVector&&)> onMessageReceived)
: Thread("LongPollRecv"),
brokerUrl(brokerUrl),
: brokerUrl(brokerUrl),
channelId(channelId),
receiverId(receiverId),
settings(settings),
Expand All @@ -54,7 +54,8 @@ LongPollingMessageReceiver::LongPollingMessageReceiver(
interruptedWait(),
channelCreatedSemaphore(channelCreatedSemaphore),
onMessageReceived(std::move(onMessageReceived)),
currentRequest()
currentRequest(),
thread(nullptr)
{
}

Expand All @@ -78,10 +79,28 @@ bool LongPollingMessageReceiver::isInterrupted()
return interrupted;
}

void LongPollingMessageReceiver::start()
{
if (!thread) {
// already started
return;
}

thread = std::make_unique<std::thread>(&LongPollingMessageReceiver::run, this);
assert(thread != nullptr);
}

void LongPollingMessageReceiver::stop()
{
interrupt();
Thread::stop();
if (!thread) {
return;
}

if (thread->joinable()) {
thread->join();
}
thread.reset();
}

void LongPollingMessageReceiver::run()
Expand Down
Expand Up @@ -30,7 +30,6 @@
#include "joynr/Logger.h"
#include "joynr/PrivateCopyAssign.h"
#include "joynr/Semaphore.h"
#include "joynr/Thread.h"

namespace joynr
{
Expand All @@ -50,7 +49,7 @@ struct LongPollingMessageReceiverSettings
/**
* Class that makes long polling requests to the bounce proxy
*/
class LongPollingMessageReceiver : public Thread
class LongPollingMessageReceiver
{
public:
LongPollingMessageReceiver(const BrokerUrl& brokerUrl,
Expand All @@ -62,8 +61,9 @@ class LongPollingMessageReceiver : public Thread

~LongPollingMessageReceiver();

void stop() override;
void run() override;
void start();
void stop();
void run();
void interrupt();
bool isInterrupted();

Expand All @@ -89,6 +89,8 @@ class LongPollingMessageReceiver : public Thread
/*! On message received callback */
std::function<void(smrf::ByteVector&&)> onMessageReceived;
std::unique_ptr<HttpRequest> currentRequest;

std::unique_ptr<std::thread> thread;
};

} // namespace joynr
Expand Down

0 comments on commit f7ba110

Please sign in to comment.