diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-03 14:24:41 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-04 18:15:16 +0000 |
commit | 8946dbea418f760e4f0a5cbe2eb2bcbcddd25032 (patch) | |
tree | fc254ea5dea29ddf6a395b8bcdcb8c7540d22238 /messagebus | |
parent | 7700f411ea6f4a3e7c0599fae239ec84c18c0038 (diff) |
FastOS_THread::Sleep -> std::chrono::sleep_for
Renamed Timer -> ScheduledExecutor.
Do not include thread.h when not needed in header files.
Diffstat (limited to 'messagebus')
10 files changed, 17 insertions, 14 deletions
diff --git a/messagebus/src/tests/context/context.cpp b/messagebus/src/tests/context/context.cpp index de9dd1b83a6..c71357d09ad 100644 --- a/messagebus/src/tests/context/context.cpp +++ b/messagebus/src/tests/context/context.cpp @@ -77,7 +77,7 @@ Test::Main() if (queue.size() == 3) { break; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } EXPECT_EQUAL(queue.size(), 3u); { diff --git a/messagebus/src/tests/loadbalance/loadbalance.cpp b/messagebus/src/tests/loadbalance/loadbalance.cpp index 2f510d98ff1..05ea6d78871 100644 --- a/messagebus/src/tests/loadbalance/loadbalance.cpp +++ b/messagebus/src/tests/loadbalance/loadbalance.cpp @@ -78,7 +78,7 @@ Test::Main() if (queue.size() == msgCnt) { break; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } EXPECT_TRUE(queue.size() == msgCnt); EXPECT_TRUE(h1.cnt == msgCnt / 3); diff --git a/messagebus/src/tests/messagebus/messagebus.cpp b/messagebus/src/tests/messagebus/messagebus.cpp index 7434941a900..d9c6e438523 100644 --- a/messagebus/src/tests/messagebus/messagebus.cpp +++ b/messagebus/src/tests/messagebus/messagebus.cpp @@ -43,7 +43,7 @@ struct Base { if (queue.size() == size) { return true; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } return false; } @@ -270,7 +270,7 @@ Test::testSendToCol() } } client->waitQueueSize(300); - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); client->waitQueueSize(300); while (client->queue.size() > 0) { Routable::UP reply = client->queue.dequeue(0); @@ -347,7 +347,7 @@ Test::testSendToAnyThenCol() } } client->waitQueueSize(300); - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); client->waitQueueSize(300); while (client->queue.size() > 0) { Routable::UP reply = client->queue.dequeue(0); diff --git a/messagebus/src/tests/messageordering/messageordering.cpp b/messagebus/src/tests/messageordering/messageordering.cpp index 520c3d3dea3..481b8bbd270 100644 --- a/messagebus/src/tests/messageordering/messageordering.cpp +++ b/messagebus/src/tests/messageordering/messageordering.cpp @@ -167,7 +167,7 @@ Test::Main() const int messageCount = 5000; for (int i = 0; i < messageCount; ++i) { vespalib::string str(vespalib::make_string("%d", i)); - //FastOS_Thread::Sleep(1); + //std::this_thread::sleep_for(1ms); auto msg = std::make_unique<SimpleMessage>(str, true, commonMessageId); msg->getTrace().setLevel(9); //LOG(debug, "Sending message %p for %d", msg.get(), i); diff --git a/messagebus/src/tests/serviceaddress/serviceaddress.cpp b/messagebus/src/tests/serviceaddress/serviceaddress.cpp index ac43cec3c02..441da5a80ac 100644 --- a/messagebus/src/tests/serviceaddress/serviceaddress.cpp +++ b/messagebus/src/tests/serviceaddress/serviceaddress.cpp @@ -82,7 +82,7 @@ Test::waitSlobrok(RPCNetwork &network, const string &pattern, size_t num) if (res.size() == num) { return true; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } return false; } diff --git a/messagebus/src/tests/slobrok/slobrok.cpp b/messagebus/src/tests/slobrok/slobrok.cpp index 7e0718283a6..439ee0b23b5 100644 --- a/messagebus/src/tests/slobrok/slobrok.cpp +++ b/messagebus/src/tests/slobrok/slobrok.cpp @@ -51,7 +51,7 @@ compare(const IMirrorAPI &api, const string &pattern, SpecList expect) if (actual == expect) { return true; } - FastOS_Thread::Sleep(100); + std::this_thread::sleep_for(100ms); } return false; } diff --git a/messagebus/src/tests/sourcesession/sourcesession.cpp b/messagebus/src/tests/sourcesession/sourcesession.cpp index 5177cf0e799..de04715a060 100644 --- a/messagebus/src/tests/sourcesession/sourcesession.cpp +++ b/messagebus/src/tests/sourcesession/sourcesession.cpp @@ -35,7 +35,7 @@ struct DelayedHandler : public IMessageHandler // this will block the transport thread in the server messagebus, // but that should be ok, as we only want to test the timing in the // client messagebus... - FastOS_Thread::Sleep(delay); + std::this_thread::sleep_for(std::chrono::milliseconds(delay)); session->acknowledge(std::move(msg)); } }; @@ -59,7 +59,7 @@ bool waitQueueSize(RoutableQueue &queue, uint32_t size) { if (queue.size() == size) { return true; } - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } return false; } @@ -99,7 +99,7 @@ Test::testSequencing() EXPECT_TRUE(ss->send(Message::UP(new SimpleMessage("foo", true, 2)), "dst").isAccepted()); EXPECT_TRUE(ss->send(Message::UP(new SimpleMessage("foo", true, 1)), "dst").isAccepted()); EXPECT_TRUE(waitQueueSize(dstQ, 2)); - FastOS_Thread::Sleep(250); + std::this_thread::sleep_for(250ms); EXPECT_TRUE(waitQueueSize(dstQ, 2)); EXPECT_TRUE(waitQueueSize(srcQ, 0)); ds->acknowledge(Message::UP((Message*)dstQ.dequeue(0).release())); diff --git a/messagebus/src/tests/throttling/throttling.cpp b/messagebus/src/tests/throttling/throttling.cpp index 5d3525e8ba6..76bba89b72d 100644 --- a/messagebus/src/tests/throttling/throttling.cpp +++ b/messagebus/src/tests/throttling/throttling.cpp @@ -51,7 +51,7 @@ bool waitQueueSize(RoutableQueue &queue, uint32_t size) if (queue.size() == size) { return true; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } return false; } @@ -62,7 +62,7 @@ bool waitPending(SourceSession& session, uint32_t size) if (session.getPendingCount() == size) { return true; } - FastOS_Thread::Sleep(1); + std::this_thread::sleep_for(1ms); } return false; } diff --git a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp index 5ae6b07c3fa..280250a5119 100644 --- a/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp +++ b/messagebus/src/vespa/messagebus/network/rpcnetwork.cpp @@ -17,6 +17,7 @@ #include <vespa/fnet/scheduler.h> #include <vespa/fnet/transport.h> #include <vespa/fnet/frt/supervisor.h> +#include <vespa/fastos/thread.h> #include <thread> #include <vespa/log/log.h> diff --git a/messagebus/src/vespa/messagebus/testlib/testserver.cpp b/messagebus/src/vespa/messagebus/testlib/testserver.cpp index bbd23d52c0b..e0c6d6a756d 100644 --- a/messagebus/src/vespa/messagebus/testlib/testserver.cpp +++ b/messagebus/src/vespa/messagebus/testlib/testserver.cpp @@ -4,6 +4,8 @@ #include "slobrok.h" #include "slobrokstate.h" #include <vespa/vespalib/component/vtag.h> +#include <vespa/vespalib/util/time.h> +#include <thread> namespace mbus { @@ -59,7 +61,7 @@ TestServer::waitState(const SlobrokState &slobrokState) if (done) { return true; } - FastOS_Thread::Sleep(10); + std::this_thread::sleep_for(10ms); } return false; } |