/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#pragma once
-#include <folly/Baton.h>
#include <folly/Function.h>
#include <folly/IndexedMemPool.h>
#include <folly/Portability.h>
#include <folly/concurrency/CacheLocality.h>
+#include <folly/synchronization/SaturatingSemaphore.h>
#include <atomic>
#include <cassert>
#include <mutex>
+#include <thread>
namespace folly {
/// Combining request record.
class Rec {
FOLLY_ALIGN_TO_AVOID_FALSE_SHARING
- folly::Baton<Atom, true, false> valid_;
- folly::Baton<Atom, true, false> done_;
- folly::Baton<Atom, true, false> disconnected_;
+ folly::SaturatingSemaphore<false, Atom> valid_;
+ folly::SaturatingSemaphore<false, Atom> done_;
+ folly::SaturatingSemaphore<false, Atom> disconnected_;
size_t index_;
size_t next_;
uint64_t last_;
}
bool isValid() const {
- return valid_.try_wait();
+ return valid_.ready();
}
void setDone() {
}
bool isDone() const {
- return done_.try_wait();
+ return done_.ready();
}
void awaitDone() {
}
bool isDisconnected() const {
- return disconnected_.try_wait();
+ return disconnected_.ready();
}
void setIndex(const size_t index) {
Mutex m_;
FOLLY_ALIGN_TO_AVOID_FALSE_SHARING
- folly::Baton<Atom, false, true> pending_;
+ folly::SaturatingSemaphore<true, Atom> pending_;
Atom<bool> shutdown_{false};
FOLLY_ALIGN_TO_AVOID_FALSE_SHARING
}
bool isPending() const {
- return pending_.try_wait();
+ return pending_.ready();
}
void awaitPending() {
}
};
-} // namespace folly {
+} // namespace folly