);
}
- template<class F, class Tuple, class ...Unpacked>
+ template <class F, class Tuple, class... Unpacked>
static typename std::enable_if<ExprIsUnpacked<Tuple, Unpacked...>::value,
- Ret
- >::type call(const F& f, Tuple&& t, Unpacked&&... unp) {
+ Ret>::type
+ call(const F& f, Tuple&& /* t */, Unpacked&&... unp) {
return makeCallable(f)(std::forward<Unpacked>(unp)...);
}
};
return r;
}
- void deallocate(void* p) {
+ void deallocate(void* /* p */) {
// Deallocate? Never!
}
*/
template <class Alloc>
struct ArenaAllocatorTraits {
- static size_t goodSize(const Alloc& alloc, size_t size) {
- return size;
- }
+ static size_t goodSize(const Alloc& /* alloc */, size_t size) { return size; }
};
template <>
struct ArenaAllocatorTraits<SysAlloc> {
- static size_t goodSize(const SysAlloc& alloc, size_t size) {
+ static size_t goodSize(const SysAlloc& /* alloc */, size_t size) {
return goodMallocSize(size);
}
};
struct AtomicHashArrayLinearProbeFcn
{
- inline size_t operator()(size_t idx, size_t numProbes, size_t capacity) const{
+ inline size_t operator()(size_t idx,
+ size_t /* numProbes */,
+ size_t capacity) const {
idx += 1; // linear probing
// Avoid modulus because it's slow
};
template <typename NotKeyT, typename KeyT>
-inline void checkLegalKeyIfKeyTImpl(NotKeyT ignored, KeyT emptyKey,
- KeyT lockedKey, KeyT erasedKey) {
-}
+inline void checkLegalKeyIfKeyTImpl(NotKeyT /* ignored */,
+ KeyT /* emptyKey */,
+ KeyT /* lockedKey */,
+ KeyT /* erasedKey */) {}
template <typename KeyT>
inline void checkLegalKeyIfKeyTImpl(KeyT key_in, KeyT emptyKey,
}
// post-increment
- ConstIterator operator++ (int dummy) {
+ ConstIterator operator++(int /* dummy */) {
auto prev = *this;
++*this;
return prev;
#elif defined(__clang__)
template <class T>
-__attribute__((__optnone__)) void doNotOptimizeAway(T&& datum) {
-}
+__attribute__((__optnone__)) void doNotOptimizeAway(T&& /* datum */) {}
#else
void addRef() { }
void releaseRef() { }
- void add(NodeType* node) { }
+ void add(NodeType* /* node */) {}
NodeAlloc& alloc() { return alloc_; }
return folly::StringPiece(value).size();
}
-template<>
-inline size_t estimateSpaceNeeded(std::nullptr_t value) {
+template <>
+inline size_t estimateSpaceNeeded(std::nullptr_t /* value */) {
return 0;
}
template <class Delimiter, class T, class Tgt>
typename std::enable_if<
- IsSomeString<typename std::remove_pointer<Tgt>::type>
- ::value>::type
-toAppendDelimStrImpl(const Delimiter& delim, const T& v, Tgt result) {
+ IsSomeString<typename std::remove_pointer<Tgt>::type>::value>::type
+toAppendDelimStrImpl(const Delimiter& /* delim */, const T& v, Tgt result) {
toAppend(v, result);
}
* Variadic base case: do nothing.
*/
template <class Tgt>
-typename std::enable_if<IsSomeString<Tgt>::value>::type
-toAppend(Tgt* result) {
-}
+typename std::enable_if<IsSomeString<Tgt>::value>::type toAppend(
+ Tgt* /* result */) {}
/**
* Variadic base case: do nothing.
*/
template <class Delimiter, class Tgt>
-typename std::enable_if<IsSomeString<Tgt>::value>::type
-toAppendDelim(const Delimiter& delim, Tgt* result) {
-}
+typename std::enable_if<IsSomeString<Tgt>::value>::type toAppendDelim(
+ const Delimiter& /* delim */, Tgt* /* result */) {}
/**
* 1 element: same as toAppend.
*/
template <class Delimiter, class T, class Tgt>
-typename std::enable_if<IsSomeString<Tgt>::value>::type
-toAppendDelim(const Delimiter& delim, const T& v, Tgt* tgt) {
+typename std::enable_if<IsSomeString<Tgt>::value>::type toAppendDelim(
+ const Delimiter& /* delim */, const T& v, Tgt* tgt) {
toAppend(v, tgt);
}
* toDelim<SomeString>(SomeString str) returns itself.
*/
template <class Tgt, class Delim, class Src>
-typename std::enable_if<
- IsSomeString<Tgt>::value && std::is_same<Tgt, Src>::value,
- Tgt>::type
-toDelim(const Delim& delim, const Src & value) {
+typename std::enable_if<IsSomeString<Tgt>::value &&
+ std::is_same<Tgt, Src>::value,
+ Tgt>::type
+toDelim(const Delim& /* delim */, const Src& value) {
return value;
}
template<typename T>
struct Dereferencer {
- static inline void
- derefToCache(T* mem, const dynamic::const_item_iterator& it) {
+ static inline void derefToCache(
+ T* /* mem */, const dynamic::const_item_iterator& /* it */) {
throw TypeError("array", dynamic::Type::OBJECT);
}
}
#endif
- basic_fbstring(const basic_fbstring& str, size_type pos,
- size_type n = npos, const A& a = A()) {
+ basic_fbstring(const basic_fbstring& str,
+ size_type pos,
+ size_type n = npos,
+ const A& /* a */ = A()) {
assign(str, pos, n);
}
}
private:
- template <class FwdIterator>
- bool replaceAliased(iterator i1, iterator i2,
- FwdIterator s1, FwdIterator s2, std::false_type) {
+ template <class FwdIterator>
+ bool replaceAliased(iterator /* i1 */,
+ iterator /* i2 */,
+ FwdIterator /* s1 */,
+ FwdIterator /* s2 */,
+ std::false_type) {
return false;
}
class TryFormatValue {
public:
template <class FormatCallback>
- static void formatOrFail(T& value, FormatArg& arg, FormatCallback& cb) {
+ static void formatOrFail(T& /* value */,
+ FormatArg& arg,
+ FormatCallback& /* cb */) {
arg.error("No formatter available for this type");
}
};
static constexpr size_t valueCount = std::tuple_size<Tuple>::value;
template <size_t K, class Callback>
- typename std::enable_if<K == valueCount>::type
- doFormatFrom(size_t i, FormatArg& arg, Callback& cb) const {
+ typename std::enable_if<K == valueCount>::type doFormatFrom(
+ size_t i, FormatArg& arg, Callback& /* cb */) const {
arg.enforce("tuple index out of range, max=", i);
}
template <class U> StlAllocator(const StlAllocator<Alloc, U>& other)
: alloc_(other.alloc()) { }
- T* allocate(size_t n, const void* hint = nullptr) {
+ T* allocate(size_t n, const void* /* hint */ = nullptr) {
return static_cast<T*>(alloc_->allocate(n * sizeof(T)));
}
- void deallocate(T* p, size_t n) {
- alloc_->deallocate(p);
- }
+ void deallocate(T* p, size_t /* n */) { alloc_->deallocate(p); }
size_t max_size() const {
return std::numeric_limits<size_t>::max();
bool canTimeOut() { return true; }
bool shouldTimeOut() { return true; }
- bool doWait(Futex& futex, uint32_t expected, uint32_t waitMask) {
+ bool doWait(Futex& /* futex */,
+ uint32_t /* expected */,
+ uint32_t /* waitMask */) {
return false;
}
};
return getEntry().try_get_fast();
}
- explicit Singleton(std::nullptr_t _ = nullptr,
- typename Singleton::TeardownFunc t = nullptr) :
- Singleton ([]() { return new T; }, std::move(t)) {
- }
+ explicit Singleton(std::nullptr_t /* _ */ = nullptr,
+ typename Singleton::TeardownFunc t = nullptr)
+ : Singleton([]() { return new T; }, std::move(t)) {}
explicit Singleton(typename Singleton::CreateFunc c,
typename Singleton::TeardownFunc t = nullptr) {
* the injection. The returned mock singleton is functionality identical to
* regular singletons.
*/
- static void make_mock(std::nullptr_t c = nullptr,
+ static void make_mock(std::nullptr_t /* c */ = nullptr,
typename Singleton<T>::TeardownFunc t = nullptr) {
make_mock([]() { return new T; }, t);
}
return arena->allocate(size);
}
- void deallocate(void* p) {
+ void deallocate(void* /* p */) {
// Deallocate? Never!
}
#endif
template <typename T>
-inline bool setThreadName(T id, StringPiece name) {
+inline bool setThreadName(T /* id */, StringPiece /* name */) {
static_assert(
std::is_same<T, pthread_t>::value ||
std::is_same<T, std::thread::native_handle_type>::value,
AccessSpreaderArray<std::atomic,128>::sharedInstance = {};
/// Always claims to be on CPU zero, node zero
-static int degenerateGetcpu(unsigned* cpu, unsigned* node, void* unused) {
+static int degenerateGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
if (cpu != nullptr) {
*cpu = 0;
}
/// Fills the thread id into the cpu and node out params (if they
/// are non-null). This method is intended to act like getcpu when a
/// fast-enough form of getcpu isn't available or isn't desired
- static int getcpu(unsigned* cpu, unsigned* node, void* unused) {
+ static int getcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
auto id = ThreadId::get();
if (cpu) {
*cpu = id;
template <typename V, typename R>
struct ApplyVisitor1<V, R> {
- R operator()(size_t index, V&& visitor, void* ptr) const {
+ R operator()(size_t /* index */, V&& /* visitor */, void* /* ptr */) const {
CHECK(false); // NOTREACHED
}
};
template <typename V, typename R>
struct ApplyConstVisitor1<V, R> {
- R operator()(size_t index, V&& visitor, void* ptr) const {
+ R operator()(size_t /* index */, V&& /* visitor */, void* /* ptr */) const {
CHECK(false); // NOTREACHED
}
};
return r;
}
-inline void incr(ssize_t n) { }
+inline void incr(ssize_t /* n */) {}
inline void incr(ssize_t n, off_t& offset) { offset += n; }
// Wrap call to read/pread/write/pwrite(fd, buf, count, offset?) to retry on
// Otherwise, null, being (void*)0, would print as 0.
template <>
struct dynamic::PrintImpl<void*> {
- static void print(dynamic const& d, std::ostream& out, void* const& nul) {
+ static void print(dynamic const& /* d */,
+ std::ostream& out,
+ void* const& nul) {
DCHECK_EQ((void*)0, nul);
out << "null";
}
// use explicitly.
struct Default {
- static bool supported(const folly::CpuId& cpuId = {}) {
- return true;
- }
+ static bool supported(const folly::CpuId& /* cpuId */ = {}) { return true; }
static inline uint64_t popcount(uint64_t value) {
return __builtin_popcountll(value);
}
}
void NestedCommandLineApp::displayHelp(
- const po::variables_map& globalOptions,
+ const po::variables_map& /* globalOptions */,
const std::vector<std::string>& args) {
if (args.empty()) {
// General help
bool is_composing() const override { return false; }
bool is_required() const override { return false; }
// We handle setting the GFlags from parse(), so notify() does nothing.
- void notify(const boost::any& valueStore) const override { }
+ void notify(const boost::any& /* valueStore */) const override {}
bool apply_default(boost::any& valueStore) const override {
// We're using the *current* rather than *default* value here, and
// this is intentional; GFlags-using programs assign to FLAGS_foo
void parse(boost::any& valueStore,
const std::vector<std::string>& tokens,
- bool utf8) const override;
+ bool /* utf8 */) const override;
private:
virtual T parseValue(const std::vector<std::string>& tokens) const = 0;
- virtual void transform(T& val) const { }
+ virtual void transform(T& /* val */) const {}
mutable std::shared_ptr<GFlagInfo<T>> info_;
};
template <class T>
void GFlagValueSemanticBase<T>::parse(boost::any& valueStore,
const std::vector<std::string>& tokens,
- bool utf8) const {
+ bool /* utf8 */) const {
T val;
try {
val = this->parseValue(tokens);
: Base(std::move(other)) {
}
- StringKeyedMap(StringKeyedMap&& other, const allocator_type& a) noexcept
- : Base(std::move(other)/*, a*/ /* not supported by gcc */) {
- }
+ StringKeyedMap(StringKeyedMap&& other, const allocator_type& /* a */) noexcept
+ : Base(std::move(other) /*, a*/ /* not supported by gcc */) {}
StringKeyedMap(std::initializer_list<value_type> il,
const key_compare& comp = key_compare(),
}
StringKeyedUnorderedMap(StringKeyedUnorderedMap&& other,
- const allocator_type& a) noexcept
- : Base(std::move(other)/*, a*/ /* not supported by gcc */) {
- }
+ const allocator_type& /* a */) noexcept
+ : Base(std::move(other) /*, a*/ /* not supported by gcc */) {}
StringKeyedUnorderedMap(std::initializer_list<value_type> il)
: StringKeyedUnorderedMap(il.begin(), il.end()) {
}
BasicStringKeyedUnorderedSet(BasicStringKeyedUnorderedSet&& rhs,
- const allocator_type& a) noexcept
- : Base(std::move(rhs)/* , a */ /* not supported by gcc */) {
+ const allocator_type& /* a */) noexcept
+ : Base(std::move(rhs) /* , a */ /* not supported by gcc */) {
assert(rhs.empty());
}
}
}
-int main(int argc, char *argv[]) {
+int main(int /* argc */, char* /* argv */ []) {
foo();
testExceptionPtr1();
testExceptionPtr2();
friend class StackCacheEntry;
- void giveBack(std::unique_ptr<StackCache> stackCache_) {
+ void giveBack(std::unique_ptr<StackCache> /* stackCache_ */) {
assert(inUse_ > 0);
--inUse_;
/* Note: we can add a free list for each size bucket
typename std::iterator_traits<InputIterator>::value_type()>::type, void
>::value, void>::type
inline collectAll(InputIterator first, InputIterator last) {
- forEach(first, last, [] (size_t id) {});
+ forEach(first, last, [](size_t /* id */) {});
}
template <class InputIterator>
folly::RequestContext::create();
auto rcontext3 = folly::RequestContext::get();
- fm.addTaskFinally([&]() {
- EXPECT_EQ(rcontext3, folly::RequestContext::get());
- baton3.wait();
- EXPECT_EQ(rcontext3, folly::RequestContext::get());
-
- return folly::Unit();
- },
- [&](Try<folly::Unit>&& t) {
- EXPECT_EQ(rcontext3, folly::RequestContext::get());
- checkRun3 = true;
- });
+ fm.addTaskFinally(
+ [&]() {
+ EXPECT_EQ(rcontext3, folly::RequestContext::get());
+ baton3.wait();
+ EXPECT_EQ(rcontext3, folly::RequestContext::get());
+
+ return folly::Unit();
+ },
+ [&](Try<folly::Unit>&& /* t */) {
+ EXPECT_EQ(rcontext3, folly::RequestContext::get());
+ checkRun3 = true;
+ });
folly::RequestContext::create();
auto rcontext = folly::RequestContext::get();
maybeDequeue();
}
-void AsyncIOQueue::onCompleted(AsyncIOOp* op) {
- maybeDequeue();
-}
+void AsyncIOQueue::onCompleted(AsyncIOOp* /* op */) { maybeDequeue(); }
void AsyncIOQueue::maybeDequeue() {
while (!queue_.empty() && asyncIO_->pending() < asyncIO_->capacity()) {
std::atomic<bool> gInRecursiveSignalHandler(false);
// Here be dragons.
-void innerSignalHandler(int signum, siginfo_t* info, void* uctx) {
+void innerSignalHandler(int signum, siginfo_t* info, void* /* uctx */) {
// First, let's only let one thread in here at a time.
pthread_t myId = pthread_self();
}
volatile bool handled = false;
-void handler(int num, siginfo_t* info, void* ctx) {
+void handler(int /* num */, siginfo_t* /* info */, void* /* ctx */) {
// Yes, getStackTrace and VLOG aren't async-signal-safe, but signals
// raised with raise() aren't "async" signals.
foo1();
}
template <class Reader, class List>
-void bmSkip(const List& list, const std::vector<uint32_t>& data,
- size_t logAvgSkip, size_t iters) {
+void bmSkip(const List& list,
+ const std::vector<uint32_t>& /* data */,
+ size_t logAvgSkip,
+ size_t iters) {
size_t avg = (size_t(1) << logAvgSkip);
size_t base = avg - (avg >> 2);
size_t mask = (avg > 1) ? (avg >> 1) - 1 : 0;
namespace {
void init(const std::string& cmd,
- const po::variables_map& options,
- const std::vector<std::string>& args) {
+ const po::variables_map& /* options */,
+ const std::vector<std::string>& /* args */) {
printf("running %s\n", cmd.c_str());
}
// Base case: empty typle -> empty tuple
template <>
struct TupleTo<std::tuple<>, std::tuple<>> {
- static std::tuple<> convert(const std::tuple<>& input) {
+ static std::tuple<> convert(const std::tuple<>& /* input */) {
return std::make_tuple();
}
};
template <typename T>
struct CollectContext {
- struct Nothing { explicit Nothing(int n) {} };
+ struct Nothing {
+ explicit Nothing(int /* n */) {}
+ };
using Result = typename std::conditional<
std::is_void<T>::value,
auto ctx = std::make_shared<UnorderedReduceContext>(
std::move(initial), std::move(func), std::distance(first, last));
- mapSetCallback<ItT>(first, last, [ctx](size_t i, Try<ItT>&& t) {
- folly::MoveWrapper<Try<ItT>> mt(std::move(t));
- // Futures can be completed in any order, simultaneously.
- // To make this non-blocking, we create a new Future chain in
- // the order of completion to reduce the values.
- // The spinlock just protects chaining a new Future, not actually
- // executing the reduce, which should be really fast.
- folly::MSLGuard lock(ctx->lock_);
- ctx->memo_ = ctx->memo_.then([ctx, mt](T&& v) mutable {
- // Either return a ItT&& or a Try<ItT>&& depending
- // on the type of the argument of func.
- return ctx->func_(std::move(v), mt->template get<IsTry::value, Arg&&>());
- });
- if (++ctx->numThens_ == ctx->numFutures_) {
- // After reducing the value of the last Future, fulfill the Promise
- ctx->memo_.setCallback_([ctx](Try<T>&& t2) {
- ctx->promise_.setValue(std::move(t2));
+ mapSetCallback<ItT>(
+ first,
+ last,
+ [ctx](size_t /* i */, Try<ItT>&& t) {
+ folly::MoveWrapper<Try<ItT>> mt(std::move(t));
+ // Futures can be completed in any order, simultaneously.
+ // To make this non-blocking, we create a new Future chain in
+ // the order of completion to reduce the values.
+ // The spinlock just protects chaining a new Future, not actually
+ // executing the reduce, which should be really fast.
+ folly::MSLGuard lock(ctx->lock_);
+ ctx->memo_ = ctx->memo_.then([ctx, mt](T&& v) mutable {
+ // Either return a ItT&& or a Try<ItT>&& depending
+ // on the type of the argument of func.
+ return ctx->func_(std::move(v),
+ mt->template get<IsTry::value, Arg&&>());
+ });
+ if (++ctx->numThens_ == ctx->numFutures_) {
+ // After reducing the value of the last Future, fulfill the Promise
+ ctx->memo_.setCallback_(
+ [ctx](Try<T>&& t2) { ctx->promise_.setValue(std::move(t2)); });
+ }
});
- }
- });
return ctx->promise_.getFuture();
}
if (f.isReady()) return;
FutureBatonType baton;
- f.setCallback_([&](const Try<T>& t) { baton.post(); });
+ f.setCallback_([&](const Try<T>& /* t */) { baton.post(); });
baton.wait();
assert(f.isReady());
}
/// Schedule a Func to be executed at time t, or as soon afterward as
/// possible. Expect millisecond resolution at best. Must be threadsafe.
- virtual void scheduleAt(Func&& a, TimePoint const& t) {
+ virtual void scheduleAt(Func&& /* a */, TimePoint const& /* t */) {
throw std::logic_error("unimplemented");
}
std::move(*std::get<sizeof...(ts2)>(o)));
}
- static std::tuple<Ts...> unwrap(std::tuple<folly::Try<Ts>...>&& o,
+ static std::tuple<Ts...> unwrap(std::tuple<folly::Try<Ts>...>&& /* o */,
Ts&&... ts) {
return std::tuple<Ts...>(std::forward<Ts>(ts)...);
}
};
-template <template <typename ...> class T, typename... Ts>
-void collectVariadicHelper(const std::shared_ptr<T<Ts...>>& ctx) {
+template <template <typename...> class T, typename... Ts>
+void collectVariadicHelper(const std::shared_ptr<T<Ts...>>& /* ctx */) {
// base case
}
// will try to wrap, so no exception_ptrs/rethrows are necessary.
void throwAndCatchWrappedImpl() {
makeFuture()
- .then([](Try<Unit>&&){ throw std::runtime_error("oh no"); })
+ .then([](Try<Unit>&&) { throw std::runtime_error("oh no"); })
.then([](Try<Unit>&& t) {
auto caught = t.withException<std::runtime_error>(
- [](const std::runtime_error& e){
+ [](const std::runtime_error& /* e */) {
// ...
});
CHECK(caught);
// The new way. Wrap an exception, and access it via the wrapper upstream
void throwWrappedAndCatchWrappedImpl() {
makeFuture()
- .then([](Try<Unit>&&){
+ .then([](Try<Unit>&&) {
return makeFuture<Unit>(std::runtime_error("oh no"));
})
- .then([](Try<Unit>&& t){
+ .then([](Try<Unit>&& t) {
auto caught = t.withException<std::runtime_error>(
- [](const std::runtime_error& e){
+ [](const std::runtime_error& /* e */) {
// ...
});
CHECK(caught);
TEST(Collect, noDefaultConstructor) {
struct A {
- explicit A(size_t x) {}
+ explicit A(size_t /* x */) {}
};
auto f1 = makeFuture(A(1));
class CrappyExecutor : public Executor {
public:
- void add(Func f) override {
- throw std::runtime_error("bad");
- }
+ void add(Func /* f */) override { throw std::runtime_error("bad"); }
};
TEST(Executor, CrappyExecutor) {
// By reference
{
- auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t& e) { flag(); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ }).onError([&](eggs_t& /* e */) { flag(); });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t& e) { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](eggs_t& /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// By value
{
- auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t e) { flag(); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ }).onError([&](eggs_t /* e */) { flag(); });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t e) { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](eggs_t /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// Polymorphic
{
- auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (std::exception& e) { flag(); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ }).onError([&](std::exception& /* e */) { flag(); });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (std::exception& e) { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](std::exception& /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// Non-exceptions
{
- auto f = makeFuture()
- .then([] { throw -1; })
- .onError([&] (int e) { flag(); });
+ auto f = makeFuture().then([] {
+ throw - 1;
+ }).onError([&](int /* e */) { flag(); });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
{
auto f = makeFuture()
- .then([] { throw -1; })
- .onError([&] (int e) { flag(); return makeFuture(); });
+ .then([] { throw - 1; })
+ .onError([&](int /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// Mutable lambda
{
- auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t& e) mutable { flag(); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ }).onError([&](eggs_t& /* e */) mutable { flag(); });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (eggs_t& e) mutable { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](eggs_t& /* e */) mutable {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// No throw
{
auto f = makeFuture()
- .then([] { return 42; })
- .onError([&] (eggs_t& e) { flag(); return -1; });
+ .then([] { return 42; })
+ .onError([&](eggs_t& /* e */) {
+ flag();
+ return -1;
+ });
EXPECT_NO_FLAG();
EXPECT_EQ(42, f.value());
}
{
auto f = makeFuture()
- .then([] { return 42; })
- .onError([&] (eggs_t& e) { flag(); return makeFuture<int>(-1); });
+ .then([] { return 42; })
+ .onError([&](eggs_t& /* e */) {
+ flag();
+ return makeFuture<int>(-1);
+ });
EXPECT_NO_FLAG();
EXPECT_EQ(42, f.value());
}
// Catch different exception
{
- auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (std::runtime_error& e) { flag(); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ }).onError([&](std::runtime_error& /* e */) { flag(); });
EXPECT_NO_FLAG();
EXPECT_THROW(f.value(), eggs_t);
}
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (std::runtime_error& e) { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](std::runtime_error& /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_NO_FLAG();
EXPECT_THROW(f.value(), eggs_t);
}
// Returned value propagates
{
- auto f = makeFuture()
- .then([] { throw eggs; return 0; })
- .onError([&] (eggs_t& e) { return 42; });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ return 0;
+ }).onError([&](eggs_t& /* e */) { return 42; });
EXPECT_EQ(42, f.value());
}
// Returned future propagates
{
- auto f = makeFuture()
- .then([] { throw eggs; return 0; })
- .onError([&] (eggs_t& e) { return makeFuture<int>(42); });
+ auto f = makeFuture().then([] {
+ throw eggs;
+ return 0;
+ }).onError([&](eggs_t& /* e */) { return makeFuture<int>(42); });
EXPECT_EQ(42, f.value());
}
// exception_wrapper, return Future<T>
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (exception_wrapper e) { flag(); return makeFuture(); });
+ .then([] { throw eggs; })
+ .onError([&](exception_wrapper /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
// exception_wrapper, return Future<T> but throw
{
auto f = makeFuture()
- .then([]{ throw eggs; return 0; })
- .onError([&] (exception_wrapper e) {
- flag();
- throw eggs;
- return makeFuture<int>(-1);
- });
+ .then([] {
+ throw eggs;
+ return 0;
+ })
+ .onError([&](exception_wrapper /* e */) {
+ flag();
+ throw eggs;
+ return makeFuture<int>(-1);
+ });
EXPECT_FLAG();
EXPECT_THROW(f.value(), eggs_t);
}
// exception_wrapper, return T
{
auto f = makeFuture()
- .then([]{ throw eggs; return 0; })
- .onError([&] (exception_wrapper e) {
- flag();
- return -1;
- });
+ .then([] {
+ throw eggs;
+ return 0;
+ })
+ .onError([&](exception_wrapper /* e */) {
+ flag();
+ return -1;
+ });
EXPECT_FLAG();
EXPECT_EQ(-1, f.value());
}
// exception_wrapper, return T but throw
{
auto f = makeFuture()
- .then([]{ throw eggs; return 0; })
- .onError([&] (exception_wrapper e) {
- flag();
- throw eggs;
- return -1;
- });
+ .then([] {
+ throw eggs;
+ return 0;
+ })
+ .onError([&](exception_wrapper /* e */) {
+ flag();
+ throw eggs;
+ return -1;
+ });
EXPECT_FLAG();
EXPECT_THROW(f.value(), eggs_t);
}
// const exception_wrapper&
{
auto f = makeFuture()
- .then([] { throw eggs; })
- .onError([&] (const exception_wrapper& e) {
- flag();
- return makeFuture();
- });
+ .then([] { throw eggs; })
+ .onError([&](const exception_wrapper& /* e */) {
+ flag();
+ return makeFuture();
+ });
EXPECT_FLAG();
EXPECT_NO_THROW(f.value());
}
EXPECT_TRUE(flag); flag = false;
Promise<Unit> p;
- auto f = p.getFuture().then([&](Try<Unit>&& t) { flag = true; });
+ auto f = p.getFuture().then([&](Try<Unit>&& /* t */) { flag = true; });
EXPECT_FALSE(flag);
EXPECT_FALSE(f.isReady());
p.setValue();
});
EXPECT_TRUE(flag); flag = false;
- auto f = makeFuture<int>(eggs).then([&](int i){});
+ auto f = makeFuture<int>(eggs).then([&](int /* i */) {});
EXPECT_THROW(f.value(), eggs_t);
f = makeFuture<Unit>(eggs).then([&]{});
.then([&](Try<int>&& t) { flag = true; EXPECT_EQ(42, t.value()); });
EXPECT_TRUE(flag); flag = false;
- makeFuture()
- .then([]{ return makeFuture(); })
- .then([&](Try<Unit>&& t) { flag = true; });
+ makeFuture().then([] {
+ return makeFuture();
+ }).then([&](Try<Unit>&& /* t */) { flag = true; });
EXPECT_TRUE(flag); flag = false;
}
Promise<int64_t> promise;
auto ptr = std::make_shared<Future<int64_t>>(promise.getFuture());
- ptr->then(
- [ptr] (folly::Try<int64_t>&& uid) mutable {
- EXPECT_EQ(1, ptr.use_count());
+ ptr->then([ptr](folly::Try<int64_t>&& /* uid */) mutable {
+ EXPECT_EQ(1, ptr.use_count());
- // Leaving no references to ourselves.
- ptr.reset();
- EXPECT_EQ(0, ptr.use_count());
- }
- );
+ // Leaving no references to ourselves.
+ ptr.reset();
+ EXPECT_EQ(0, ptr.use_count());
+ });
EXPECT_EQ(2, ptr.use_count());
if (throwsOnAdd_) { throw std::exception(); }
v_.emplace_back(std::move(f));
}
- void addWithPriority(Func f, int8_t prio) override { add(std::move(f)); }
+ void addWithPriority(Func f, int8_t /* prio */) override {
+ add(std::move(f));
+ }
uint8_t getNumPriorities() const override { return numPriorities_; }
void setHandlesPriorities() { numPriorities_ = 2; }
RequestContext::get()->setContextData("key",
folly::make_unique<MyRequestData>(true));
auto checker = [](int lineno) {
- return [lineno](Try<int>&& t) {
+ return [lineno](Try<int>&& /* t */) {
auto d = static_cast<MyRequestData*>(
RequestContext::get()->getContextData("key"));
EXPECT_TRUE(d && d->value) << "on line " << lineno;
TEST(Interrupt, handleThenInterrupt) {
Promise<int> p;
bool flag = false;
- p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+ p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
p.getFuture().cancel();
EXPECT_TRUE(flag);
}
Promise<int> p;
bool flag = false;
p.getFuture().cancel();
- p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+ p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
EXPECT_TRUE(flag);
}
TEST(Interrupt, interruptAfterFulfilNoop) {
Promise<Unit> p;
bool flag = false;
- p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+ p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
p.setValue();
p.getFuture().cancel();
EXPECT_FALSE(flag);
TEST(Interrupt, secondInterruptNoop) {
Promise<Unit> p;
int count = 0;
- p.setInterruptHandler([&](const exception_wrapper& e) { count++; });
+ p.setInterruptHandler([&](const exception_wrapper& /* e */) { count++; });
auto f = p.getFuture();
f.cancel();
f.cancel();
TEST(Interrupt, withinTimedOut) {
Promise<int> p;
Baton<> done;
- p.setInterruptHandler([&](const exception_wrapper& e) { done.post(); });
+ p.setInterruptHandler([&](const exception_wrapper& /* e */) { done.post(); });
p.getFuture().within(std::chrono::milliseconds(1));
// Give it 100ms to time out and call the interrupt handler
auto t = std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
fs.push_back(makeFuture(2));
fs.push_back(makeFuture(3));
- Future<double> f = unorderedReduce(fs.begin(), fs.end(), 0.0,
- [](double a, int&& b){
- return double(b);
- });
+ Future<double> f =
+ unorderedReduce(fs.begin(),
+ fs.end(),
+ 0.0,
+ [](double /* a */, int&& b) { return double(b); });
EXPECT_EQ(3.0, f.get());
}
{
fs.push_back(p2.getFuture());
fs.push_back(p3.getFuture());
- Future<double> f = unorderedReduce(fs.begin(), fs.end(), 0.0,
- [](double a, int&& b){
- return double(b);
- });
+ Future<double> f =
+ unorderedReduce(fs.begin(),
+ fs.end(),
+ 0.0,
+ [](double /* a */, int&& b) { return double(b); });
p3.setValue(3);
p2.setValue(2);
p1.setValue(1);
fs.push_back(p2.getFuture());
fs.push_back(p3.getFuture());
- Future<double> f = unorderedReduce(fs.begin(), fs.end(), 0.0,
- [](double a, int&& b){
- return b + 0.0;
- });
+ Future<double> f =
+ unorderedReduce(fs.begin(),
+ fs.end(),
+ 0.0,
+ [](double /* a */, int&& b) { return b + 0.0; });
p3.setValue(3);
p2.setException(exception_wrapper(std::runtime_error("blah")));
p1.setValue(1);
: v_(other.v_), copied_(other.copied_ + 1), moved_(other.moved_) {}
Widget(Widget&& other) noexcept
: v_(other.v_), copied_(other.copied_), moved_(other.moved_ + 1) {}
- Widget& operator=(const Widget& other)
- { throw std::logic_error("unexpected copy assignment"); }
- Widget& operator=(Widget&& other)
- { throw std::logic_error("unexpected move assignment"); }
+ Widget& operator=(const Widget& /* other */) {
+ throw std::logic_error("unexpected copy assignment");
+ }
+ Widget& operator=(Widget&& /* other */) {
+ throw std::logic_error("unexpected move assignment");
+ }
};
TEST(Then, tryConstructor) {
std::mutex& ps_mutex) {
return [&]() mutable {
auto p = std::make_shared<Promise<Unit>>();
- p->setInterruptHandler([&](exception_wrapper const& e) {
- ++interrupt;
- });
+ p->setInterruptHandler(
+ [&](exception_wrapper const& /* e */) { ++interrupt; });
ps_mutex.lock();
ps.push(p);
ps_mutex.unlock();
bool failure = false;
auto thunk = makeThunk(ps, interrupt, ps_mutex);
- auto f = folly::times(3, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ auto f = folly::times(3, thunk).then([&]() mutable {
+ complete = true;
+ }).onError([&](FutureException& /* e */) { failure = true; });
popAndFulfillPromise(ps, ps_mutex);
EXPECT_FALSE(complete);
bool failure = false;
auto thunk = makeThunk(ps, interrupt, ps_mutex);
- auto f = folly::times(3, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ auto f = folly::times(3, thunk).then([&]() mutable {
+ complete = true;
+ }).onError([&](FutureException& /* e */) { failure = true; });
popAndFulfillPromise(ps, ps_mutex);
EXPECT_FALSE(complete);
bool failure = false;
auto thunk = makeThunk(ps, interrupt, ps_mutex);
- auto f = folly::times(3, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ auto f = folly::times(3, thunk).then([&]() mutable {
+ complete = true;
+ }).onError([&](FutureException& /* e */) { failure = true; });
EXPECT_EQ(0, interrupt);
TEST_F(ViaFixture, threadHops) {
auto westThreadId = std::this_thread::get_id();
- auto f = via(eastExecutor.get()).then([=](Try<Unit>&& t) {
- EXPECT_NE(std::this_thread::get_id(), westThreadId);
- return makeFuture<int>(1);
- }).via(westExecutor.get()
- ).then([=](Try<int>&& t) {
- EXPECT_EQ(std::this_thread::get_id(), westThreadId);
- return t.value();
- });
+ auto f = via(eastExecutor.get())
+ .then([=](Try<Unit>&& /* t */) {
+ EXPECT_NE(std::this_thread::get_id(), westThreadId);
+ return makeFuture<int>(1);
+ })
+ .via(westExecutor.get())
+ .then([=](Try<int>&& t) {
+ EXPECT_EQ(std::this_thread::get_id(), westThreadId);
+ return t.value();
+ });
EXPECT_EQ(f.getVia(waiter.get()), 1);
}
}
struct PriorityExecutor : public Executor {
- void add(Func f) override {}
+ void add(Func /* f */) override {}
void addWithPriority(Func f, int8_t priority) override {
int mid = getNumPriorities() / 2;
class DummyDrivableExecutor : public DrivableExecutor {
public:
- void add(Func f) override {}
+ void add(Func /* f */) override {}
void drive() override { ran = true; }
bool ran{false};
};
std::mutex& ps_mutex) {
return [&]() mutable {
auto p = std::make_shared<Promise<Unit>>();
- p->setInterruptHandler([&](exception_wrapper const& e) {
- ++interrupt;
- });
+ p->setInterruptHandler(
+ [&](exception_wrapper const& /* e */) { ++interrupt; });
ps_mutex.lock();
ps.push(p);
ps_mutex.unlock();
auto pred = makePred(i);
auto thunk = makeThunk(ps, interrupt, ps_mutex);
auto f = folly::whileDo(pred, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ .then([&]() mutable { complete = true; })
+ .onError([&](FutureException& /* e */) { failure = true; });
popAndFulfillPromise(ps, ps_mutex);
EXPECT_FALSE(complete);
auto pred = makePred(i);
auto thunk = makeThunk(ps, interrupt, ps_mutex);
auto f = folly::whileDo(pred, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ .then([&]() mutable { complete = true; })
+ .onError([&](FutureException& /* e */) { failure = true; });
popAndFulfillPromise(ps, ps_mutex);
EXPECT_FALSE(complete);
auto pred = makePred(i);
auto thunk = makeThunk(ps, interrupt, ps_mutex);
auto f = folly::whileDo(pred, thunk)
- .then([&]() mutable { complete = true; })
- .onError([&] (FutureException& e) { failure = true; });
+ .then([&]() mutable { complete = true; })
+ .onError([&](FutureException& /* e */) { failure = true; });
EXPECT_EQ(0, interrupt);
}
{
// int -> Future<Unit>
- auto res = reduce(
- window(
- std::vector<int>({1, 2, 3}),
- [](int i) { return makeFuture(); },
- 2),
- 0,
- [](int sum, const Try<Unit>& b) {
- EXPECT_TRUE(b.hasValue());
- return sum + 1;
- }).get();
+ auto res = reduce(window(std::vector<int>({1, 2, 3}),
+ [](int /* i */) { return makeFuture(); },
+ 2),
+ 0,
+ [](int sum, const Try<Unit>& b) {
+ EXPECT_TRUE(b.hasValue());
+ return sum + 1;
+ }).get();
EXPECT_EQ(3, res);
}
{
template <class Value>
class InfiniteImpl {
public:
- bool test(const Value& current) const { return true; }
+ bool test(const Value& /* current */) const { return true; }
void step(Value& current) const { ++current; }
static constexpr bool infinite = true;
};
"false or hang. 'any' or 'notEmpty' will either return true "
"or hang.");
bool ans = emptyResult;
- source | [&](Value v) -> bool {
- ans = !emptyResult;
- return false;
- };
+ source |
+ [&](Value /* v */) -> bool {
+ ans = !emptyResult;
+ return false;
+ };
return ans;
}
};
size_t compose(const GenImpl<Value, Source>& source) const {
static_assert(!Source::infinite, "Cannot count infinite source");
return foldl(size_t(0),
- [](size_t accum, Value v) {
- return accum + 1;
- }).compose(source);
+ [](size_t accum, Value /* v */) { return accum + 1; })
+ .compose(source);
}
};
return &(storage->buf);
}
-void* IOBuf::operator new(size_t size, void* ptr) {
- return ptr;
-}
+void* IOBuf::operator new(size_t /* size */, void* ptr) { return ptr; }
void IOBuf::operator delete(void* ptr) {
auto* storageAddr = static_cast<uint8_t*>(ptr) - offsetof(HeapStorage, buf);
}
}
-void IOBuf::freeInternalBuf(void* buf, void* userData) {
+void IOBuf::freeInternalBuf(void* /* buf */, void* userData) {
auto* storage = static_cast<HeapStorage*>(userData);
releaseStorage(storage, kDataInUse);
}
data_ = buf_;
}
-IOBuf::IOBuf(CopyBufferOp op, const void* buf, uint64_t size,
- uint64_t headroom, uint64_t minTailroom)
- : IOBuf(CREATE, headroom + size + minTailroom) {
+IOBuf::IOBuf(CopyBufferOp /* op */,
+ const void* buf,
+ uint64_t size,
+ uint64_t headroom,
+ uint64_t minTailroom)
+ : IOBuf(CREATE, headroom + size + minTailroom) {
advance(headroom);
memcpy(writableData(), buf, size);
append(size);
delete this;
}
- void handshakeSuc(AsyncSSLSocket* sock) noexcept override {
+ void handshakeSuc(AsyncSSLSocket* /* sock */) noexcept override {
VLOG(7) << "client handshake success";
if (callback_) {
callback_->connectSuccess();
delete this;
}
- void handshakeErr(AsyncSSLSocket* socket,
+ void handshakeErr(AsyncSSLSocket* /* socket */,
const AsyncSocketException& ex) noexcept override {
LOG(ERROR) << "client handshakeErr: " << ex.what();
fail(ex);
getSSLExDataIndex()));
}
-void AsyncSSLSocket::failHandshake(const char* fn,
- const AsyncSocketException& ex) {
+void AsyncSSLSocket::failHandshake(const char* /* fn */,
+ const AsyncSocketException& ex) {
startFail();
if (handshakeTimeout_.isScheduled()) {
handshakeTimeout_.cancelTimeout();
return n;
}
-void
-AsyncSSLSocket::sslInfoCallback(const SSL *ssl, int where, int ret) {
+void AsyncSSLSocket::sslInfoCallback(const SSL* ssl, int where, int /* ret */) {
AsyncSSLSocket *sslSocket = AsyncSSLSocket::getFromSSL(ssl);
if (sslSocket->handshakeComplete_ && (where & SSL_CB_HANDSHAKE_START)) {
sslSocket->renegotiateAttempted_ = true;
clientHelloInfo_->clientHelloBuf_.clear();
}
-void
-AsyncSSLSocket::clientHelloParsingCallback(int written, int version,
- int contentType, const void *buf, size_t len, SSL *ssl, void *arg)
-{
+void AsyncSSLSocket::clientHelloParsingCallback(int written,
+ int /* version */,
+ int contentType,
+ const void* buf,
+ size_t len,
+ SSL* ssl,
+ void* arg) {
AsyncSSLSocket *sock = static_cast<AsyncSSLSocket*>(arg);
if (written != 0) {
sock->resetClientHelloParsing(ssl);
}
}
-void AsyncServerSocket::handlerReady(
- uint16_t events, int fd, sa_family_t addressFamily) noexcept {
+void AsyncServerSocket::handlerReady(uint16_t /* events */,
+ int fd,
+ sa_family_t addressFamily) noexcept {
assert(!callbacks_.empty());
DestructorGuard dg(this);
signalEvents_.erase(it);
}
-void AsyncSignalHandler::libeventCallback(int signum, short events,
- void* arg) {
+void AsyncSignalHandler::libeventCallback(int signum,
+ short /* events */,
+ void* arg) {
AsyncSignalHandler* handler = static_cast<AsyncSignalHandler*>(arg);
handler->signalReceived(signum);
}
}
}
-ssize_t AsyncSocket::performRead(void** buf, size_t* buflen, size_t* offset) {
+ssize_t AsyncSocket::performRead(void** buf,
+ size_t* buflen,
+ size_t* /* offset */) {
VLOG(5) << "AsyncSocket::performRead() this=" << this
<< ", buf=" << *buf << ", buflen=" << *buflen;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT)
-int SSLContext::alpnSelectCallback(SSL* ssl,
+int SSLContext::alpnSelectCallback(SSL* /* ssl */,
const unsigned char** out,
unsigned char* outlen,
const unsigned char* in,
}
#endif
-int SSLContext::selectNextProtocolCallback(
- SSL* ssl, unsigned char **out, unsigned char *outlen,
- const unsigned char *server, unsigned int server_len, void *data) {
+int SSLContext::selectNextProtocolCallback(SSL* /* ssl */,
+ unsigned char** out,
+ unsigned char* outlen,
+ const unsigned char* server,
+ unsigned int server_len,
+ void* data) {
SSLContext* ctx = (SSLContext*)data;
if (ctx->advertisedNextProtocols_.size() > 1) {
bool OpenSSLUtils::validatePeerCertNames(X509* cert,
const sockaddr* addr,
- socklen_t addrLen) {
+ socklen_t /* addrLen */) {
// Try to extract the names within the SAN extension from the certificate
auto altNames =
reinterpret_cast<STACK_OF(GENERAL_NAME)*>(
}
ScopedEventBaseThread::ScopedEventBaseThread(
- ScopedEventBaseThread&& other) noexcept = default;
+ ScopedEventBaseThread&& /* other */) noexcept = default;
ScopedEventBaseThread& ScopedEventBaseThread::operator=(
- ScopedEventBaseThread&& other) noexcept = default;
+ ScopedEventBaseThread&& /* other */) noexcept = default;
void ScopedEventBaseThread::start() {
if (running()) {
*lenReturn = 0;
}
- void readDataAvailable(size_t len) noexcept override {
+ void readDataAvailable(size_t /* len */) noexcept override {
// This should never to called.
FAIL();
}
sock->setReadCB(rcb_);
state = (expect_ == EXPECT_SUCCESS) ? STATE_SUCCEEDED : STATE_FAILED;
}
- void handshakeErr(
- AsyncSSLSocket *sock,
- const AsyncSocketException& ex) noexcept override {
+ void handshakeErr(AsyncSSLSocket* /* sock */,
+ const AsyncSocketException& ex) noexcept override {
std::cerr << "HandshakeCallback::handshakeError " << ex.what() << std::endl;
state = (expect_ == EXPECT_ERROR) ? STATE_SUCCEEDED : STATE_FAILED;
if (expect_ == EXPECT_ERROR) {
state = STATE_FAILED;
}
- void connectionAccepted(int fd, const folly::SocketAddress& clientAddr)
- noexcept override{
+ void connectionAccepted(
+ int fd, const folly::SocketAddress& /* clientAddr */) noexcept override {
printf("Connection accepted\n");
std::shared_ptr<AsyncSSLSocket> sslSock;
try {
static uint32_t asyncLookups_;
static uint32_t lookupDelay_;
- static SSL_SESSION *getSessionCallback(SSL *ssl,
- unsigned char *sess_id,
- int id_len,
- int *copyflag) {
+ static SSL_SESSION* getSessionCallback(SSL* ssl,
+ unsigned char* /* sess_id */,
+ int /* id_len */,
+ int* copyflag) {
*copyflag = 0;
asyncCallbacks_++;
#ifdef SSL_ERROR_WANT_SESS_CACHE_LOOKUP
const AsyncSocketException& ex) noexcept override {
ADD_FAILURE() << "server handshake error: " << ex.what();
}
- void getReadBuffer(void** bufReturn, size_t* lenReturn) override {
+ void getReadBuffer(void** /* bufReturn */, size_t* lenReturn) override {
*lenReturn = 0;
}
- void readDataAvailable(size_t len) noexcept override {
- }
+ void readDataAvailable(size_t /* len */) noexcept override {}
void readEOF() noexcept override {
socket_->close();
}
bool serverNameMatch;
private:
- void handshakeSuc(AsyncSSLSocket* ssl) noexcept override {}
+ void handshakeSuc(AsyncSSLSocket* /* ssl */) noexcept override {}
void handshakeErr(
AsyncSSLSocket*,
const AsyncSocketException& ex) noexcept override {
ADD_FAILURE() << "server handshake error: " << ex.what();
}
- void getReadBuffer(void** bufReturn, size_t* lenReturn) override {
+ void getReadBuffer(void** /* bufReturn */, size_t* lenReturn) override {
*lenReturn = 0;
}
- void readDataAvailable(size_t len) noexcept override {
- }
+ void readDataAvailable(size_t /* len */) noexcept override {}
void readEOF() noexcept override {
socket_->close();
}
std::cerr << "client write success" << std::endl;
}
- void writeErr(
- size_t bytesWritten,
- const AsyncSocketException& ex)
- noexcept override {
+ void writeErr(size_t /* bytesWritten */,
+ const AsyncSocketException& ex) noexcept override {
std::cerr << "client writeError: " << ex.what() << std::endl;
if (!sslSocket_) {
writeAfterConnectErrors_++;
bool verifyResult_;
// HandshakeCallback
- bool handshakeVer(
- AsyncSSLSocket* sock,
- bool preverifyOk,
- X509_STORE_CTX* ctx) noexcept override {
+ bool handshakeVer(AsyncSSLSocket* /* sock */,
+ bool preverifyOk,
+ X509_STORE_CTX* /* ctx */) noexcept override {
handshakeVerify_ = true;
EXPECT_EQ(preverifyResult_, preverifyOk);
handshakeTime = socket_->getHandshakeTime();
}
- void handshakeErr(
- AsyncSSLSocket*,
- const AsyncSocketException& ex) noexcept override {
+ void handshakeErr(AsyncSSLSocket*,
+ const AsyncSocketException& /* ex */) noexcept override {
handshakeError_ = true;
handshakeTime = socket_->getHandshakeTime();
}
cerr << "client write success" << endl;
}
- void writeErr(size_t bytesWritten, const AsyncSocketException& ex)
- noexcept override {
+ void writeErr(size_t /* bytesWritten */,
+ const AsyncSocketException& ex) noexcept override {
cerr << "client writeError: " << ex.what() << endl;
}
public AsyncServerSocket::ConnectionEventCallback {
public:
virtual void onConnectionAccepted(
- const int socket,
- const SocketAddress& addr) noexcept override {
+ const int /* socket */,
+ const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionAccepted_++;
}
- virtual void onConnectionAcceptError(const int err) noexcept override {
+ virtual void onConnectionAcceptError(const int /* err */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionAcceptedError_++;
}
virtual void onConnectionDropped(
- const int socket,
- const SocketAddress& addr) noexcept override {
+ const int /* socket */,
+ const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionDropped_++;
}
virtual void onConnectionEnqueuedForAcceptorCallback(
- const int socket,
- const SocketAddress& addr) noexcept override {
+ const int /* socket */,
+ const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionEnqueuedForAcceptCallback_++;
}
virtual void onConnectionDequeuedByAcceptorCallback(
- const int socket,
- const SocketAddress& addr) noexcept override {
+ const int /* socket */,
+ const SocketAddress& /* addr */) noexcept override {
folly::RWSpinLock::WriteHolder holder(spinLock_);
connectionDequeuedByAcceptCallback_++;
}
// Add a callback to accept one connection then stop the loop
TestAcceptCallback acceptCallback;
acceptCallback.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
- });
- acceptCallback.setAcceptErrorFn([&](const std::exception& ex) {
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
+ });
+ acceptCallback.setAcceptErrorFn([&](const std::exception& /* ex */) {
serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
});
serverSocket->addAcceptCallback(&acceptCallback, nullptr);
// Have callback 2 remove callback 3 and callback 5 the first time it is
// called.
int cb2Count = 0;
- cb1.setConnectionAcceptedFn([&](int fd, const folly::SocketAddress& addr){
- std::shared_ptr<AsyncSocket> sock2(
+ cb1.setConnectionAcceptedFn([&](int /* fd */,
+ const folly::SocketAddress& /* addr */) {
+ std::shared_ptr<AsyncSocket> sock2(
AsyncSocket::newSocket(&eventBase, serverAddress)); // cb2: -cb3 -cb5
+ });
+ cb3.setConnectionAcceptedFn(
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {});
+ cb4.setConnectionAcceptedFn(
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ std::shared_ptr<AsyncSocket> sock3(
+ AsyncSocket::newSocket(&eventBase, serverAddress)); // cb4
+ });
+ cb5.setConnectionAcceptedFn(
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ std::shared_ptr<AsyncSocket> sock5(
+ AsyncSocket::newSocket(&eventBase, serverAddress)); // cb7: -cb7
+
});
- cb3.setConnectionAcceptedFn([&](int fd, const folly::SocketAddress& addr){
- });
- cb4.setConnectionAcceptedFn([&](int fd, const folly::SocketAddress& addr){
- std::shared_ptr<AsyncSocket> sock3(
- AsyncSocket::newSocket(&eventBase, serverAddress)); // cb4
- });
- cb5.setConnectionAcceptedFn([&](int fd, const folly::SocketAddress& addr){
- std::shared_ptr<AsyncSocket> sock5(
- AsyncSocket::newSocket(&eventBase, serverAddress)); // cb7: -cb7
-
- });
cb2.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- if (cb2Count == 0) {
- serverSocket->removeAcceptCallback(&cb3, nullptr);
- serverSocket->removeAcceptCallback(&cb5, nullptr);
- }
- ++cb2Count;
- });
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ if (cb2Count == 0) {
+ serverSocket->removeAcceptCallback(&cb3, nullptr);
+ serverSocket->removeAcceptCallback(&cb5, nullptr);
+ }
+ ++cb2Count;
+ });
// Have callback 6 remove callback 4 the first time it is called,
// and destroy the server socket the second time it is called
int cb6Count = 0;
cb6.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- if (cb6Count == 0) {
- serverSocket->removeAcceptCallback(&cb4, nullptr);
- std::shared_ptr<AsyncSocket> sock6(
- AsyncSocket::newSocket(&eventBase, serverAddress)); // cb1
- std::shared_ptr<AsyncSocket> sock7(
- AsyncSocket::newSocket(&eventBase, serverAddress)); // cb2
- std::shared_ptr<AsyncSocket> sock8(
- AsyncSocket::newSocket(&eventBase, serverAddress)); // cb6: stop
-
- } else {
- serverSocket.reset();
- }
- ++cb6Count;
- });
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ if (cb6Count == 0) {
+ serverSocket->removeAcceptCallback(&cb4, nullptr);
+ std::shared_ptr<AsyncSocket> sock6(
+ AsyncSocket::newSocket(&eventBase, serverAddress)); // cb1
+ std::shared_ptr<AsyncSocket> sock7(
+ AsyncSocket::newSocket(&eventBase, serverAddress)); // cb2
+ std::shared_ptr<AsyncSocket> sock8(
+ AsyncSocket::newSocket(&eventBase, serverAddress)); // cb6: stop
+
+ } else {
+ serverSocket.reset();
+ }
+ ++cb6Count;
+ });
// Have callback 7 remove itself
cb7.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- serverSocket->removeAcceptCallback(&cb7, nullptr);
- });
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ serverSocket->removeAcceptCallback(&cb7, nullptr);
+ });
serverSocket->addAcceptCallback(&cb1, nullptr);
serverSocket->addAcceptCallback(&cb2, nullptr);
CHECK_NE(thread_id, pthread_self());
thread_id = pthread_self();
});
- cb1.setConnectionAcceptedFn([&](int fd, const folly::SocketAddress& addr){
- CHECK_EQ(thread_id, pthread_self());
- serverSocket->removeAcceptCallback(&cb1, nullptr);
- });
+ cb1.setConnectionAcceptedFn(
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ CHECK_EQ(thread_id, pthread_self());
+ serverSocket->removeAcceptCallback(&cb1, nullptr);
+ });
cb1.setAcceptStoppedFn([&](){
CHECK_EQ(thread_id, pthread_self());
});
// Add a callback to accept one connection then stop accepting
TestAcceptCallback acceptCallback;
acceptCallback.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
- });
- acceptCallback.setAcceptErrorFn([&](const std::exception& ex) {
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
+ });
+ acceptCallback.setAcceptErrorFn([&](const std::exception& /* ex */) {
serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
});
serverSocket->addAcceptCallback(&acceptCallback, nullptr);
// Add a callback to accept one connection then stop the loop
TestAcceptCallback acceptCallback;
acceptCallback.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
- });
- acceptCallback.setAcceptErrorFn([&](const std::exception& ex) {
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
+ });
+ acceptCallback.setAcceptErrorFn([&](const std::exception& /* ex */) {
serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
});
serverSocket->addAcceptCallback(&acceptCallback, nullptr);
// Add a callback to accept one connection then stop the loop
TestAcceptCallback acceptCallback;
acceptCallback.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
- serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
- });
- acceptCallback.setAcceptErrorFn([&](const std::exception& ex) {
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
+ serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
+ });
+ acceptCallback.setAcceptErrorFn([&](const std::exception& /* ex */) {
serverSocket->removeAcceptCallback(&acceptCallback, nullptr);
});
serverSocket->addAcceptCallback(&acceptCallback, nullptr);
// Add a callback to accept connections
TestAcceptCallback acceptCallback;
acceptCallback.setConnectionAcceptedFn(
- [&](int fd, const folly::SocketAddress& addr) {
+ [&](int /* fd */, const folly::SocketAddress& /* addr */) {
count++;
CHECK_EQ(4 - count, serverSocket->getNumPendingMessagesInQueue());
serverSocket->removeAcceptCallback(&acceptCallback, &eventBase);
}
});
- acceptCallback.setAcceptErrorFn([&](const std::exception& ex) {
+ acceptCallback.setAcceptErrorFn([&](const std::exception& /* ex */) {
serverSocket->removeAcceptCallback(&acceptCallback, &eventBase);
});
serverSocket->addAcceptCallback(&acceptCallback, &eventBase);
void onListenStopped() noexcept override {}
- void onDataAvailable(std::shared_ptr<folly::AsyncUDPSocket> socket,
+ void onDataAvailable(std::shared_ptr<folly::AsyncUDPSocket> /* socket */,
const folly::SocketAddress& client,
std::unique_ptr<folly::IOBuf> data,
bool truncated) noexcept override {
err_ = ex;
}
void writeSuccess() noexcept override {}
- void writeErr(size_t bytesWritten,
+ void writeErr(size_t /* bytesWritten */,
const folly::AsyncSocketException& ex) noexcept override {
err_ = ex;
}
unregisterHandler();
}
- void handlerReady(uint16_t events) noexcept override {
+ void handlerReady(uint16_t /* events */) noexcept override {
// We didn't register with PERSIST, so we will have been automatically
// unregistered already.
ASSERT_FALSE(isHandlerRegistered());
PipeHandler(EventBase* eventBase, int fd)
: EventHandler(eventBase, fd) {}
- void handlerReady(uint16_t events) noexcept override { abort(); }
+ void handlerReady(uint16_t /* events */) noexcept override { abort(); }
};
TEST(EventBaseTest, StopBeforeLoop) {
EventHandlerMock eh(&eb, efd);
eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
EXPECT_CALL(eh, _handlerReady(_))
- .Times(writes)
- .WillRepeatedly(Invoke([&](uint16_t events) {
- efd_read();
- if (--readsRemaining == 0) {
- eh.unregisterHandler();
- }
- }));
+ .Times(writes)
+ .WillRepeatedly(Invoke([&](uint16_t /* events */) {
+ efd_read();
+ if (--readsRemaining == 0) {
+ eh.unregisterHandler();
+ }
+ }));
efd_write(writes);
eb.loop();
size_t readsRemaining = writes;
runInThreadsAndWait({
- [&] {
- EventBase eb;
- EventHandlerMock eh(&eb, efd);
- eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
- EXPECT_CALL(eh, _handlerReady(_))
- .Times(writes)
- .WillRepeatedly(Invoke([&](uint16_t events) {
- efd_read();
- if (--readsRemaining == 0) {
- eh.unregisterHandler();
- }
- }));
- eb.loop();
- },
- [&] {
- runInThreadsAndWait(nproducers, [&](size_t k) {
- for (size_t i = 0; i < writes / nproducers; ++i) {
- this_thread::sleep_for(chrono::milliseconds(1));
- efd_write(1);
- }
- });
- },
+ [&] {
+ EventBase eb;
+ EventHandlerMock eh(&eb, efd);
+ eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
+ EXPECT_CALL(eh, _handlerReady(_))
+ .Times(writes)
+ .WillRepeatedly(Invoke([&](uint16_t /* events */) {
+ efd_read();
+ if (--readsRemaining == 0) {
+ eh.unregisterHandler();
+ }
+ }));
+ eb.loop();
+ },
+ [&] {
+ runInThreadsAndWait(nproducers,
+ [&](size_t /* k */) {
+ for (size_t i = 0; i < writes / nproducers; ++i) {
+ this_thread::sleep_for(chrono::milliseconds(1));
+ efd_write(1);
+ }
+ });
+ },
});
EXPECT_EQ(0, readsRemaining);
MPMCQueue<nullptr_t> queue(writes / 10);
runInThreadsAndWait({
- [&] {
- runInThreadsAndWait(nconsumers, [&](size_t k) {
- size_t thReadsRemaining = writes / nconsumers;
- EventBase eb;
- EventHandlerMock eh(&eb, efd);
- eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
- EXPECT_CALL(eh, _handlerReady(_))
- .WillRepeatedly(Invoke([&](uint16_t events) {
- nullptr_t val;
- if (!queue.readIfNotEmpty(val)) {
- return;
- }
- efd_read();
- --readsRemaining;
- if (--thReadsRemaining == 0) {
- eh.unregisterHandler();
- }
- }));
- eb.loop();
- });
- },
- [&] {
- runInThreadsAndWait(nproducers, [&](size_t k) {
- for (size_t i = 0; i < writes / nproducers; ++i) {
- this_thread::sleep_for(chrono::milliseconds(1));
- queue.blockingWrite(nullptr);
- efd_write(1);
- --writesRemaining;
- }
- });
- },
+ [&] {
+ runInThreadsAndWait(
+ nconsumers,
+ [&](size_t /* k */) {
+ size_t thReadsRemaining = writes / nconsumers;
+ EventBase eb;
+ EventHandlerMock eh(&eb, efd);
+ eh.registerHandler(EventHandler::READ | EventHandler::PERSIST);
+ EXPECT_CALL(eh, _handlerReady(_))
+ .WillRepeatedly(Invoke([&](uint16_t /* events */) {
+ nullptr_t val;
+ if (!queue.readIfNotEmpty(val)) {
+ return;
+ }
+ efd_read();
+ --readsRemaining;
+ if (--thReadsRemaining == 0) {
+ eh.unregisterHandler();
+ }
+ }));
+ eb.loop();
+ });
+ },
+ [&] {
+ runInThreadsAndWait(nproducers,
+ [&](size_t /* k */) {
+ for (size_t i = 0; i < writes / nproducers; ++i) {
+ this_thread::sleep_for(chrono::milliseconds(1));
+ queue.blockingWrite(nullptr);
+ efd_write(1);
+ --writesRemaining;
+ }
+ });
+ },
});
EXPECT_EQ(0, writesRemaining);
// Make sure there can only be one drainer at once
folly::Baton<> callbackBaton, threadStartBaton;
- consumer.fn = [&](int i) {
- callbackBaton.wait();
- };
+ consumer.fn = [&](int /* i */) { callbackBaton.wait(); };
QueueConsumer competingConsumer;
competingConsumer.startConsuming(&eventBase, &queue);
queue.putMessage(1);
// Make sure there can only be one drainer at once
folly::Baton<> callbackBaton, threadStartBaton;
- consumer.fn = [&](int i) {
- callbackBaton.wait();
- };
+ consumer.fn = [&](int /* i */) { callbackBaton.wait(); };
QueueConsumer competingConsumer;
competingConsumer.startConsuming(&eventBase, &queue);
queue.putMessage(1);
return !(*this == other);
}
- bool operator==(const MmapAllocator<T>& other) const {
- return true;
- }
+ bool operator==(const MmapAllocator<T>& /* other */) const { return true; }
template <class... Args>
void construct(T* p, Args&&... args) {
typedef AtomicHashArray<int32_t, int32_t> AHA;
AHA::Config configRace;
auto atomicHashArrayInsertRaceArray = AHA::create(2, configRace);
-void* atomicHashArrayInsertRaceThread(void* j) {
+void* atomicHashArrayInsertRaceThread(void* /* j */) {
AHA* arr = atomicHashArrayInsertRaceArray.get();
uintptr_t numInserted = 0;
while (!runThreadsCreatedAllThreads.load());
T operator+=(T arg) { value += arg; return load();}
- T load(std::memory_order order= std::memory_order_seq_cst) const {
+ T load(std::memory_order /* order */ = std::memory_order_seq_cst) const {
return value;
}
/* implicit */
operator T() const {return load();}
- void store(T desired, std::memory_order order = std::memory_order_seq_cst) {
+ void store(T desired,
+ std::memory_order /* order */ = std::memory_order_seq_cst) {
value = desired;
}
- T exchange(T desired, std::memory_order order = std::memory_order_seq_cst) {
+ T exchange(T desired,
+ std::memory_order /* order */ = std::memory_order_seq_cst) {
T old = load();
store(desired);
return old;
}
bool compare_exchange_weak(
- T& expected, T desired,
- std::memory_order success = std::memory_order_seq_cst,
- std::memory_order failure = std::memory_order_seq_cst) {
+ T& expected,
+ T desired,
+ std::memory_order /* success */ = std::memory_order_seq_cst,
+ std::memory_order /* failure */ = std::memory_order_seq_cst) {
if (value == expected) {
value = desired;
return true;
}
bool compare_exchange_strong(
- T& expected, T desired,
- std::memory_order success = std::memory_order_seq_cst,
- std::memory_order failure = std::memory_order_seq_cst) {
+ T& expected,
+ T desired,
+ std::memory_order /* success */ = std::memory_order_seq_cst,
+ std::memory_order /* failure */ = std::memory_order_seq_cst) {
if (value == expected) {
value = desired;
return true;
static FOLLY_TLS unsigned testingCpu = 0;
-static int testingGetcpu(unsigned* cpu, unsigned* node, void* unused) {
+static int testingGetcpu(unsigned* cpu, unsigned* node, void* /* unused */) {
if (cpu != nullptr) {
*cpu = testingCpu;
}
FOR_EACH(lock, locks_) delete *lock;
}
- inline bool skipListFind(int idx, ValueType val) {
+ inline bool skipListFind(int /* idx */, ValueType val) {
return skipList_.contains(val);
}
- inline void skipListInsert(int idx, ValueType val) {
+ inline void skipListInsert(int /* idx */, ValueType val) {
skipList_.add(val);
}
- inline void skipListErase(int idx, ValueType val) {
+ inline void skipListErase(int /* idx */, ValueType val) {
skipList_.remove(val);
}
return std::rand() % n;
}
-int DeterministicSchedule::getcpu(unsigned* cpu, unsigned* node, void* unused) {
+int DeterministicSchedule::getcpu(unsigned* cpu,
+ unsigned* node,
+ void* /* unused */) {
if (!tls_threadId && tls_sched) {
beforeSharedAccess();
tls_threadId = tls_sched->nextThreadId_++;
template <>
Getcpu::Func AccessSpreader<test::DeterministicAtomic>::pickGetcpuFunc(
- size_t numStripes) {
+ size_t /* numStripes */) {
return &DeterministicSchedule::getcpu;
}
}
return rv;
}
- T operator++(int postDummy) noexcept {
+ T operator++(int /* postDummy */) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data++;
FOLLY_TEST_DSCHED_VLOG(this << " post++ -> " << std::hex << rv);
return rv;
}
- T operator--(int postDummy) noexcept {
+ T operator--(int /* postDummy */) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data--;
FOLLY_TEST_DSCHED_VLOG(this << " post-- -> " << std::hex << rv);
return rv;
}
- T fetch_add(T v, std::memory_order mo = std::memory_order_seq_cst) noexcept {
+ T fetch_add(T v,
+ std::memory_order /* mo */ = std::memory_order_seq_cst) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data;
data += v;
return rv;
}
- T fetch_sub(T v, std::memory_order mo = std::memory_order_seq_cst) noexcept {
+ T fetch_sub(T v,
+ std::memory_order /* mo */ = std::memory_order_seq_cst) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data;
data -= v;
return rv;
}
- T fetch_and(T v, std::memory_order mo = std::memory_order_seq_cst) noexcept {
+ T fetch_and(T v,
+ std::memory_order /* mo */ = std::memory_order_seq_cst) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data;
data &= v;
return rv;
}
- T fetch_or(T v, std::memory_order mo = std::memory_order_seq_cst) noexcept {
+ T fetch_or(T v,
+ std::memory_order /* mo */ = std::memory_order_seq_cst) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data;
data |= v;
return rv;
}
- T fetch_xor(T v, std::memory_order mo = std::memory_order_seq_cst) noexcept {
+ T fetch_xor(T v,
+ std::memory_order /* mo */ = std::memory_order_seq_cst) noexcept {
DeterministicSchedule::beforeSharedAccess();
T rv = data;
data ^= v;
TEST(DiscriminatedPtr, Apply) {
struct Foo { };
struct Visitor {
- std::string operator()(int* ptr) { return "int"; }
- std::string operator()(const int* ptr) { return "const int"; }
- std::string operator()(Foo* ptr) { return "Foo"; }
- std::string operator()(const Foo* ptr) { return "const Foo"; }
+ std::string operator()(int* /* ptr */) { return "int"; }
+ std::string operator()(const int* /* ptr */) { return "const int"; }
+ std::string operator()(Foo* /* ptr */) { return "Foo"; }
+ std::string operator()(const Foo* /* ptr */) { return "const Foo"; }
};
typedef DiscriminatedPtr<int, Foo> Ptr;
TEST(DiscriminatedPtr, ApplyVoid) {
struct Foo { };
struct Visitor {
- void operator()(int* ptr) { result = "int"; }
- void operator()(const int* ptr) { result = "const int"; }
- void operator()(Foo* ptr) { result = "Foo"; }
- void operator()(const Foo* ptr) { result = "const Foo"; }
+ void operator()(int* /* ptr */) { result = "int"; }
+ void operator()(const int* /* ptr */) { result = "const int"; }
+ void operator()(Foo* /* ptr */) { result = "Foo"; }
+ void operator()(const Foo* /* ptr */) { result = "const Foo"; }
std::string result;
};
// Test with const this. If this compiles and does not crash due to
// infinite loop when it runs, it succeeds.
const exception_wrapper& cew = ew;
- cew.with_exception([&](const IntException& ie) {
- SUCCEED();
- });
+ cew.with_exception([&](const IntException& /* ie */) { SUCCEED(); });
// This won't even compile. You can't use a function which takes a
// non-const reference with a const exception_wrapper.
* override-include-guard
*/
-void BENCHFUN(initRNG)(size_t iters, size_t) {
- srand(seed);
-}
+void BENCHFUN(initRNG)(size_t /* iters */, size_t) { srand(seed); }
BENCHMARK_PARAM(BENCHFUN(initRNG), 0);
void BENCHFUN(defaultCtor)(size_t iters, size_t) {
}
BENCHMARK_PARAM(BENCHFUN(resize), 524288);
-void BENCHFUN(findSuccessful)(size_t iters, size_t arg) {
+void BENCHFUN(findSuccessful)(size_t iters, size_t /* arg */) {
size_t pos, len;
STRING s;
}
BENCHMARK_PARAM(BENCHFUN(findSuccessful), 524288);
-void BENCHFUN(findUnsuccessful)(size_t iters, size_t arg) {
+void BENCHFUN(findUnsuccessful)(size_t iters, size_t /* arg */) {
STRING s, s1;
BENCHMARK_SUSPEND {
}
template <class String, class Integral>
-void Num2String(String& str, Integral n) {
+void Num2String(String& str, Integral /* n */) {
str.resize(10, '\0');
sprintf(&str[0], "%ul", 10);
str.resize(strlen(str.c_str()));
}
template <class String, class Integral>
-void Num2String(String& str, Integral n) {
+void Num2String(String& str, Integral /* n */) {
str.resize(10, '\0');
sprintf(&str[0], "%ul", 10);
str.resize(strlen(str.c_str()));
BENCHMARK_PARAM(BENCHFUN(pushBack), 102400);
BENCHMARK_PARAM(BENCHFUN(pushBack), 512000);
-void BENCHFUN(reserve)(int iters, int size) {
+void BENCHFUN(reserve)(int iters, int /* size */) {
auto const obj = randomObject<VECTOR::value_type>();
VECTOR v(random(0U, 10000U), obj);
FOR_EACH_RANGE (i, 0, iters) {
BENCHMARK_PARAM(BENCHFUN(reserve), 1024);
BENCHMARK_PARAM(BENCHFUN(reserve), 10240);
-void BENCHFUN(insert)(int iters, int size) {
+void BENCHFUN(insert)(int iters, int /* size */) {
auto const obj1 = randomObject<VECTOR::value_type>();
auto const obj2 = randomObject<VECTOR::value_type>();
VECTOR v(random(0U, 1U), obj1);
}
BENCHMARK_PARAM(BENCHFUN(insert), 100);
-void BENCHFUN(erase)(int iters, int size) {
+void BENCHFUN(erase)(int iters, int /* size */) {
auto const obj1 = randomObject<VECTOR::value_type>();
VECTOR v(random(0U, 100U), obj1);
FOR_EACH_RANGE (i, 0, iters) {
return n;
}
-ssize_t Reader::operator()(int fd, void* buf, size_t count) {
+ssize_t Reader::operator()(int /* fd */, void* buf, size_t count) {
ssize_t n = nextSize();
if (n <= 0) {
return n;
return operator()(fd, buf, count);
}
-ssize_t Reader::operator()(int fd, const iovec* iov, int count) {
+ssize_t Reader::operator()(int /* fd */, const iovec* iov, int count) {
ssize_t n = nextSize();
if (n <= 0) {
return n;
++lc_counts[DEFAULT_CONSTRUCTOR];
}
- explicit Lifecycle(int n, char const* s) noexcept : constructed(true) {
+ explicit Lifecycle(int /* n */, char const* /* s */) noexcept
+ : constructed(true) {
++lc_counts[TWO_ARG_CONSTRUCTOR];
}
- Lifecycle(const Lifecycle& rhs) noexcept : constructed(true) {
+ Lifecycle(const Lifecycle& /* rhs */) noexcept : constructed(true) {
++lc_counts[COPY_CONSTRUCTOR];
}
- Lifecycle(Lifecycle&& rhs) noexcept : constructed(true) {
+ Lifecycle(Lifecycle&& /* rhs */) noexcept : constructed(true) {
++lc_counts[MOVE_CONSTRUCTOR];
}
- Lifecycle& operator= (const Lifecycle& rhs) noexcept {
+ Lifecycle& operator=(const Lifecycle& /* rhs */) noexcept {
++lc_counts[COPY_OPERATOR];
return *this;
}
- Lifecycle& operator= (Lifecycle&& rhs) noexcept {
+ Lifecycle& operator=(Lifecycle&& /* rhs */) noexcept {
++lc_counts[MOVE_OPERATOR];
return *this;
}
delete test;
}
-void BM_ProducerConsumerLatency(int iters, int size) {
+void BM_ProducerConsumerLatency(int /* iters */, int size) {
BenchmarkSuspender susp;
CHECK_GT(size, 0);
LatencyTest<LatencyQueueType> *test =
struct DtorChecker {
static unsigned int numInstances;
DtorChecker() { ++numInstances; }
- DtorChecker(const DtorChecker& o) { ++numInstances; }
+ DtorChecker(const DtorChecker& /* o */) { ++numInstances; }
~DtorChecker() { --numInstances; }
};
ThreadLocalPtr<int> tl;
std::thread([&] {
- tl.reset(new int(1), [&] (int* ptr, TLPDestructionMode mode) {
- delete ptr;
- // This test ensures Widgets allocated here are not leaked.
- ++w.get()->val_;
- ThreadLocal<Widget> wl;
- ++wl.get()->val_;
- });
- }).join();
+ tl.reset(new int(1),
+ [&](int* ptr, TLPDestructionMode /* mode */) {
+ delete ptr;
+ // This test ensures Widgets allocated here are not leaked.
+ ++w.get()->val_;
+ ThreadLocal<Widget> wl;
+ ++wl.get()->val_;
+ });
+ }).join();
EXPECT_EQ(2, Widget::totalVal_);
}
EventVec events;
TimeoutQueue q;
- TimeoutQueue::Callback cb =
- [&events](TimeoutQueue::Id id, int64_t now) {
- events.push_back(id);
- };
+ TimeoutQueue::Callback cb = [&events](
+ TimeoutQueue::Id id, int64_t /* now */) { events.push_back(id); };
EXPECT_EQ(1, q.add(0, 10, cb));
EXPECT_EQ(2, q.add(0, 11, cb));
TimeoutQueue q;
TimeoutQueue::Callback cb =
- [&events, &q](TimeoutQueue::Id id, int64_t now) {
- events.push_back(id);
- if (id == 2) {
- q.erase(1);
- }
- };
+ [&events, &q](TimeoutQueue::Id id, int64_t /* now */) {
+ events.push_back(id);
+ if (id == 2) {
+ q.erase(1);
+ }
+ };
EXPECT_EQ(1, q.addRepeating(0, 10, cb));
EXPECT_EQ(2, q.add(0, 35, cb));
int count = 0;
TimeoutQueue q;
TimeoutQueue::Callback cb =
- [&count, &q](TimeoutQueue::Id id, int64_t now) {
- if (++count == 100) {
- EXPECT_TRUE(q.erase(id));
- }
- };
+ [&count, &q](TimeoutQueue::Id id, int64_t /* now */) {
+ if (++count == 100) {
+ EXPECT_TRUE(q.erase(id));
+ }
+ };
EXPECT_EQ(1, q.addRepeating(0, 0, cb));
++ctored;
}
- NontrivialType(NontrivialType const& s) {
- ++ctored;
- }
+ NontrivialType(NontrivialType const& /* s */) { ++ctored; }
NontrivialType& operator=(NontrivialType const& o) {
a = o.a;
--alive;
}
- Thrower& operator=(Thrower const& other) {
+ Thrower& operator=(Thrower const& /* other */) {
EXPECT_EQ(magic, kMagic);
MaybeThrow();
return *this;