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