summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-08-11 12:29:46 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-08-11 12:30:24 +0200
commit41709673f0165f16496ecf37162ed7dac06b5295 (patch)
treec213da683873bbe88927a3de58eb93f3f231a693 /config
parent2fe073e8e1875bc891c38099c880d156bd228e9d (diff)
Use std::atomic all over and completely get rid of homegrown atomics.
Diffstat (limited to 'config')
-rw-r--r--config/src/vespa/config/common/configmanager.cpp3
-rw-r--r--config/src/vespa/config/common/configmanager.h2
-rw-r--r--config/src/vespa/config/frt/connection.h1
-rw-r--r--config/src/vespa/config/frt/frtconnection.cpp5
-rw-r--r--config/src/vespa/config/frt/frtconnection.h9
5 files changed, 9 insertions, 11 deletions
diff --git a/config/src/vespa/config/common/configmanager.cpp b/config/src/vespa/config/common/configmanager.cpp
index a123a1aab1a..2fa40b503df 100644
--- a/config/src/vespa/config/common/configmanager.cpp
+++ b/config/src/vespa/config/common/configmanager.cpp
@@ -2,7 +2,6 @@
#include "configmanager.h"
#include "exceptions.h"
#include "configholder.h"
-#include <vespa/vespalib/util/atomic.h>
#include <thread>
#include <sstream>
@@ -30,7 +29,7 @@ ConfigManager::subscribe(const ConfigKey & key, uint64_t timeoutInMillis)
{
LOG(debug, "subscribing on def %s, configid %s", key.getDefName().c_str(), key.getConfigId().c_str());
- SubscriptionId id(vespalib::Atomic::postInc(&_idGenerator));
+ SubscriptionId id(_idGenerator.fetch_add(1));
IConfigHolder::SP holder(new ConfigHolder());
Source::UP source = _sourceFactory->createSource(holder, key);
diff --git a/config/src/vespa/config/common/configmanager.h b/config/src/vespa/config/common/configmanager.h
index 06ed2d617f7..740445292fe 100644
--- a/config/src/vespa/config/common/configmanager.h
+++ b/config/src/vespa/config/common/configmanager.h
@@ -34,7 +34,7 @@ public:
void reload(int64_t generation) override;
private:
- SubscriptionId _idGenerator;
+ std::atomic<SubscriptionId> _idGenerator;
SourceFactory::UP _sourceFactory;
int64_t _generation;
diff --git a/config/src/vespa/config/frt/connection.h b/config/src/vespa/config/frt/connection.h
index 3b3e6cd53ff..a5fad5a7ff5 100644
--- a/config/src/vespa/config/frt/connection.h
+++ b/config/src/vespa/config/frt/connection.h
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
+#include <vespa/vespalib/stllike/string.h>
class FRT_RPCRequest;
class FRT_IRequestWait;
diff --git a/config/src/vespa/config/frt/frtconnection.cpp b/config/src/vespa/config/frt/frtconnection.cpp
index 3503c95ba61..bcdec9a4537 100644
--- a/config/src/vespa/config/frt/frtconnection.cpp
+++ b/config/src/vespa/config/frt/frtconnection.cpp
@@ -1,6 +1,5 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "frtconnection.h"
-#include <vespa/vespalib/util/atomic.h>
#include <vespa/config/common/errorcode.h>
#include <vespa/fnet/frt/supervisor.h>
#include <vespa/fnet/frt/target.h>
@@ -88,7 +87,7 @@ void FRTConnection::calculateSuspension(ErrorType type)
int64_t delay = 0;
switch(type) {
case TRANSIENT:
- Atomic::postInc(&_transientFailures);
+ _transientFailures.fetch_add(1);
delay = _transientFailures * getTransientDelay();
if (delay > getMaxTransientDelay()) {
delay = getMaxTransientDelay();
@@ -96,7 +95,7 @@ void FRTConnection::calculateSuspension(ErrorType type)
LOG(warning, "Connection to %s failed or timed out", _address.c_str());
break;
case FATAL:
- Atomic::postInc(&_fatalFailures);
+ _fatalFailures.fetch_add(1);
delay = _fatalFailures * getFatalDelay();
if (delay > getMaxFatalDelay()) {
delay = getMaxFatalDelay();
diff --git a/config/src/vespa/config/frt/frtconnection.h b/config/src/vespa/config/frt/frtconnection.h
index 06f05200252..df57cfae92f 100644
--- a/config/src/vespa/config/frt/frtconnection.h
+++ b/config/src/vespa/config/frt/frtconnection.h
@@ -1,11 +1,10 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <string>
+#include "connection.h"
#include <vespa/vespalib/util/sync.h>
-#include <vespa/vespalib/stllike/string.h>
#include <vespa/config/common/timingvalues.h>
-#include "connection.h"
+#include <atomic>
class FRT_Supervisor;
class FRT_Target;
@@ -23,8 +22,8 @@ private:
FRT_Target* _target;
int64_t _suspendedUntil;
int64_t _suspendWarned;
- int _transientFailures;
- int _fatalFailures;
+ std::atomic<int> _transientFailures;
+ std::atomic<int> _fatalFailures;
int64_t _transientDelay;
int64_t _fatalDelay;