Skip to content

Commit

Permalink
util: Remove unused Microsleep
Browse files Browse the repository at this point in the history
Adapted from: fae86c3
  • Loading branch information
MarcoFalke authored and xanimo committed Mar 30, 2024
1 parent 2be791a commit 75698c4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 15 deletions.
8 changes: 2 additions & 6 deletions src/test/scheduler_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "random.h"
#include "scheduler.h"
#include "utiltime.h"

#include "test/test_bitcoin.h"

Expand All @@ -27,11 +28,6 @@ static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delt
}
}

static void MicroSleep(uint64_t n)
{
boost::this_thread::sleep_for(boost::chrono::microseconds(n));
}

BOOST_AUTO_TEST_CASE(manythreads)
{
// Stress test: hundreds of microsecond-scheduled tasks,
Expand Down Expand Up @@ -78,7 +74,7 @@ BOOST_AUTO_TEST_CASE(manythreads)
for (int i = 0; i < 5; i++)
microThreads.create_thread(boost::bind(&CScheduler::serviceQueue, &microTasks));

MicroSleep(600);
UninterruptibleSleep(std::chrono::microseconds{600});
now = boost::chrono::system_clock::now();

// More threads and more tasks:
Expand Down
3 changes: 1 addition & 2 deletions src/utiltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <atomic>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
#include <ctime>
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -95,7 +94,7 @@ int64_t GetLogTimeMicros()

void MilliSleep(int64_t n)
{
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
std::this_thread::sleep_for(std::chrono::milliseconds(n));
}

std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
Expand Down
7 changes: 0 additions & 7 deletions src/utiltime.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ int64_t GetTimeMicros();
/** Returns the system time (not mockable) */
int64_t GetSystemTimeInSeconds(); // Like GetTime(), but not mockable

/** For testing. Set e.g. with the setmocktime rpc, or -mocktime argument */
void SetMockTime(int64_t nMockTimeIn);
/** For testing */
int64_t GetMockTime();

void MilliSleep(int64_t n);

/**
* GetTimeMicros() and GetTimeMillis() both return the system time, but in
* different units. GetTime() returns the system time in seconds, but also
Expand Down

0 comments on commit 75698c4

Please sign in to comment.