Commit dcf8a19c authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Let Futex import base-class ctors

Summary:
[Folly] Let `Futex` import base-class ctors.

Rather than needing to define ctors and inherit `boost::noncopyable`.

Reviewed By: WillerZ

Differential Revision: D6674054

fbshipit-source-id: 59e0a4815682b227346954fe47c6eda49e3ad62f
parent 028415ba
......@@ -563,7 +563,7 @@ class SharedMutexImpl {
};
// 32 bits of state
Futex state_;
Futex state_{};
// S count needs to be on the end, because we explicitly allow it to
// underflow. This can occur while we are in the middle of applying
......
......@@ -34,6 +34,8 @@
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/Portability.h>
#include <folly/SmallLocks.h>
......
......@@ -330,7 +330,8 @@ class DynamicBoundedQueue {
capacity_(capacity + threshold(capacity)), // capacity slack
credit_(0),
threshold_(threshold(capacity)),
transfer_(0) {}
transfer_(0),
waiting_(0) {}
/** destructor */
~DynamicBoundedQueue() {}
......
......@@ -22,8 +22,6 @@
#include <limits>
#include <type_traits>
#include <boost/noncopyable.hpp>
#include <folly/portability/Unistd.h>
namespace folly { namespace detail {
......@@ -45,9 +43,8 @@ enum class FutexResult {
* (and benchmarks to back you up).
*/
template <template <typename> class Atom = std::atomic>
struct Futex : Atom<uint32_t>, boost::noncopyable {
explicit constexpr Futex(uint32_t init = 0) : Atom<uint32_t>(init) {}
struct Futex : Atom<uint32_t> {
using Atom<uint32_t>::Atom;
/** Puts the thread to sleep if this->load() == expected. Returns true when
* it is returning because it has consumed a wake() event, false for any
......
......@@ -171,8 +171,8 @@ class FlatCombiningPriorityQueue
private:
size_t maxSize_;
PriorityQueue pq_;
detail::Futex<Atom> empty_;
detail::Futex<Atom> full_;
detail::Futex<Atom> empty_{};
detail::Futex<Atom> full_{};
bool isTrue(detail::Futex<Atom>& futex) {
return futex.load(std::memory_order_relaxed) != 0;
......
......@@ -258,7 +258,7 @@ class Baton {
union {
std::atomic<intptr_t> waitingFiber_;
struct {
folly::detail::Futex<> futex;
folly::detail::Futex<> futex{};
int32_t _unused_packing;
} futex_;
};
......
......@@ -38,7 +38,7 @@ template <typename Tag>
class ThreadCachedInts {
std::atomic<int64_t> orphan_inc_[2];
std::atomic<int64_t> orphan_dec_[2];
folly::detail::Futex<> waiting_;
folly::detail::Futex<> waiting_{0};
class Integer {
public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment