mirror of https://gitee.com/bigwinds/arangodb
remove TRI_usleep and TRI_sleep, and use std::this_thread::sleep_for … (#3817)
This commit is contained in:
parent
6bdc26e5c9
commit
282be208cc
|
@ -988,7 +988,7 @@ uint64_t AgencyComm::uniqid(uint64_t count, double timeout) {
|
||||||
while (tries++ < maxTries) {
|
while (tries++ < maxTries) {
|
||||||
result = getValues("Sync/LatestID");
|
result = getValues("Sync/LatestID");
|
||||||
if (!result.successful()) {
|
if (!result.successful()) {
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,7 +1024,7 @@ uint64_t AgencyComm::uniqid(uint64_t count, double timeout) {
|
||||||
try {
|
try {
|
||||||
newBuilder.add(VPackValue(newValue));
|
newBuilder.add(VPackValue(newValue));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1189,7 @@ bool AgencyComm::ensureStructureInitialized() {
|
||||||
LOG_TOPIC(WARN, Logger::AGENCYCOMM)
|
LOG_TOPIC(WARN, Logger::AGENCYCOMM)
|
||||||
<< "Initializing agency failed. We'll try again soon";
|
<< "Initializing agency failed. We'll try again soon";
|
||||||
// We should really have exclusive access, here, this is strange!
|
// We should really have exclusive access, here, this is strange!
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
AgencyCommResult result = getValues("InitDone");
|
AgencyCommResult result = getValues("InitDone");
|
||||||
|
@ -1207,7 +1207,7 @@ bool AgencyComm::ensureStructureInitialized() {
|
||||||
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
LOG_TOPIC(TRACE, Logger::AGENCYCOMM)
|
||||||
<< "Waiting for agency to get initialized";
|
<< "Waiting for agency to get initialized";
|
||||||
|
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1248,7 +1248,7 @@ bool AgencyComm::lock(std::string const& key, double ttl, double timeout,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep((TRI_usleep_t) sleepTime);
|
std::this_thread::sleep_for(std::chrono::microseconds(sleepTime));
|
||||||
|
|
||||||
if (sleepTime < MAX_SLEEP_TIME) {
|
if (sleepTime < MAX_SLEEP_TIME) {
|
||||||
sleepTime += INITIAL_SLEEP_TIME;
|
sleepTime += INITIAL_SLEEP_TIME;
|
||||||
|
@ -1289,7 +1289,7 @@ bool AgencyComm::unlock(std::string const& key, VPackSlice const& slice,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep((TRI_usleep_t)sleepTime);
|
std::this_thread::sleep_for(std::chrono::microseconds(sleepTime));
|
||||||
|
|
||||||
if (sleepTime < MAX_SLEEP_TIME) {
|
if (sleepTime < MAX_SLEEP_TIME) {
|
||||||
sleepTime += INITIAL_SLEEP_TIME;
|
sleepTime += INITIAL_SLEEP_TIME;
|
||||||
|
|
|
@ -315,7 +315,7 @@ void AgencyFeature::stop() {
|
||||||
if (_agent->inception() != nullptr) { // can only exist in resilient agents
|
if (_agent->inception() != nullptr) { // can only exist in resilient agents
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (_agent->inception()->isRunning()) {
|
while (_agent->inception()->isRunning()) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
// emit warning after 5 seconds
|
// emit warning after 5 seconds
|
||||||
if (++counter == 10 * 5) {
|
if (++counter == 10 * 5) {
|
||||||
LOG_TOPIC(WARN, Logger::AGENCY) << "waiting for inception thread to finish";
|
LOG_TOPIC(WARN, Logger::AGENCY) << "waiting for inception thread to finish";
|
||||||
|
@ -326,7 +326,7 @@ void AgencyFeature::stop() {
|
||||||
if (_agent != nullptr) {
|
if (_agent != nullptr) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (_agent->isRunning()) {
|
while (_agent->isRunning()) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
// emit warning after 5 seconds
|
// emit warning after 5 seconds
|
||||||
if (++counter == 10 * 5) {
|
if (++counter == 10 * 5) {
|
||||||
LOG_TOPIC(WARN, Logger::AGENCY) << "waiting for agent thread to finish";
|
LOG_TOPIC(WARN, Logger::AGENCY) << "waiting for agent thread to finish";
|
||||||
|
|
|
@ -102,7 +102,7 @@ void Agent::waitForThreadsStop() {
|
||||||
while (_constituent.isRunning() || _compactor.isRunning() ||
|
while (_constituent.isRunning() || _compactor.isRunning() ||
|
||||||
(_config.supervision() && _supervision.isRunning()) ||
|
(_config.supervision() && _supervision.isRunning()) ||
|
||||||
(_inception != nullptr && _inception->isRunning())) {
|
(_inception != nullptr && _inception->isRunning())) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
|
|
||||||
// fail fatally after 5 mins:
|
// fail fatally after 5 mins:
|
||||||
if (++counter >= 10 * 60 * 5) {
|
if (++counter >= 10 * 60 * 5) {
|
||||||
|
|
|
@ -403,7 +403,7 @@ void Inception::reportVersionForEp(std::string const& endpoint, size_t version)
|
||||||
void Inception::run() {
|
void Inception::run() {
|
||||||
while (ServerState::isMaintenance() &&
|
while (ServerState::isMaintenance() &&
|
||||||
!this->isStopping() && !_agent->isStopping()) {
|
!this->isStopping() && !_agent->isStopping()) {
|
||||||
usleep(1000000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1000000));
|
||||||
LOG_TOPIC(DEBUG, Logger::AGENCY)
|
LOG_TOPIC(DEBUG, Logger::AGENCY)
|
||||||
<< "Waiting for RestHandlerFactory to exit maintenance mode before we "
|
<< "Waiting for RestHandlerFactory to exit maintenance mode before we "
|
||||||
" start gossip protocol...";
|
" start gossip protocol...";
|
||||||
|
|
|
@ -89,7 +89,7 @@ Result AqlTransaction::processCollectionNormal(aql::Collection* collection) {
|
||||||
auto startTime = TRI_microtime();
|
auto startTime = TRI_microtime();
|
||||||
auto endTime = startTime + 60.0;
|
auto endTime = startTime + 60.0;
|
||||||
do {
|
do {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
if (TRI_microtime() > endTime) {
|
if (TRI_microtime() > endTime) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ int EnumerateCollectionBlock::initialize() {
|
||||||
if (endTime - now < waitInterval) {
|
if (endTime - now < waitInterval) {
|
||||||
waitInterval = static_cast<unsigned long>(endTime - now);
|
waitInterval = static_cast<unsigned long>(endTime - now);
|
||||||
}
|
}
|
||||||
usleep((TRI_usleep_t)waitInterval);
|
std::this_thread::sleep_for(std::chrono::microseconds(waitInterval));
|
||||||
}
|
}
|
||||||
now = TRI_microtime();
|
now = TRI_microtime();
|
||||||
if (now > endTime) {
|
if (now > endTime) {
|
||||||
|
|
|
@ -1760,7 +1760,7 @@ AqlValue Functions::Sleep(arangodb::aql::Query* query,
|
||||||
double const until = TRI_microtime() + value.toDouble(trx);
|
double const until = TRI_microtime() + value.toDouble(trx);
|
||||||
|
|
||||||
while (TRI_microtime() < until) {
|
while (TRI_microtime() < until) {
|
||||||
usleep(30000);
|
std::this_thread::sleep_for(std::chrono::microseconds(30000));
|
||||||
|
|
||||||
if (query->killed()) {
|
if (query->killed()) {
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED);
|
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED);
|
||||||
|
|
|
@ -681,7 +681,7 @@ bool RestAqlHandler::findQuery(std::string const& idString, Query*& query) {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// we can only get here if the query is currently used by someone
|
// we can only get here if the query is currently used by someone
|
||||||
// else. in this case we sleep for a while and re-try
|
// else. in this case we sleep for a while and re-try
|
||||||
usleep(SingleWaitPeriod);
|
std::this_thread::sleep_for(std::chrono::microseconds(SingleWaitPeriod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -959,11 +959,7 @@ size_t ClusterComm::performRequests(std::vector<ClusterCommRequest>& requests,
|
||||||
// is in flight, this is possible, since we might have scheduled
|
// is in flight, this is possible, since we might have scheduled
|
||||||
// a retry later than now and simply wait till then
|
// a retry later than now and simply wait till then
|
||||||
if (now < actionNeeded) {
|
if (now < actionNeeded) {
|
||||||
#ifdef _WIN32
|
std::this_thread::sleep_for(std::chrono::microseconds((unsigned long long) ((actionNeeded - now) * 1000000.0)));
|
||||||
usleep((unsigned long) ((actionNeeded - now) * 1000000));
|
|
||||||
#else
|
|
||||||
usleep((useconds_t) ((actionNeeded - now) * 1000000));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1259,7 +1255,7 @@ void ClusterCommThread::run() {
|
||||||
_cc->communicator()->abortRequests();
|
_cc->communicator()->abortRequests();
|
||||||
LOG_TOPIC(DEBUG, Logger::CLUSTER) << "waiting for curl to stop remaining handles";
|
LOG_TOPIC(DEBUG, Logger::CLUSTER) << "waiting for curl to stop remaining handles";
|
||||||
while (_cc->communicator()->work_once() > 0) {
|
while (_cc->communicator()->work_once() > 0) {
|
||||||
usleep(10);
|
std::this_thread::sleep_for(std::chrono::microseconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, Logger::CLUSTER) << "stopped ClusterComm thread";
|
LOG_TOPIC(DEBUG, Logger::CLUSTER) << "stopped ClusterComm thread";
|
||||||
|
|
|
@ -348,7 +348,7 @@ void ClusterFeature::prepare() {
|
||||||
LOG_TOPIC(INFO, arangodb::Logger::CLUSTER) << "Found " << DBServers.size() << " DBservers.";
|
LOG_TOPIC(INFO, arangodb::Logger::CLUSTER) << "Found " << DBServers.size() << " DBservers.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ void ClusterFeature::start() {
|
||||||
|
|
||||||
while (!_heartbeatThread->isReady()) {
|
while (!_heartbeatThread->isReady()) {
|
||||||
// wait until heartbeat is ready
|
// wait until heartbeat is ready
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ void ClusterFeature::start() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerState::instance()->setState(ServerState::STATE_SERVING);
|
ServerState::instance()->setState(ServerState::STATE_SERVING);
|
||||||
|
@ -483,7 +483,7 @@ void ClusterFeature::stop() {
|
||||||
if (_heartbeatThread != nullptr) {
|
if (_heartbeatThread != nullptr) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (_heartbeatThread->isRunning()) {
|
while (_heartbeatThread->isRunning()) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
// emit warning after 5 seconds
|
// emit warning after 5 seconds
|
||||||
if (++counter == 10 * 5) {
|
if (++counter == 10 * 5) {
|
||||||
LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish";
|
LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish";
|
||||||
|
@ -510,7 +510,7 @@ void ClusterFeature::unprepare() {
|
||||||
if (_heartbeatThread != nullptr) {
|
if (_heartbeatThread != nullptr) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while (_heartbeatThread->isRunning()) {
|
while (_heartbeatThread->isRunning()) {
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
// emit warning after 5 seconds
|
// emit warning after 5 seconds
|
||||||
if (++counter == 10 * 5) {
|
if (++counter == 10 * 5) {
|
||||||
LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish";
|
LOG_TOPIC(WARN, arangodb::Logger::CLUSTER) << "waiting for heartbeat thread to finish";
|
||||||
|
@ -553,7 +553,7 @@ void ClusterFeature::unprepare() {
|
||||||
comm.sendTransactionWithFailover(unreg, 120.0);
|
comm.sendTransactionWithFailover(unreg, 120.0);
|
||||||
|
|
||||||
while (_heartbeatThread->isRunning()) {
|
while (_heartbeatThread->isRunning()) {
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50000));
|
||||||
}
|
}
|
||||||
|
|
||||||
AgencyCommManager::MANAGER->stop();
|
AgencyCommManager::MANAGER->stop();
|
||||||
|
|
|
@ -2679,7 +2679,7 @@ std::shared_ptr<std::vector<ServerID>> ClusterInfo::getResponsibleServer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++tries >= 2) {
|
if (++tries >= 2) {
|
||||||
|
|
|
@ -168,7 +168,7 @@ void FollowerInfo::add(ServerID const& sid) {
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER) << "FollowerInfo::add, could not read "
|
LOG_TOPIC(ERR, Logger::CLUSTER) << "FollowerInfo::add, could not read "
|
||||||
<< path << " in agency.";
|
<< path << " in agency.";
|
||||||
}
|
}
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
} while (TRI_microtime() < startTime + 30);
|
} while (TRI_microtime() < startTime + 30);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER)
|
LOG_TOPIC(ERR, Logger::CLUSTER)
|
||||||
|
@ -272,7 +272,7 @@ bool FollowerInfo::remove(ServerID const& sid) {
|
||||||
LOG_TOPIC(ERR, Logger::CLUSTER) << "FollowerInfo::remove, could not read "
|
LOG_TOPIC(ERR, Logger::CLUSTER) << "FollowerInfo::remove, could not read "
|
||||||
<< path << " in agency.";
|
<< path << " in agency.";
|
||||||
}
|
}
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
} while (TRI_microtime() < startTime + 30);
|
} while (TRI_microtime() < startTime + 30);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
_followers = _oldFollowers;
|
_followers = _oldFollowers;
|
||||||
|
|
|
@ -195,7 +195,7 @@ void HeartbeatThread::run() {
|
||||||
// startup aborted
|
// startup aborted
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ void HeartbeatThread::runDBServer() {
|
||||||
if (!registered) {
|
if (!registered) {
|
||||||
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
LOG_TOPIC(ERR, Logger::HEARTBEAT)
|
||||||
<< "Couldn't register plan change in agency!";
|
<< "Couldn't register plan change in agency!";
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,10 +456,10 @@ void HeartbeatThread::runSingleServer() {
|
||||||
// like arguments greater than 1000000
|
// like arguments greater than 1000000
|
||||||
while (remain > 0.0) {
|
while (remain > 0.0) {
|
||||||
if (remain >= 0.5) {
|
if (remain >= 0.5) {
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
remain -= 0.5;
|
remain -= 0.5;
|
||||||
} else {
|
} else {
|
||||||
usleep(static_cast<TRI_usleep_t>(remain * 1000.0 * 1000.0));
|
std::this_thread::sleep_for(std::chrono::microseconds(uint64_t(remain * 1000.0 * 1000.0)));
|
||||||
remain = 0.0;
|
remain = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -600,7 +600,7 @@ void HeartbeatThread::runSingleServer() {
|
||||||
<< res.errorMessage();
|
<< res.errorMessage();
|
||||||
}
|
}
|
||||||
// wait for everything to calm down for good measure
|
// wait for everything to calm down for good measure
|
||||||
sleep(10);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (applier->endpoint() != endpoint) {
|
if (applier->endpoint() != endpoint) {
|
||||||
|
@ -910,10 +910,10 @@ void HeartbeatThread::runCoordinator() {
|
||||||
// like arguments greater than 1000000
|
// like arguments greater than 1000000
|
||||||
while (remain > 0.0) {
|
while (remain > 0.0) {
|
||||||
if (remain >= 0.5) {
|
if (remain >= 0.5) {
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
remain -= 0.5;
|
remain -= 0.5;
|
||||||
} else {
|
} else {
|
||||||
usleep((TRI_usleep_t)(remain * 1000.0 * 1000.0));
|
std::this_thread::sleep_for(std::chrono::microseconds(uint64_t(remain * 1000.0 * 1000.0)));
|
||||||
remain = 0.0;
|
remain = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -964,8 +964,8 @@ void HeartbeatThread::dispatchedJobResult(DBServerAgencySyncResult result) {
|
||||||
if (doSleep) {
|
if (doSleep) {
|
||||||
// Sleep a little longer, since this might be due to some synchronisation
|
// Sleep a little longer, since this might be due to some synchronisation
|
||||||
// of shards going on in the background
|
// of shards going on in the background
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
}
|
}
|
||||||
CONDITION_LOCKER(guard, _condition);
|
CONDITION_LOCKER(guard, _condition);
|
||||||
_wasNotified = true;
|
_wasNotified = true;
|
||||||
|
|
|
@ -110,7 +110,7 @@ ClusterSelectivityEstimates::ValueType ClusterSelectivityEstimates::fetch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
now = TRI_microtime();
|
now = TRI_microtime();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,7 @@ static int LookupLocalInfoToId(std::string const& localInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
};
|
};
|
||||||
return TRI_ERROR_CLUSTER_COULD_NOT_DETERMINE_ID;
|
return TRI_ERROR_CLUSTER_COULD_NOT_DETERMINE_ID;
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
|
||||||
if (!result.successful()) {
|
if (!result.successful()) {
|
||||||
LOG_TOPIC(WARN, Logger::CLUSTER) << "Couldn't fetch " << targetIdStr
|
LOG_TOPIC(WARN, Logger::CLUSTER) << "Couldn't fetch " << targetIdStr
|
||||||
<< " and " << targetUrl;
|
<< " and " << targetUrl;
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ bool ServerState::registerAtAgency(AgencyComm& comm,
|
||||||
if (result.successful()) {
|
if (result.successful()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(FATAL, Logger::STARTUP) << "Couldn't register shortname for " << id;
|
LOG_TOPIC(FATAL, Logger::STARTUP) << "Couldn't register shortname for " << id;
|
||||||
|
|
|
@ -113,7 +113,7 @@ void MMFilesCleanupThread::run() {
|
||||||
locker.wait(cleanupInterval());
|
locker.wait(cleanupInterval());
|
||||||
} else {
|
} else {
|
||||||
// prevent busy waiting
|
// prevent busy waiting
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -598,7 +598,7 @@ int MMFilesCollection::close() {
|
||||||
while (_ditches.contains(MMFilesDitch::TRI_DITCH_DATAFILE_DROP) ||
|
while (_ditches.contains(MMFilesDitch::TRI_DITCH_DATAFILE_DROP) ||
|
||||||
_ditches.contains(MMFilesDitch::TRI_DITCH_DATAFILE_RENAME) ||
|
_ditches.contains(MMFilesDitch::TRI_DITCH_DATAFILE_RENAME) ||
|
||||||
_ditches.contains(MMFilesDitch::TRI_DITCH_COMPACTION)) {
|
_ditches.contains(MMFilesDitch::TRI_DITCH_COMPACTION)) {
|
||||||
usleep(20000);
|
std::this_thread::sleep_for(std::chrono::microseconds(20000));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -2552,7 +2552,7 @@ int MMFilesCollection::lockRead(bool useDeadlockDetector, double timeout) {
|
||||||
if (now - startTime < 0.001) {
|
if (now - startTime < 0.001) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} else {
|
} else {
|
||||||
usleep(static_cast<TRI_usleep_t>(waitTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(waitTime));
|
||||||
if (waitTime < 32) {
|
if (waitTime < 32) {
|
||||||
waitTime *= 2;
|
waitTime *= 2;
|
||||||
}
|
}
|
||||||
|
@ -2665,7 +2665,7 @@ int MMFilesCollection::lockWrite(bool useDeadlockDetector, double timeout) {
|
||||||
if (now - startTime < 0.001) {
|
if (now - startTime < 0.001) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} else {
|
} else {
|
||||||
usleep(static_cast<TRI_usleep_t>(waitTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(waitTime));
|
||||||
if (waitTime < 32) {
|
if (waitTime < 32) {
|
||||||
waitTime *= 2;
|
waitTime *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ void MMFilesCollectionExport::run(uint64_t maxWaitTime, size_t limit) {
|
||||||
if (mmColl->isFullyCollected()) {
|
if (mmColl->isFullyCollected()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(SleepTime);
|
std::this_thread::sleep_for(std::chrono::microseconds(SleepTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -997,7 +997,7 @@ int MMFilesCollectorThread::queueOperations(arangodb::MMFilesWalLogfile* logfile
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait outside the mutex for the flag to be cleared
|
// wait outside the mutex for the flag to be cleared
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxNumPendingOperations > 0 &&
|
if (maxNumPendingOperations > 0 &&
|
||||||
|
|
|
@ -970,7 +970,7 @@ void MMFilesCompactorThread::run() {
|
||||||
if (numCompacted > 0) {
|
if (numCompacted > 0) {
|
||||||
// no need to sleep long or go into wait state if we worked.
|
// no need to sleep long or go into wait state if we worked.
|
||||||
// maybe there's still work left
|
// maybe there's still work left
|
||||||
usleep(1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1000));
|
||||||
} else if (state != TRI_vocbase_t::State::SHUTDOWN_COMPACTOR && _vocbase->state() == TRI_vocbase_t::State::NORMAL) {
|
} else if (state != TRI_vocbase_t::State::SHUTDOWN_COMPACTOR && _vocbase->state() == TRI_vocbase_t::State::NORMAL) {
|
||||||
// only sleep while server is still running
|
// only sleep while server is still running
|
||||||
CONDITION_LOCKER(locker, _condition);
|
CONDITION_LOCKER(locker, _condition);
|
||||||
|
|
|
@ -176,14 +176,14 @@ Result MMFilesEngine::dropDatabase(TRI_vocbase_t* database) {
|
||||||
// queued operations, a service which it offers:
|
// queued operations, a service which it offers:
|
||||||
auto callback = [&database]() {
|
auto callback = [&database]() {
|
||||||
database->shutdown();
|
database->shutdown();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
};
|
};
|
||||||
while (
|
while (
|
||||||
!MMFilesLogfileManager::instance()->executeWhileNothingQueued(callback)) {
|
!MMFilesLogfileManager::instance()->executeWhileNothingQueued(callback)) {
|
||||||
LOG_TOPIC(TRACE, Logger::FIXME)
|
LOG_TOPIC(TRACE, Logger::FIXME)
|
||||||
<< "Trying to shutdown dropped database, waiting for phase in which "
|
<< "Trying to shutdown dropped database, waiting for phase in which "
|
||||||
"the collector thread does not have queued operations.";
|
"the collector thread does not have queued operations.";
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
}
|
}
|
||||||
// stop compactor thread
|
// stop compactor thread
|
||||||
shutdownDatabase(database);
|
shutdownDatabase(database);
|
||||||
|
@ -805,7 +805,7 @@ void MMFilesEngine::waitUntilDeletion(TRI_voc_tick_t id, bool force,
|
||||||
}
|
}
|
||||||
|
|
||||||
++iterations;
|
++iterations;
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50000));
|
||||||
}
|
}
|
||||||
|
|
||||||
status = TRI_ERROR_NO_ERROR;
|
status = TRI_ERROR_NO_ERROR;
|
||||||
|
@ -2675,7 +2675,7 @@ int MMFilesEngine::stopCleanup(TRI_vocbase_t* vocbase) {
|
||||||
thread->signal();
|
thread->signal();
|
||||||
|
|
||||||
while (thread->isRunning()) {
|
while (thread->isRunning()) {
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
@ -2757,7 +2757,7 @@ int MMFilesEngine::stopCompactor(TRI_vocbase_t* vocbase) {
|
||||||
thread->signal();
|
thread->signal();
|
||||||
|
|
||||||
while (thread->isRunning()) {
|
while (thread->isRunning()) {
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRI_ERROR_NO_ERROR;
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
|
|
@ -493,7 +493,7 @@ void MMFilesLogfileManager::unprepare() {
|
||||||
if (_allocatorThread != nullptr) {
|
if (_allocatorThread != nullptr) {
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping allocator thread";
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping allocator thread";
|
||||||
while (_allocatorThread->isRunning()) {
|
while (_allocatorThread->isRunning()) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
delete _allocatorThread;
|
delete _allocatorThread;
|
||||||
_allocatorThread = nullptr;
|
_allocatorThread = nullptr;
|
||||||
|
@ -514,7 +514,7 @@ void MMFilesLogfileManager::unprepare() {
|
||||||
if (_removerThread != nullptr) {
|
if (_removerThread != nullptr) {
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping remover thread";
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping remover thread";
|
||||||
while (_removerThread->isRunning()) {
|
while (_removerThread->isRunning()) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
delete _removerThread;
|
delete _removerThread;
|
||||||
_removerThread = nullptr;
|
_removerThread = nullptr;
|
||||||
|
@ -528,7 +528,7 @@ void MMFilesLogfileManager::unprepare() {
|
||||||
_collectorThread->forceStop();
|
_collectorThread->forceStop();
|
||||||
while (_collectorThread->isRunning()) {
|
while (_collectorThread->isRunning()) {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
locker.lock();
|
locker.lock();
|
||||||
}
|
}
|
||||||
delete _collectorThread;
|
delete _collectorThread;
|
||||||
|
@ -539,7 +539,7 @@ void MMFilesLogfileManager::unprepare() {
|
||||||
if (_synchronizerThread != nullptr) {
|
if (_synchronizerThread != nullptr) {
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping synchronizer thread";
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "stopping synchronizer thread";
|
||||||
while (_synchronizerThread->isRunning()) {
|
while (_synchronizerThread->isRunning()) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
delete _synchronizerThread;
|
delete _synchronizerThread;
|
||||||
_synchronizerThread = nullptr;
|
_synchronizerThread = nullptr;
|
||||||
|
@ -819,7 +819,7 @@ int MMFilesLogfileManager::waitForCollectorQueue(TRI_voc_cid_t cid, double timeo
|
||||||
|
|
||||||
// sleep without holding the lock
|
// sleep without holding the lock
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
|
|
||||||
if (TRI_microtime() > end) {
|
if (TRI_microtime() > end) {
|
||||||
return TRI_ERROR_LOCKED;
|
return TRI_ERROR_LOCKED;
|
||||||
|
@ -932,7 +932,7 @@ bool MMFilesLogfileManager::waitForSync(double maxWait) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// not everything was committed yet. wait a bit
|
// not everything was committed yet. wait a bit
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
|
|
||||||
if (TRI_microtime() >= end) {
|
if (TRI_microtime() >= end) {
|
||||||
// time's up!
|
// time's up!
|
||||||
|
@ -1593,7 +1593,7 @@ MMFilesLogfileManagerState MMFilesLogfileManager::state() {
|
||||||
if (application_features::ApplicationServer::isStopping()) {
|
if (application_features::ApplicationServer::isStopping()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
TRI_ASSERT(state.lastCommittedTick > 0);
|
TRI_ASSERT(state.lastCommittedTick > 0);
|
||||||
|
|
||||||
|
@ -1691,7 +1691,7 @@ void MMFilesLogfileManager::waitForCollector() {
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "waiting for WAL collector";
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "waiting for WAL collector";
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1752,7 +1752,7 @@ int MMFilesLogfileManager::waitForCollector(MMFilesWalLogfile::IdType logfileId,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(20000);
|
std::this_thread::sleep_for(std::chrono::microseconds(20000));
|
||||||
// try again
|
// try again
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2041,7 +2041,7 @@ void MMFilesLogfileManager::stopMMFilesCollectorThread() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50000));
|
||||||
}
|
}
|
||||||
|
|
||||||
_collectorThread->beginShutdown();
|
_collectorThread->beginShutdown();
|
||||||
|
|
|
@ -95,7 +95,7 @@ Result MMFilesTransactionState::beginTransaction(transaction::Hints hints) {
|
||||||
return TRI_ERROR_ARANGO_WRITE_THROTTLE_TIMEOUT;
|
return TRI_ERROR_ARANGO_WRITE_THROTTLE_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(WaitTime);
|
std::this_thread::sleep_for(std::chrono::microseconds(WaitTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ MMFilesWalSlotInfo MMFilesWalSlots::nextUnused(TRI_voc_tick_t databaseId, TRI_vo
|
||||||
return MMFilesWalSlotInfo(res);
|
return MMFilesWalSlotInfo(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
// try again in next iteration
|
// try again in next iteration
|
||||||
} else {
|
} else {
|
||||||
TRI_ASSERT(_logfile != nullptr);
|
TRI_ASSERT(_logfile != nullptr);
|
||||||
|
@ -578,7 +578,7 @@ int MMFilesWalSlots::closeLogfile(MMFilesWalSlot::TickType& lastCommittedTick, b
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
// try again in next iteration
|
// try again in next iteration
|
||||||
} else {
|
} else {
|
||||||
TRI_ASSERT(_logfile != nullptr);
|
TRI_ASSERT(_logfile != nullptr);
|
||||||
|
|
|
@ -79,7 +79,7 @@ GraphStore<V, E>::GraphStore(TRI_vocbase_t* vb, GraphFormat<V, E>* graphFormat)
|
||||||
template <typename V, typename E>
|
template <typename V, typename E>
|
||||||
GraphStore<V, E>::~GraphStore() {
|
GraphStore<V, E>::~GraphStore() {
|
||||||
_destroyed = true;
|
_destroyed = true;
|
||||||
usleep(25 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(25 * 1000));
|
||||||
delete _vertexData;
|
delete _vertexData;
|
||||||
delete _edges;
|
delete _edges;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ void GraphStore<V, E>::loadShards(WorkerConfig* config,
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_runningThreads > 0) {
|
while (_runningThreads > 0) {
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scheduler->post(callback);
|
scheduler->post(callback);
|
||||||
|
|
|
@ -140,7 +140,7 @@ void ArrayInCache<M>::mergeCache(WorkerConfig const& config,
|
||||||
TRY_MUTEX_LOCKER(guard, this->_bucketLocker[shardId]);
|
TRY_MUTEX_LOCKER(guard, this->_bucketLocker[shardId]);
|
||||||
if (guard.isLocked() == false) {
|
if (guard.isLocked() == false) {
|
||||||
if (i == 0) { // eventually we hit the last one
|
if (i == 0) { // eventually we hit the last one
|
||||||
usleep(100); // don't busy wait
|
std::this_thread::sleep_for(std::chrono::microseconds(100)); // don't busy wait
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ void CombiningInCache<M>::mergeCache(WorkerConfig const& config,
|
||||||
TRY_MUTEX_LOCKER(guard, this->_bucketLocker[shardId]);
|
TRY_MUTEX_LOCKER(guard, this->_bucketLocker[shardId]);
|
||||||
if (guard.isLocked() == false) {
|
if (guard.isLocked() == false) {
|
||||||
if (i == 0) { // eventually we hit the last one
|
if (i == 0) { // eventually we hit the last one
|
||||||
usleep(100); // don't busy wait
|
std::this_thread::sleep_for(std::chrono::microseconds(100)); // don't busy wait
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ void PregelFeature::cleanupAll() {
|
||||||
for (auto it : _workers) {
|
for (auto it : _workers) {
|
||||||
it.second->cancelGlobalStep(VPackSlice());
|
it.second->cancelGlobalStep(VPackSlice());
|
||||||
}
|
}
|
||||||
usleep(1000 * 100); // 100ms to send out cancel calls
|
std::this_thread::sleep_for(std::chrono::microseconds(1000 * 100)); // 100ms to send out cancel calls
|
||||||
_workers.clear();
|
_workers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ void RecoveryManager::_renewPrimaryServer(ShardID const& shard) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usleep(100000); // 100ms
|
std::this_thread::sleep_for(std::chrono::microseconds(100000)); // 100ms
|
||||||
tries++;
|
tries++;
|
||||||
} while (tries < 3);
|
} while (tries < 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ template <typename V, typename E, typename M>
|
||||||
Worker<V, E, M>::~Worker() {
|
Worker<V, E, M>::~Worker() {
|
||||||
LOG_TOPIC(DEBUG, Logger::PREGEL) << "Called ~Worker()";
|
LOG_TOPIC(DEBUG, Logger::PREGEL) << "Called ~Worker()";
|
||||||
_state = WorkerState::DONE;
|
_state = WorkerState::DONE;
|
||||||
usleep(50000); // 50ms wait for threads to die
|
std::this_thread::sleep_for(std::chrono::microseconds(50000)); // 50ms wait for threads to die
|
||||||
delete _readCache;
|
delete _readCache;
|
||||||
delete _writeCache;
|
delete _writeCache;
|
||||||
delete _writeCacheNextGSS;
|
delete _writeCacheNextGSS;
|
||||||
|
|
|
@ -176,7 +176,7 @@ void ReplicationApplier::start(TRI_voc_tick_t initialTick, bool useTick, TRI_voc
|
||||||
while (_state.isShuttingDown()) {
|
while (_state.isShuttingDown()) {
|
||||||
// another instance is still around
|
// another instance is still around
|
||||||
writeLocker.unlock();
|
writeLocker.unlock();
|
||||||
usleep(50 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50 * 1000));
|
||||||
writeLocker.lock();
|
writeLocker.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ void ReplicationApplier::start(TRI_voc_tick_t initialTick, bool useTick, TRI_voc
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!_thread->hasStarted()) {
|
while (!_thread->hasStarted()) {
|
||||||
usleep(20000);
|
std::this_thread::sleep_for(std::chrono::microseconds(20000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(!_state.isRunning() && !_state.isShuttingDown());
|
TRI_ASSERT(!_state.isRunning() && !_state.isShuttingDown());
|
||||||
|
@ -257,7 +257,7 @@ bool ReplicationApplier::sleepIfStillActive(uint64_t sleepTime) {
|
||||||
if (sleepChunk > sleepTime) {
|
if (sleepChunk > sleepTime) {
|
||||||
sleepChunk = sleepTime;
|
sleepChunk = sleepTime;
|
||||||
}
|
}
|
||||||
usleep(static_cast<TRI_usleep_t>(sleepChunk));
|
std::this_thread::sleep_for(std::chrono::microseconds(sleepChunk));
|
||||||
sleepTime -= sleepChunk;
|
sleepTime -= sleepChunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ void ReplicationApplier::doStop(Result const& r, bool joinThread) {
|
||||||
if (joinThread) {
|
if (joinThread) {
|
||||||
while (_state.isShuttingDown()) {
|
while (_state.isShuttingDown()) {
|
||||||
writeLocker.unlock();
|
writeLocker.unlock();
|
||||||
usleep(50 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50 * 1000));
|
||||||
writeLocker.lock();
|
writeLocker.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ Result Syncer::applyCollectionDumpMarker(
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(50000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50000));
|
||||||
// retry
|
// retry
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Syncer {
|
||||||
|
|
||||||
/// @brief sleeps (nanoseconds)
|
/// @brief sleeps (nanoseconds)
|
||||||
void sleep(uint64_t time) {
|
void sleep(uint64_t time) {
|
||||||
usleep(static_cast<TRI_usleep_t>(time));
|
std::this_thread::sleep_for(std::chrono::microseconds(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief request location rewriter (injects database name)
|
/// @brief request location rewriter (injects database name)
|
||||||
|
|
|
@ -21,13 +21,15 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RestDemoHandler.h"
|
#include "RestDemoHandler.h"
|
||||||
|
#include "Rest/HttpRequest.h"
|
||||||
|
#include "Rest/Version.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include <velocypack/Builder.h>
|
#include <velocypack/Builder.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
#include "Rest/HttpRequest.h"
|
|
||||||
#include "Rest/Version.h"
|
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
@ -39,7 +41,7 @@ RestDemoHandler::RestDemoHandler(GeneralRequest* request,
|
||||||
RestStatus RestDemoHandler::execute() {
|
RestStatus RestDemoHandler::execute() {
|
||||||
return RestStatus::QUEUE
|
return RestStatus::QUEUE
|
||||||
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler going to sleep"; })
|
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler going to sleep"; })
|
||||||
.then([]() { sleep(5); })
|
.then([]() { std::this_thread::sleep_for(std::chrono::seconds(5)); })
|
||||||
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler done sleeping"; })
|
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler done sleeping"; })
|
||||||
.then([this]() { doSomeMoreWork(); })
|
.then([this]() { doSomeMoreWork(); })
|
||||||
.then([this]() { return evenMoreWork(); });
|
.then([this]() { return evenMoreWork(); });
|
||||||
|
@ -62,7 +64,7 @@ RestStatus RestDemoHandler::evenMoreWork() {
|
||||||
|
|
||||||
return RestStatus::DONE
|
return RestStatus::DONE
|
||||||
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler keeps working"; })
|
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "demo handler keeps working"; })
|
||||||
.then([]() { sleep(5); })
|
.then([]() { std::this_thread::sleep_for(std::chrono::seconds(5)); })
|
||||||
.then(
|
.then(
|
||||||
[]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "even if the result has already been returned"; })
|
[]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "even if the result has already been returned"; })
|
||||||
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "finally done"; });
|
.then([]() { LOG_TOPIC(INFO, arangodb::Logger::FIXME) << "finally done"; });
|
||||||
|
|
|
@ -108,7 +108,7 @@ void AqlFeature::stop() {
|
||||||
<< o << " registered traverser engines to terminate and for "
|
<< o << " registered traverser engines to terminate and for "
|
||||||
<< n << " registered queries to terminate and for "
|
<< n << " registered queries to terminate and for "
|
||||||
<< m << " feature leases to be released";
|
<< m << " feature leases to be released";
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
}
|
}
|
||||||
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
||||||
AqlFeature::_AQL = nullptr;
|
AqlFeature::_AQL = nullptr;
|
||||||
|
|
|
@ -71,7 +71,7 @@ static void raceForClusterBootstrap() {
|
||||||
// Error in communication, note that value not found is not an error
|
// Error in communication, note that value not found is not an error
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP)
|
LOG_TOPIC(TRACE, Logger::STARTUP)
|
||||||
<< "raceForClusterBootstrap: no agency communication";
|
<< "raceForClusterBootstrap: no agency communication";
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ static void raceForClusterBootstrap() {
|
||||||
}
|
}
|
||||||
LOG_TOPIC(DEBUG, Logger::STARTUP)
|
LOG_TOPIC(DEBUG, Logger::STARTUP)
|
||||||
<< "raceForClusterBootstrap: somebody else does the bootstrap";
|
<< "raceForClusterBootstrap: somebody else does the bootstrap";
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ static void raceForClusterBootstrap() {
|
||||||
LOG_TOPIC(DEBUG, Logger::STARTUP)
|
LOG_TOPIC(DEBUG, Logger::STARTUP)
|
||||||
<< "raceForClusterBootstrap: lost race, somebody else will bootstrap";
|
<< "raceForClusterBootstrap: lost race, somebody else will bootstrap";
|
||||||
// Cannot get foot into the door, try again later:
|
// Cannot get foot into the door, try again later:
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// OK, we handle things now
|
// OK, we handle things now
|
||||||
|
@ -115,7 +115,7 @@ static void raceForClusterBootstrap() {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP)
|
LOG_TOPIC(TRACE, Logger::STARTUP)
|
||||||
<< "raceForClusterBootstrap: no DBservers, waiting";
|
<< "raceForClusterBootstrap: no DBservers, waiting";
|
||||||
agency.removeValues(boostrapKey, false);
|
agency.removeValues(boostrapKey, false);
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ static void raceForClusterBootstrap() {
|
||||||
LOG_TOPIC(ERR, Logger::STARTUP) << "Empty returned value.";
|
LOG_TOPIC(ERR, Logger::STARTUP) << "Empty returned value.";
|
||||||
}
|
}
|
||||||
agency.removeValues(boostrapKey, false);
|
agency.removeValues(boostrapKey, false);
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ static void raceForClusterBootstrap() {
|
||||||
|
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP)
|
LOG_TOPIC(TRACE, Logger::STARTUP)
|
||||||
<< "raceForClusterBootstrap: could not indicate success";
|
<< "raceForClusterBootstrap: could not indicate success";
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ void BootstrapFeature::start() {
|
||||||
<< "result of bootstrap was not an array: " << slice.typeName() << ". retrying bootstrap in 1s.";
|
<< "result of bootstrap was not an array: " << slice.typeName() << ". retrying bootstrap in 1s.";
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ServerState::isDBServer(role)) {
|
} else if (ServerState::isDBServer(role)) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ void CheckVersionFeature::start() {
|
||||||
// and force shutdown
|
// and force shutdown
|
||||||
server()->beginShutdown();
|
server()->beginShutdown();
|
||||||
|
|
||||||
usleep(1 * 1000 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1 * 1000 * 1000));
|
||||||
TRI_EXIT_FUNCTION(EXIT_SUCCESS, nullptr);
|
TRI_EXIT_FUNCTION(EXIT_SUCCESS, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ void ConsoleFeature::unprepare() {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
|
|
||||||
while (_consoleThread->isRunning() && ++iterations < 30) {
|
while (_consoleThread->isRunning() && ++iterations < 30) {
|
||||||
usleep(100 * 1000); // spin while console is still needed
|
std::this_thread::sleep_for(std::chrono::microseconds(100 * 1000)); // spin while console is still needed
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << std::endl << TRI_BYE_MESSAGE << std::endl;
|
std::cout << std::endl << TRI_BYE_MESSAGE << std::endl;
|
||||||
|
|
|
@ -58,7 +58,7 @@ ConsoleThread::~ConsoleThread() { shutdown(); }
|
||||||
static char const* USER_ABORTED = "user aborted";
|
static char const* USER_ABORTED = "user aborted";
|
||||||
|
|
||||||
void ConsoleThread::run() {
|
void ConsoleThread::run() {
|
||||||
usleep(100 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100 * 1000));
|
||||||
|
|
||||||
// enter V8 context
|
// enter V8 context
|
||||||
_context = V8DealerFeature::DEALER->enterContext(_vocbase, true);
|
_context = V8DealerFeature::DEALER->enterContext(_vocbase, true);
|
||||||
|
|
|
@ -180,7 +180,7 @@ void DatabaseManagerThread::run() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(waitTime());
|
std::this_thread::sleep_for(std::chrono::microseconds(waitTime()));
|
||||||
|
|
||||||
// The following is only necessary after a wait:
|
// The following is only necessary after a wait:
|
||||||
auto queryRegistry = QueryRegistryFeature::QUERY_REGISTRY;
|
auto queryRegistry = QueryRegistryFeature::QUERY_REGISTRY;
|
||||||
|
@ -398,7 +398,7 @@ void DatabaseFeature::unprepare() {
|
||||||
_databaseManager->beginShutdown();
|
_databaseManager->beginShutdown();
|
||||||
|
|
||||||
while (_databaseManager->isRunning()) {
|
while (_databaseManager->isRunning()) {
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,7 +208,7 @@ void ServerFeature::waitForHeartbeat() {
|
||||||
if (HeartbeatThread::hasRunOnce()) {
|
if (HeartbeatThread::hasRunOnce()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(100 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100 * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1745,7 +1745,7 @@ int RocksDBCollection::lockWrite(double timeout) {
|
||||||
if (now - startTime < 0.001) {
|
if (now - startTime < 0.001) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} else {
|
} else {
|
||||||
usleep(static_cast<TRI_usleep_t>(waitTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(waitTime));
|
||||||
if (waitTime < 32) {
|
if (waitTime < 32) {
|
||||||
waitTime *= 2;
|
waitTime *= 2;
|
||||||
}
|
}
|
||||||
|
@ -1796,7 +1796,7 @@ int RocksDBCollection::lockRead(double timeout) {
|
||||||
if (now - startTime < 0.001) {
|
if (now - startTime < 0.001) {
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
} else {
|
} else {
|
||||||
usleep(static_cast<TRI_usleep_t>(waitTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(waitTime));
|
||||||
if (waitTime < 32) {
|
if (waitTime < 32) {
|
||||||
waitTime *= 2;
|
waitTime *= 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ Result RocksDBCounterManager::sync(bool force) {
|
||||||
if (res) {
|
if (res) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool expected = false;
|
bool expected = false;
|
||||||
|
|
|
@ -797,7 +797,7 @@ void RocksDBEdgeIndex::warmupInternal(transaction::Methods* trx,
|
||||||
while (cc->isBusy()) {
|
while (cc->isBusy()) {
|
||||||
// We should wait here, the cache will reject
|
// We should wait here, the cache will reject
|
||||||
// any inserts anyways.
|
// any inserts anyways.
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entry = cache::CachedValue::construct(
|
auto entry = cache::CachedValue::construct(
|
||||||
|
|
|
@ -595,7 +595,7 @@ void RocksDBEngine::stop() {
|
||||||
|
|
||||||
// wait until background thread stops
|
// wait until background thread stops
|
||||||
while (_backgroundThread->isRunning()) {
|
while (_backgroundThread->isRunning()) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
_backgroundThread.reset();
|
_backgroundThread.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ RocksDBReplicationManager::~RocksDBReplicationManager() {
|
||||||
<< "giving up waiting for unused contexts";
|
<< "giving up waiting for unused contexts";
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
++tries;
|
++tries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -445,10 +445,10 @@ void Scheduler::rebalanceThreads() {
|
||||||
}
|
}
|
||||||
// add an extra sleep so the system has a chance to recover and provide
|
// add an extra sleep so the system has a chance to recover and provide
|
||||||
// the needed resources
|
// the needed resources
|
||||||
usleep(20000);
|
std::this_thread::sleep_for(std::chrono::microseconds(20000));
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ void Scheduler::shutdown() {
|
||||||
// we can be quite generous here with waiting...
|
// we can be quite generous here with waiting...
|
||||||
// as we are in the shutdown already, we do not care if we need to wait for a
|
// as we are in the shutdown already, we do not care if we need to wait for a
|
||||||
// bit longer
|
// bit longer
|
||||||
usleep(20000);
|
std::this_thread::sleep_for(std::chrono::microseconds(20000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove all queued work descriptions in the work monitor first
|
// remove all queued work descriptions in the work monitor first
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "V8Server/V8DealerFeature.h"
|
#include "V8Server/V8DealerFeature.h"
|
||||||
#include "V8Server/v8-dispatcher.h"
|
#include "V8Server/v8-dispatcher.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
@ -176,7 +179,7 @@ void SchedulerFeature::stop() {
|
||||||
for (size_t count = 0; count < MAX_TRIES && _scheduler->isRunning();
|
for (size_t count = 0; count < MAX_TRIES && _scheduler->isRunning();
|
||||||
++count) {
|
++count) {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << "waiting for scheduler to stop";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << "waiting for scheduler to stop";
|
||||||
usleep(100000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// shutdown user jobs again, in case new ones appear
|
// shutdown user jobs again, in case new ones appear
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#include <boost/asio/serial_port_service.hpp>
|
#include <boost/asio/serial_port_service.hpp>
|
||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "Basics/StringBuffer.h"
|
#include "Basics/StringBuffer.h"
|
||||||
#include "Basics/asio-helper.h"
|
#include "Basics/asio-helper.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
|
@ -82,7 +85,7 @@ bool doSslHandshake(T& socket) {
|
||||||
LOG_TOPIC(DEBUG, Logger::COMMUNICATION) << "forcefully shutting down connection after wait time";
|
LOG_TOPIC(DEBUG, Logger::COMMUNICATION) << "forcefully shutting down connection after wait time";
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ void RequestStatistics::process(RequestStatistics* statistics) {
|
||||||
if (_freeList.push(statistics)) {
|
if (_freeList.push(statistics)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tries > 1) {
|
if (tries > 1) {
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "StatisticsFeature.h"
|
#include "StatisticsFeature.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "ProgramOptions/ProgramOptions.h"
|
#include "ProgramOptions/ProgramOptions.h"
|
||||||
#include "ProgramOptions/Section.h"
|
#include "ProgramOptions/Section.h"
|
||||||
|
@ -30,6 +29,9 @@
|
||||||
#include "Statistics/RequestStatistics.h"
|
#include "Statistics/RequestStatistics.h"
|
||||||
#include "Statistics/ServerStatistics.h"
|
#include "Statistics/ServerStatistics.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
@ -89,14 +91,14 @@ class arangodb::StatisticsThread final : public Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(static_cast<TRI_usleep_t>(sleepTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(sleepTime));
|
||||||
} else {
|
} else {
|
||||||
nothingHappened = 0;
|
nothingHappened = 0;
|
||||||
|
|
||||||
if (count < 10) {
|
if (count < 10) {
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
} else if (count < 100) {
|
} else if (count < 100) {
|
||||||
usleep(1 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1 * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +198,7 @@ void StatisticsFeature::unprepare() {
|
||||||
_statisticsThread->beginShutdown();
|
_statisticsThread->beginShutdown();
|
||||||
|
|
||||||
while (_statisticsThread->isRunning()) {
|
while (_statisticsThread->isRunning()) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ CollectionKeysRepository::~CollectionKeysRepository() {
|
||||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "giving up waiting for unused keys";
|
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "giving up waiting for unused keys";
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
++tries;
|
++tries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ CursorRepository::~CursorRepository() {
|
||||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "giving up waiting for unused cursors";
|
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "giving up waiting for unused cursors";
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(500000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500000));
|
||||||
++tries;
|
++tries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -708,7 +708,7 @@ V8Context* V8DealerFeature::enterContext(TRI_vocbase_t* vocbase,
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, arangodb::Logger::V8) << "waiting for V8 context #" << id << " to become available";
|
LOG_TOPIC(DEBUG, arangodb::Logger::V8) << "waiting for V8 context #" << id << " to become available";
|
||||||
usleep(50 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(50 * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context == nullptr) {
|
if (context == nullptr) {
|
||||||
|
@ -1088,7 +1088,7 @@ void V8DealerFeature::shutdownContexts() {
|
||||||
|
|
||||||
// wait until garbage collector thread is done
|
// wait until garbage collector thread is done
|
||||||
while (!_gcFinished) {
|
while (!_gcFinished) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_TOPIC(DEBUG, arangodb::Logger::V8) << "commanding GC Thread to terminate";
|
LOG_TOPIC(DEBUG, arangodb::Logger::V8) << "commanding GC Thread to terminate";
|
||||||
|
|
|
@ -1248,7 +1248,7 @@ static void JS_QuerySleepAql(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
double const until = TRI_microtime() + n;
|
double const until = TRI_microtime() + n;
|
||||||
|
|
||||||
while (TRI_microtime() < until) {
|
while (TRI_microtime() < until) {
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
|
|
||||||
if (query != nullptr) {
|
if (query != nullptr) {
|
||||||
if (query->killed()) {
|
if (query->killed()) {
|
||||||
|
|
|
@ -248,7 +248,7 @@ arangodb::Result Databases::create(std::string const& dbName,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// sleep
|
// sleep
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vocbase == nullptr) {
|
if (vocbase == nullptr) {
|
||||||
|
@ -434,7 +434,7 @@ arangodb::Result Databases::drop(TRI_vocbase_t* systemVocbase,
|
||||||
|
|
||||||
vocbase->release();
|
vocbase->release();
|
||||||
// sleep
|
// sleep
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -489,7 +489,7 @@ int TRI_vocbase_t::loadCollection(arangodb::LogicalCollection* collection,
|
||||||
return TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED;
|
return TRI_ERROR_ARANGO_COLLECTION_NOT_LOADED;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(collectionStatusPollInterval());
|
std::this_thread::sleep_for(std::chrono::microseconds(collectionStatusPollInterval()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadCollection(collection, status, false);
|
return loadCollection(collection, status, false);
|
||||||
|
@ -598,7 +598,7 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
||||||
|
|
||||||
// sleep for a while
|
// sleep for a while
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(writeLocker.isLocked());
|
TRI_ASSERT(writeLocker.isLocked());
|
||||||
|
@ -1073,7 +1073,7 @@ int TRI_vocbase_t::unloadCollection(arangodb::LogicalCollection* collection,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// sleep without lock
|
// sleep without lock
|
||||||
usleep(collectionStatusPollInterval());
|
std::this_thread::sleep_for(std::chrono::microseconds(collectionStatusPollInterval()));
|
||||||
}
|
}
|
||||||
// if we get here, the status has changed
|
// if we get here, the status has changed
|
||||||
return unloadCollection(collection, force);
|
return unloadCollection(collection, force);
|
||||||
|
@ -1138,7 +1138,7 @@ int TRI_vocbase_t::dropCollection(arangodb::LogicalCollection* collection,
|
||||||
|
|
||||||
// try again in next iteration
|
// try again in next iteration
|
||||||
TRI_ASSERT(state == DROP_AGAIN);
|
TRI_ASSERT(state == DROP_AGAIN);
|
||||||
usleep(collectionStatusPollInterval());
|
std::this_thread::sleep_for(std::chrono::microseconds(collectionStatusPollInterval()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,7 +1207,7 @@ int TRI_vocbase_t::renameCollection(arangodb::LogicalCollection* collection,
|
||||||
|
|
||||||
// sleep for a while
|
// sleep for a while
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(writeLocker.isLocked());
|
TRI_ASSERT(writeLocker.isLocked());
|
||||||
|
@ -1465,7 +1465,7 @@ int TRI_vocbase_t::dropView(std::shared_ptr<arangodb::LogicalView> view) {
|
||||||
|
|
||||||
// sleep for a while
|
// sleep for a while
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(writeLocker.isLocked());
|
TRI_ASSERT(writeLocker.isLocked());
|
||||||
|
|
|
@ -234,12 +234,12 @@ void BenchFeature::start() {
|
||||||
|
|
||||||
// give all threads a chance to start so they will not miss the broadcast
|
// give all threads a chance to start so they will not miss the broadcast
|
||||||
while (getStartCounter() < (int)_concurreny) {
|
while (getStartCounter() < (int)_concurreny) {
|
||||||
usleep(5000);
|
std::this_thread::sleep_for(std::chrono::microseconds(5000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_delay) {
|
if (_delay) {
|
||||||
status("sleeping (startup delay)...");
|
status("sleeping (startup delay)...");
|
||||||
sleep(10);
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
status("executing tests...");
|
status("executing tests...");
|
||||||
|
@ -270,7 +270,7 @@ void BenchFeature::start() {
|
||||||
nextReportValue += stepValue;
|
nextReportValue += stepValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
|
|
||||||
double time = TRI_microtime() - start;
|
double time = TRI_microtime() - start;
|
||||||
|
|
|
@ -886,7 +886,7 @@ void ImportHelper::waitForSenders() {
|
||||||
if (numIdle == _senderThreads.size()) {
|
if (numIdle == _senderThreads.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "Ssl/ssl-helper.h"
|
#include "Ssl/ssl-helper.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
@ -150,7 +152,7 @@ void ClientFeature::prepare() {
|
||||||
if (_authentication &&
|
if (_authentication &&
|
||||||
isEnabled() &&
|
isEnabled() &&
|
||||||
_haveServerPassword) {
|
_haveServerPassword) {
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConsoleFeature* console =
|
ConsoleFeature* console =
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "Basics/FileUtils.h"
|
#include "Basics/FileUtils.h"
|
||||||
#include "Logger/LogAppender.h"
|
#include "Logger/LogAppender.h"
|
||||||
|
@ -370,7 +372,7 @@ int DaemonFeature::waitForChildProcess(int pid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sleep a while and retry
|
// sleep a while and retry
|
||||||
usleep(500 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500 * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
// enough time has elapsed... we now abort our loop
|
// enough time has elapsed... we now abort our loop
|
||||||
|
|
|
@ -25,6 +25,8 @@
|
||||||
#define ARANGODB_BASICS_DATA_PROTECTOR_H 1
|
#define ARANGODB_BASICS_DATA_PROTECTOR_H 1
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
namespace basics {
|
namespace basics {
|
||||||
|
@ -140,7 +142,7 @@ class DataProtector {
|
||||||
for (int i = 0; i < DATA_PROTECTOR_MULTIPLICITY; i++) {
|
for (int i = 0; i < DATA_PROTECTOR_MULTIPLICITY; i++) {
|
||||||
while (reinterpret_cast<Entry*>(_list + i)->_count > 0) {
|
while (reinterpret_cast<Entry*>(_list + i)->_count > 0) {
|
||||||
// let other threads do some work while we're waiting
|
// let other threads do some work while we're waiting
|
||||||
usleep(250);
|
std::this_thread::sleep_for(std::chrono::microseconds(250));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,115 +18,86 @@
|
||||||
///
|
///
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// @author Frank Celler
|
/// @author Max Neunhoeffer
|
||||||
/// @author Achim Brandt
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "ReadWriteLock.h"
|
#include "ReadWriteLock.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief constructs a read-write lock
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ReadWriteLock::ReadWriteLock() : _rwlock(), _writeLocked(false) {
|
|
||||||
TRI_InitReadWriteLock(&_rwlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief deletes read-write lock
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ReadWriteLock::~ReadWriteLock() { TRI_DestroyReadWriteLock(&_rwlock); }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief locks for reading
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ReadWriteLock::readLock() { TRI_ReadLockReadWriteLock(&_rwlock); }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief tries to lock for reading
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool ReadWriteLock::tryReadLock() {
|
|
||||||
return TRI_TryReadLockReadWriteLock(&_rwlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief tries to lock for reading, sleeping if the lock cannot be
|
|
||||||
/// acquired instantly, sleepTime is in microseconds
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool ReadWriteLock::tryReadLock(uint64_t sleepTime) {
|
|
||||||
while (true) {
|
|
||||||
if (tryReadLock()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(static_cast<TRI_usleep_t>(sleepTime));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief locks for writing
|
/// @brief locks for writing
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ReadWriteLock::writeLock() {
|
void ReadWriteLock::writeLock() {
|
||||||
TRI_WriteLockReadWriteLock(&_rwlock);
|
std::unique_lock<std::mutex> guard(_mut);
|
||||||
|
if (_state == 0) {
|
||||||
_writeLocked = true;
|
_state = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
_wantWrite = true;
|
||||||
|
_bell.wait(guard);
|
||||||
|
} while (_state != 0);
|
||||||
|
_state = -1;
|
||||||
|
_wantWrite = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/// @brief locks for writing, but only tries
|
||||||
/// @brief tries to lock for writing
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
bool ReadWriteLock::tryWriteLock() {
|
bool ReadWriteLock::tryWriteLock() {
|
||||||
if (!TRI_TryWriteLockReadWriteLock(&_rwlock)) {
|
std::unique_lock<std::mutex> guard(_mut);
|
||||||
return false;
|
if (_state == 0) {
|
||||||
|
_state = -1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
_writeLocked = true;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/// @brief locks for reading
|
||||||
/// @brief tries to lock for writing, sleeping if the lock cannot be
|
void ReadWriteLock::readLock() {
|
||||||
/// acquired instantly, sleepTime is in microseconds
|
std::unique_lock<std::mutex> guard(_mut);
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
if (!_wantWrite && _state >= 0) {
|
||||||
|
_state += 1;
|
||||||
bool ReadWriteLock::tryWriteLock(uint64_t sleepTime) {
|
return;
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
if (tryWriteLock()) {
|
while (_wantWrite || _state < 0) {
|
||||||
return true;
|
_bell.wait(guard);
|
||||||
|
}
|
||||||
|
if (!_wantWrite) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(static_cast<TRI_usleep_t>(sleepTime));
|
|
||||||
}
|
}
|
||||||
|
_state += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief locks for reading, tries only
|
||||||
|
bool ReadWriteLock::tryReadLock() {
|
||||||
|
std::unique_lock<std::mutex> guard(_mut);
|
||||||
|
if (!_wantWrite && _state >= 0) {
|
||||||
|
_state += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief releases the read-lock or write-lock
|
/// @brief releases the read-lock or write-lock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ReadWriteLock::unlock() {
|
void ReadWriteLock::unlock() {
|
||||||
if (_writeLocked) {
|
std::unique_lock<std::mutex> guard(_mut);
|
||||||
_writeLocked = false;
|
if (_state == -1) {
|
||||||
unlockWrite();
|
_state = 0;
|
||||||
|
_bell.notify_all();
|
||||||
} else {
|
} else {
|
||||||
unlockRead();
|
_state -= 1;
|
||||||
|
if (_state == 0) {
|
||||||
|
_bell.notify_all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief releases the read-lock
|
||||||
void ReadWriteLock::unlockRead() {
|
void ReadWriteLock::unlockRead() {
|
||||||
TRI_ReadUnlockReadWriteLock(&_rwlock);
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief releases the write-lock
|
||||||
void ReadWriteLock::unlockWrite() {
|
void ReadWriteLock::unlockWrite() {
|
||||||
TRI_WriteUnlockReadWriteLock(&_rwlock);
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -18,61 +18,53 @@
|
||||||
///
|
///
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// @author Frank Celler
|
/// @author Max Neunhoeffer
|
||||||
/// @author Achim Brandt
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef ARANGODB_BASICS_READ_WRITE_LOCK_H
|
#ifndef ARANGODB_BASICS_READ_WRITE_LOCK_H
|
||||||
#define ARANGODB_BASICS_READ_WRITE_LOCK_H 1
|
#define ARANGODB_BASICS_READ_WRITE_LOCK_H 1
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
#include "Basics/locks.h"
|
|
||||||
#include "Basics/ReadWriteLockCPP11.h"
|
#include <mutex>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
namespace basics {
|
namespace basics {
|
||||||
|
|
||||||
typedef ReadWriteLockCPP11 ReadWriteLock;
|
/// @brief read-write lock, slow but just using CPP11
|
||||||
|
/// This class has two other advantages:
|
||||||
#if 0
|
/// (1) it is possible that a thread tries to acquire a lock even if it
|
||||||
/// @brief read-write lock
|
/// has it already. This is important when we are running a thread
|
||||||
|
/// pool that works on task groups and a task group needs to acquire
|
||||||
|
/// a lock across multiple (non-concurrent) tasks. This must work,
|
||||||
|
/// even if tasks from different groups that fight for a lock are
|
||||||
|
/// actually executed by the same thread! POSIX RW-locks do not have
|
||||||
|
/// this property.
|
||||||
|
/// (2) write locks have a preference over read locks: as long as a task
|
||||||
|
/// wants to get a write lock, no other task can get a (new) read lock.
|
||||||
|
/// This is necessary to avoid starvation of writers by many readers.
|
||||||
|
/// The current implementation can starve readers, though.
|
||||||
class ReadWriteLock {
|
class ReadWriteLock {
|
||||||
ReadWriteLock(ReadWriteLock const&) = delete;
|
|
||||||
ReadWriteLock& operator=(ReadWriteLock const&) = delete;
|
|
||||||
ReadWriteLock(ReadWriteLock&&) = delete;
|
|
||||||
ReadWriteLock& operator=(ReadWriteLock&&) = delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief constructs a read-write lock
|
ReadWriteLock() : _state(0), _wantWrite(false) {}
|
||||||
ReadWriteLock();
|
|
||||||
|
|
||||||
/// @brief deletes read-write lock
|
|
||||||
~ReadWriteLock();
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// @brief locks for reading
|
|
||||||
void readLock();
|
|
||||||
|
|
||||||
/// @brief tries to lock for reading
|
|
||||||
bool tryReadLock();
|
|
||||||
|
|
||||||
/// @brief tries to lock for reading, sleeping if the lock cannot be
|
|
||||||
/// acquired instantly, sleepTime is in microseconds
|
|
||||||
bool tryReadLock(uint64_t sleepTime);
|
|
||||||
|
|
||||||
/// @brief locks for writing
|
/// @brief locks for writing
|
||||||
void writeLock();
|
void writeLock();
|
||||||
|
|
||||||
/// @brief tries to lock for writing
|
/// @brief locks for writing, but only tries
|
||||||
bool tryWriteLock();
|
bool tryWriteLock();
|
||||||
|
|
||||||
/// @brief tries to lock for writing, sleeping if the lock cannot be
|
/// @brief locks for reading
|
||||||
/// acquired instantly, sleepTime is in microseconds
|
void readLock();
|
||||||
bool tryWriteLock(uint64_t sleepTime);
|
|
||||||
|
/// @brief locks for reading, tries only
|
||||||
|
bool tryReadLock();
|
||||||
|
|
||||||
/// @brief releases the read-lock or write-lock
|
/// @brief releases the read-lock or write-lock
|
||||||
void unlock();
|
void unlock();
|
||||||
|
|
||||||
/// @brief releases the read-lock
|
/// @brief releases the read-lock
|
||||||
void unlockRead();
|
void unlockRead();
|
||||||
|
|
||||||
|
@ -80,15 +72,19 @@ class ReadWriteLock {
|
||||||
void unlockWrite();
|
void unlockWrite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// @brief read-write lock variable
|
/// @brief a mutex
|
||||||
TRI_read_write_lock_t _rwlock;
|
std::mutex _mut;
|
||||||
|
|
||||||
/// @brief write lock marker
|
/// @brief a condition variable to wake up threads
|
||||||
bool _writeLocked;
|
std::condition_variable _bell;
|
||||||
|
|
||||||
|
/// @brief _state, 0 means unlocked, -1 means write locked, positive means
|
||||||
|
/// a number of read locks
|
||||||
|
int _state;
|
||||||
|
|
||||||
|
/// @brief _wantWrite, is set if somebody is waiting for the write lock
|
||||||
|
bool _wantWrite;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// DISCLAIMER
|
|
||||||
///
|
|
||||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
|
||||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
/// you may not use this file except in compliance with the License.
|
|
||||||
/// You may obtain a copy of the License at
|
|
||||||
///
|
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
///
|
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
/// See the License for the specific language governing permissions and
|
|
||||||
/// limitations under the License.
|
|
||||||
///
|
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// @author Max Neunhoeffer
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "ReadWriteLockCPP11.h"
|
|
||||||
|
|
||||||
using namespace arangodb::basics;
|
|
||||||
|
|
||||||
/// @brief locks for writing
|
|
||||||
void ReadWriteLockCPP11::writeLock() {
|
|
||||||
std::unique_lock<std::mutex> guard(_mut);
|
|
||||||
if (_state == 0) {
|
|
||||||
_state = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
_wantWrite = true;
|
|
||||||
_bell.wait(guard);
|
|
||||||
} while (_state != 0);
|
|
||||||
_state = -1;
|
|
||||||
_wantWrite = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief locks for writing, but only tries
|
|
||||||
bool ReadWriteLockCPP11::tryWriteLock() {
|
|
||||||
std::unique_lock<std::mutex> guard(_mut);
|
|
||||||
if (_state == 0) {
|
|
||||||
_state = -1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief locks for reading
|
|
||||||
void ReadWriteLockCPP11::readLock() {
|
|
||||||
std::unique_lock<std::mutex> guard(_mut);
|
|
||||||
if (!_wantWrite && _state >= 0) {
|
|
||||||
_state += 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (true) {
|
|
||||||
while (_wantWrite || _state < 0) {
|
|
||||||
_bell.wait(guard);
|
|
||||||
}
|
|
||||||
if (!_wantWrite) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_state += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief locks for reading, tries only
|
|
||||||
bool ReadWriteLockCPP11::tryReadLock() {
|
|
||||||
std::unique_lock<std::mutex> guard(_mut);
|
|
||||||
if (!_wantWrite && _state >= 0) {
|
|
||||||
_state += 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief releases the read-lock or write-lock
|
|
||||||
void ReadWriteLockCPP11::unlock() {
|
|
||||||
std::unique_lock<std::mutex> guard(_mut);
|
|
||||||
if (_state == -1) {
|
|
||||||
_state = 0;
|
|
||||||
_bell.notify_all();
|
|
||||||
} else {
|
|
||||||
_state -= 1;
|
|
||||||
if (_state == 0) {
|
|
||||||
_bell.notify_all();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief releases the read-lock
|
|
||||||
void ReadWriteLockCPP11::unlockRead() {
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @brief releases the write-lock
|
|
||||||
void ReadWriteLockCPP11::unlockWrite() {
|
|
||||||
unlock();
|
|
||||||
}
|
|
|
@ -1,91 +0,0 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// DISCLAIMER
|
|
||||||
///
|
|
||||||
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
|
|
||||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
/// you may not use this file except in compliance with the License.
|
|
||||||
/// You may obtain a copy of the License at
|
|
||||||
///
|
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
///
|
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
/// See the License for the specific language governing permissions and
|
|
||||||
/// limitations under the License.
|
|
||||||
///
|
|
||||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// @author Max Neunhoeffer
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef ARANGODB_BASICS_READ_WRITE_LOCK_CPP11_H
|
|
||||||
#define ARANGODB_BASICS_READ_WRITE_LOCK_CPP11_H 1
|
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
#include <condition_variable>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace arangodb {
|
|
||||||
namespace basics {
|
|
||||||
|
|
||||||
/// @brief read-write lock, slow but just using CPP11
|
|
||||||
/// This class has two other advantages:
|
|
||||||
/// (1) it is possible that a thread tries to acquire a lock even if it
|
|
||||||
/// has it already. This is important when we are running a thread
|
|
||||||
/// pool that works on task groups and a task group needs to acquire
|
|
||||||
/// a lock across multiple (non-concurrent) tasks. This must work,
|
|
||||||
/// even if tasks from different groups that fight for a lock are
|
|
||||||
/// actually executed by the same thread! POSIX RW-locks do not have
|
|
||||||
/// this property.
|
|
||||||
/// (2) write locks have a preference over read locks: as long as a task
|
|
||||||
/// wants to get a write lock, no other task can get a (new) read lock.
|
|
||||||
/// This is necessary to avoid starvation of writers by many readers.
|
|
||||||
/// The current implementation can starve readers, though.
|
|
||||||
class ReadWriteLockCPP11 {
|
|
||||||
public:
|
|
||||||
ReadWriteLockCPP11() : _state(0), _wantWrite(false) {}
|
|
||||||
|
|
||||||
/// @brief locks for writing
|
|
||||||
void writeLock();
|
|
||||||
|
|
||||||
/// @brief locks for writing, but only tries
|
|
||||||
bool tryWriteLock();
|
|
||||||
|
|
||||||
/// @brief locks for reading
|
|
||||||
void readLock();
|
|
||||||
|
|
||||||
/// @brief locks for reading, tries only
|
|
||||||
bool tryReadLock();
|
|
||||||
|
|
||||||
/// @brief releases the read-lock or write-lock
|
|
||||||
void unlock();
|
|
||||||
|
|
||||||
/// @brief releases the read-lock
|
|
||||||
void unlockRead();
|
|
||||||
|
|
||||||
/// @brief releases the write-lock
|
|
||||||
void unlockWrite();
|
|
||||||
|
|
||||||
private:
|
|
||||||
/// @brief a mutex
|
|
||||||
std::mutex _mut;
|
|
||||||
|
|
||||||
/// @brief a condition variable to wake up threads
|
|
||||||
std::condition_variable _bell;
|
|
||||||
|
|
||||||
/// @brief _state, 0 means unlocked, -1 means write locked, positive means
|
|
||||||
/// a number of read locks
|
|
||||||
int _state;
|
|
||||||
|
|
||||||
/// @brief _wantWrite, is set if somebody is waiting for the write lock
|
|
||||||
bool _wantWrite;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -36,6 +36,9 @@
|
||||||
#include <velocypack/Builder.h>
|
#include <velocypack/Builder.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
@ -282,7 +285,7 @@ void Thread::shutdown() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(100 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(100 * 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_state.load() != ThreadState::STOPPED) {
|
if (_state.load() != ThreadState::STOPPED) {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "locks.h"
|
#include "locks.h"
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#ifdef TRI_HAVE_POSIX_THREADS
|
#ifdef TRI_HAVE_POSIX_THREADS
|
||||||
|
|
||||||
|
@ -92,7 +94,7 @@ again:
|
||||||
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "too many read-locks on read-write lock";
|
LOG_TOPIC(WARN, arangodb::Logger::FIXME) << "too many read-locks on read-write lock";
|
||||||
complained = true;
|
complained = true;
|
||||||
}
|
}
|
||||||
usleep(BUSY_LOCK_DELAY);
|
std::this_thread::sleep_for(std::chrono::microseconds(BUSY_LOCK_DELAY));
|
||||||
#ifdef TRI_HAVE_SCHED_H
|
#ifdef TRI_HAVE_SCHED_H
|
||||||
// let other threads do things
|
// let other threads do things
|
||||||
sched_yield();
|
sched_yield();
|
||||||
|
|
|
@ -180,7 +180,6 @@
|
||||||
#define TRI_WRITE ::write
|
#define TRI_WRITE ::write
|
||||||
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
||||||
|
|
||||||
#define TRI_usleep_t useconds_t
|
|
||||||
#define TRI_lseek_t off_t
|
#define TRI_lseek_t off_t
|
||||||
#define TRI_read_t size_t
|
#define TRI_read_t size_t
|
||||||
#define TRI_stat_t struct stat
|
#define TRI_stat_t struct stat
|
||||||
|
@ -338,7 +337,6 @@
|
||||||
#define TRI_WRITE ::write
|
#define TRI_WRITE ::write
|
||||||
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
||||||
|
|
||||||
#define TRI_usleep_t useconds_t
|
|
||||||
#define TRI_lseek_t off_t
|
#define TRI_lseek_t off_t
|
||||||
#define TRI_read_t size_t
|
#define TRI_read_t size_t
|
||||||
#define TRI_stat_t struct stat
|
#define TRI_stat_t struct stat
|
||||||
|
@ -483,7 +481,6 @@
|
||||||
#define TRI_WRITE ::write
|
#define TRI_WRITE ::write
|
||||||
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
||||||
|
|
||||||
#define TRI_usleep_t useconds_t
|
|
||||||
#define TRI_lseek_t off_t
|
#define TRI_lseek_t off_t
|
||||||
#define TRI_read_t size_t
|
#define TRI_read_t size_t
|
||||||
#define TRI_stat_t struct stat
|
#define TRI_stat_t struct stat
|
||||||
|
@ -647,7 +644,6 @@
|
||||||
#define TRI_WRITE ::write
|
#define TRI_WRITE ::write
|
||||||
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
#define TRI_FDOPEN(a, b) ::fdopen((a), (b))
|
||||||
|
|
||||||
#define TRI_usleep_t useconds_t
|
|
||||||
#define TRI_lseek_t off_t
|
#define TRI_lseek_t off_t
|
||||||
#define TRI_read_t size_t
|
#define TRI_read_t size_t
|
||||||
#define TRI_stat_t struct stat
|
#define TRI_stat_t struct stat
|
||||||
|
@ -752,7 +748,6 @@
|
||||||
#define putenv _putenv
|
#define putenv _putenv
|
||||||
#define sleep TRI_sleep
|
#define sleep TRI_sleep
|
||||||
#define tzset _tzset
|
#define tzset _tzset
|
||||||
#define usleep TRI_usleep
|
|
||||||
|
|
||||||
// available features
|
// available features
|
||||||
|
|
||||||
|
@ -844,7 +839,6 @@ typedef unsigned char bool;
|
||||||
#define TRI_WRITE ::_write
|
#define TRI_WRITE ::_write
|
||||||
#define TRI_FDOPEN(a, b) ::_fdopen((a), (b))
|
#define TRI_FDOPEN(a, b) ::_fdopen((a), (b))
|
||||||
|
|
||||||
#define TRI_usleep_t unsigned long
|
|
||||||
#define TRI_lseek_t __int64
|
#define TRI_lseek_t __int64
|
||||||
#define TRI_read_t unsigned int
|
#define TRI_read_t unsigned int
|
||||||
#define TRI_stat_t struct _stat64
|
#define TRI_stat_t struct _stat64
|
||||||
|
|
|
@ -1389,7 +1389,7 @@ ExternalProcessStatus TRI_KillExternalProcess(ExternalId pid, int signal, bool i
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
sleep(1);
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
if (count >= 8) {
|
if (count >= 8) {
|
||||||
TRI_ASSERT(external != nullptr);
|
TRI_ASSERT(external != nullptr);
|
||||||
killProcess(external, SIGKILL);
|
killProcess(external, SIGKILL);
|
||||||
|
|
|
@ -69,61 +69,6 @@ int getpagesize(void) {
|
||||||
return pageSize;
|
return pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Calls the windows Sleep function which always sleeps for milliseconds
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_sleep(unsigned long waitTime) { Sleep(waitTime * 1000); }
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Calls a timer which waits for a signal after the elapsed time in
|
|
||||||
// microseconds. The timer is accurate to 100nanoseconds.
|
|
||||||
// This is only a Windows workaround, use usleep, which is mapped to
|
|
||||||
// TRI_usleep on Windows!
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void TRI_usleep(unsigned long waitTime) {
|
|
||||||
int result;
|
|
||||||
HANDLE hTimer = NULL; // stores the handle of the timer object
|
|
||||||
LARGE_INTEGER wTime; // essentially a 64bit number
|
|
||||||
wTime.QuadPart = waitTime * 10; // *10 to change to microseconds
|
|
||||||
wTime.QuadPart =
|
|
||||||
-wTime.QuadPart; // negative indicates relative time elapsed,
|
|
||||||
|
|
||||||
// Create an unnamed waitable timer.
|
|
||||||
hTimer = CreateWaitableTimer(NULL, 1, NULL);
|
|
||||||
|
|
||||||
if (hTimer == NULL) {
|
|
||||||
// not much we can do at this low level
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
|
||||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "internal error in TRI_usleep()";
|
|
||||||
FATAL_ERROR_EXIT();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set timer to wait for indicated micro seconds.
|
|
||||||
if (!SetWaitableTimer(hTimer, &wTime, 0, NULL, NULL, 0)) {
|
|
||||||
// not much we can do at this low level
|
|
||||||
CloseHandle(hTimer);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for the timer
|
|
||||||
result = WaitForSingleObject(hTimer, INFINITE);
|
|
||||||
|
|
||||||
if (result != WAIT_OBJECT_0) {
|
|
||||||
CloseHandle(hTimer);
|
|
||||||
LOG_TOPIC(FATAL, arangodb::Logger::FIXME) << "couldn't wait for timer in TRI_usleep()";
|
|
||||||
FATAL_ERROR_EXIT();
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle(hTimer);
|
|
||||||
// todo: go through what the result is e.g. WAIT_OBJECT_0
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Sets up a handler when invalid (win) handles are passed to a windows
|
// Sets up a handler when invalid (win) handles are passed to a windows
|
||||||
// function.
|
// function.
|
||||||
|
|
|
@ -70,21 +70,6 @@ int TRI_createFile(char const* filename, int openFlags, int modeFlags);
|
||||||
|
|
||||||
int TRI_OPEN_WIN32(char const* filename, int openFlags);
|
int TRI_OPEN_WIN32(char const* filename, int openFlags);
|
||||||
|
|
||||||
// .............................................................................
|
|
||||||
// the sleep function in windows is for milliseconds, on linux it is for seconds
|
|
||||||
// this provides a translation
|
|
||||||
// .............................................................................
|
|
||||||
|
|
||||||
void TRI_sleep(unsigned long);
|
|
||||||
|
|
||||||
// .............................................................................
|
|
||||||
// there is no usleep (micro sleep) in windows, so we create one here
|
|
||||||
// This is only a Windows workaround, use usleep, which is mapped to
|
|
||||||
// TRI_usleep on Windows!
|
|
||||||
// .............................................................................
|
|
||||||
|
|
||||||
void TRI_usleep(unsigned long);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief converts a Windows error to a *nix system error
|
/// @brief converts a Windows error to a *nix system error
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -139,7 +139,7 @@ add_library(${LIB_ARANGO} STATIC
|
||||||
Basics/Mutex.cpp
|
Basics/Mutex.cpp
|
||||||
Basics/Nonce.cpp
|
Basics/Nonce.cpp
|
||||||
Basics/OpenFilesTracker.cpp
|
Basics/OpenFilesTracker.cpp
|
||||||
Basics/ReadWriteLockCPP11.cpp
|
Basics/ReadWriteLock.cpp
|
||||||
Basics/RocksDBLogger.cpp
|
Basics/RocksDBLogger.cpp
|
||||||
Basics/RocksDBUtils.cpp
|
Basics/RocksDBUtils.cpp
|
||||||
Basics/SharedPRNG.cpp
|
Basics/SharedPRNG.cpp
|
||||||
|
|
|
@ -421,7 +421,7 @@ void Logger::shutdown() {
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
while (_loggingThread->hasMessages() && ++tries < 1000) {
|
while (_loggingThread->hasMessages() && ++tries < 1000) {
|
||||||
_loggingThread->wakeup();
|
_loggingThread->wakeup();
|
||||||
usleep(10000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||||
}
|
}
|
||||||
_loggingThread->beginShutdown();
|
_loggingThread->beginShutdown();
|
||||||
_loggingThread.reset();
|
_loggingThread.reset();
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
#include <velocypack/Parser.h>
|
#include <velocypack/Parser.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
|
|
||||||
|
@ -173,7 +176,7 @@ SimpleHttpResult* SimpleHttpClient::retryRequest(
|
||||||
<< " - retries left: " << (_params._maxRetries - tries);
|
<< " - retries left: " << (_params._maxRetries - tries);
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(static_cast<TRI_usleep_t>(_params._retryWaitTime));
|
std::this_thread::sleep_for(std::chrono::microseconds(_params._retryWaitTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -3209,7 +3209,7 @@ static void JS_Sleep(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
? 500000
|
? 500000
|
||||||
: static_cast<uint64_t>((until - now) * 1000000);
|
: static_cast<uint64_t>((until - now) * 1000000);
|
||||||
|
|
||||||
usleep(static_cast<TRI_usleep_t>(duration));
|
std::this_thread::sleep_for(std::chrono::microseconds(duration));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_V8_RETURN_UNDEFINED();
|
TRI_V8_RETURN_UNDEFINED();
|
||||||
|
@ -3266,7 +3266,7 @@ static void JS_Wait(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
||||||
// wait without gc
|
// wait without gc
|
||||||
double until = TRI_microtime() + n;
|
double until = TRI_microtime() + n;
|
||||||
while (TRI_microtime() < until) {
|
while (TRI_microtime() < until) {
|
||||||
usleep(1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_V8_RETURN_UNDEFINED();
|
TRI_V8_RETURN_UNDEFINED();
|
||||||
|
@ -4523,7 +4523,7 @@ bool TRI_RunGarbageCollectionV8(v8::Isolate* isolate, double availableTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -198,6 +198,7 @@ TEST_CASE("cache::Manager", "[cache][!hide][longRunning]") {
|
||||||
caches.emplace(res);
|
caches.emplace(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// intentionally falls through
|
||||||
case 1:
|
case 1:
|
||||||
default: {
|
default: {
|
||||||
if (!caches.empty()) {
|
if (!caches.empty()) {
|
||||||
|
|
|
@ -69,9 +69,9 @@ TEST_CASE("cache::Rebalancer", "[cache][!hide][longRunning]") {
|
||||||
while (!doneRebalancing) {
|
while (!doneRebalancing) {
|
||||||
int status = rebalancer.rebalance();
|
int status = rebalancer.rebalance();
|
||||||
if (status != TRI_ERROR_ARANGO_BUSY) {
|
if (status != TRI_ERROR_ARANGO_BUSY) {
|
||||||
usleep(500 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500 * 1000));
|
||||||
} else {
|
} else {
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -195,9 +195,9 @@ TEST_CASE("cache::Rebalancer", "[cache][!hide][longRunning]") {
|
||||||
while (!doneRebalancing) {
|
while (!doneRebalancing) {
|
||||||
int status = rebalancer.rebalance();
|
int status = rebalancer.rebalance();
|
||||||
if (status != TRI_ERROR_ARANGO_BUSY) {
|
if (status != TRI_ERROR_ARANGO_BUSY) {
|
||||||
usleep(500 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(500 * 1000));
|
||||||
} else {
|
} else {
|
||||||
usleep(10 * 1000);
|
std::this_thread::sleep_for(std::chrono::microseconds(10 * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -194,11 +194,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
|
||||||
|
|
||||||
std::future<void> f1(std::async(std::launch::async, [&]{
|
std::future<void> f1(std::async(std::launch::async, [&]{
|
||||||
timespec ts={0,15000000};
|
timespec ts={0,15000000};
|
||||||
#if defined(_WIN32)
|
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
|
||||||
usleep(ts.tv_nsec / 1000L);
|
|
||||||
#else
|
|
||||||
nanosleep(&ts, nullptr);
|
|
||||||
#endif
|
|
||||||
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
||||||
testme.signalResponse();
|
testme.signalResponse();
|
||||||
} // lambda
|
} // lambda
|
||||||
|
@ -216,11 +212,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
|
||||||
// do second time to get other response
|
// do second time to get other response
|
||||||
std::future<void> f2(std::async(std::launch::async, [&]{
|
std::future<void> f2(std::async(std::launch::async, [&]{
|
||||||
timespec ts={0, 30000000};
|
timespec ts={0, 30000000};
|
||||||
#if defined(_WIN32)
|
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
|
||||||
usleep(ts.tv_nsec / 1000L);
|
|
||||||
#else
|
|
||||||
nanosleep(&ts, nullptr);
|
|
||||||
#endif
|
|
||||||
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
||||||
testme.signalResponse();
|
testme.signalResponse();
|
||||||
} // lambda
|
} // lambda
|
||||||
|
@ -251,11 +243,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
|
||||||
|
|
||||||
std::future<void> f3(std::async(std::launch::async, [&]{
|
std::future<void> f3(std::async(std::launch::async, [&]{
|
||||||
timespec ts={0,15000000};
|
timespec ts={0,15000000};
|
||||||
#if defined(_WIN32)
|
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
|
||||||
usleep(ts.tv_nsec / 1000L);
|
|
||||||
#else
|
|
||||||
nanosleep(&ts, nullptr);
|
|
||||||
#endif
|
|
||||||
testme.getResponse(1).result->status = CL_COMM_RECEIVED;
|
testme.getResponse(1).result->status = CL_COMM_RECEIVED;
|
||||||
testme.signalResponse();
|
testme.signalResponse();
|
||||||
} // lambda
|
} // lambda
|
||||||
|
@ -273,11 +261,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
|
||||||
// do second time to get other response
|
// do second time to get other response
|
||||||
std::future<void> f4(std::async(std::launch::async, [&]{
|
std::future<void> f4(std::async(std::launch::async, [&]{
|
||||||
timespec ts={0, 30000000};
|
timespec ts={0, 30000000};
|
||||||
#if defined(_WIN32)
|
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
|
||||||
usleep(ts.tv_nsec / 1000L);
|
|
||||||
#else
|
|
||||||
nanosleep(&ts, nullptr);
|
|
||||||
#endif
|
|
||||||
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
||||||
testme.signalResponse();
|
testme.signalResponse();
|
||||||
} // lambda
|
} // lambda
|
||||||
|
@ -296,11 +280,7 @@ TEST_CASE("ClusterComm::wait", "[cluster][mev]") {
|
||||||
id_first = testme.addSimpleRequest(transId, CL_COMM_SUBMITTED);
|
id_first = testme.addSimpleRequest(transId, CL_COMM_SUBMITTED);
|
||||||
std::future<void> f5(std::async(std::launch::async, [&]{
|
std::future<void> f5(std::async(std::launch::async, [&]{
|
||||||
timespec ts={0, 500000000}; //0.5 seconds
|
timespec ts={0, 500000000}; //0.5 seconds
|
||||||
#if defined(_WIN32)
|
std::this_thread::sleep_for(std::chrono::microseconds(ts.tv_nsec / 1000L));
|
||||||
usleep(ts.tv_nsec / 1000L);
|
|
||||||
#else
|
|
||||||
nanosleep(&ts, nullptr);
|
|
||||||
#endif
|
|
||||||
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
testme.getResponse(0).result->status = CL_COMM_RECEIVED;
|
||||||
testme.signalResponse();
|
testme.signalResponse();
|
||||||
} // lambda
|
} // lambda
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#include "SimpleHttpClient/Callbacks.h"
|
#include "SimpleHttpClient/Callbacks.h"
|
||||||
#include "SimpleHttpClient/Destination.h"
|
#include "SimpleHttpClient/Destination.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::communicator;
|
using namespace arangodb::communicator;
|
||||||
|
|
||||||
|
@ -57,7 +60,7 @@ TEST_CASE("requests are properly aborted", "[communicator]" ) {
|
||||||
communicator.work_once();
|
communicator.work_once();
|
||||||
communicator.abortRequests();
|
communicator.abortRequests();
|
||||||
while (communicator.work_once() > 0) {
|
while (communicator.work_once() > 0) {
|
||||||
usleep(1);
|
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||||
}
|
}
|
||||||
REQUIRE(callbacksCalled);
|
REQUIRE(callbacksCalled);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +87,7 @@ TEST_CASE("requests will call the progress callback", "[communicator]") {
|
||||||
communicator.work_once();
|
communicator.work_once();
|
||||||
communicator.abortRequests();
|
communicator.abortRequests();
|
||||||
while (communicator.work_once() > 0) {
|
while (communicator.work_once() > 0) {
|
||||||
usleep(1);
|
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||||
}
|
}
|
||||||
REQUIRE(curlRc == CURLE_ABORTED_BY_CALLBACK); // curlRcFn was called
|
REQUIRE(curlRc == CURLE_ABORTED_BY_CALLBACK); // curlRcFn was called
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue