Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the Boost.Random dependency #380

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/Backoff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <time.h> /* time */

#include <algorithm>
#include <boost/random/uniform_int_distribution.hpp>

namespace pulsar {

Expand All @@ -47,7 +46,7 @@ TimeDuration Backoff::next() {
}
}
// Add Randomness
boost::random::uniform_int_distribution<int> dist;
std::uniform_int_distribution<int> dist;
int randomNumber = dist(rng_);

current = current - (current * (randomNumber % 10) / 100);
Expand Down
4 changes: 2 additions & 2 deletions lib/Backoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <pulsar/defines.h>

#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <random>

namespace pulsar {

Expand All @@ -39,7 +39,7 @@ class PULSAR_PUBLIC Backoff {
TimeDuration next_;
TimeDuration mandatoryStop_;
boost::posix_time::ptime firstBackoffTime_;
boost::random::mt19937 rng_;
std::mt19937 rng_;
bool mandatoryStopMade_ = false;

friend class PulsarFriend;
Expand Down
7 changes: 3 additions & 4 deletions lib/RoundRobinMessageRouter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
*/
#include "RoundRobinMessageRouter.h"

#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include <random>

#include "Hash.h"
#include "TimeUtils.h"
Expand All @@ -37,8 +36,8 @@ RoundRobinMessageRouter::RoundRobinMessageRouter(ProducerConfiguration::HashingS
lastPartitionChange_(TimeUtils::currentTimeMillis()),
msgCounter_(0),
cumulativeBatchSize_(0) {
boost::random::mt19937 rng(time(nullptr));
boost::random::uniform_int_distribution<int> dist;
std::mt19937 rng(time(nullptr));
std::uniform_int_distribution<int> dist;
currentPartitionCursor_ = dist(rng);
}

Expand Down
4 changes: 0 additions & 4 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
"name": "boost-property-tree",
"version>=": "1.83.0"
},
{
"name": "boost-random",
"version>=": "1.83.0"
},
{
"name": "boost-serialization",
"version>=": "1.83.0"
Expand Down