std::unique_ptr<LoopController> loopController__,
Options options) :
loopController_(std::move(loopController__)),
+ stackAllocator_(options.useGuardPages),
options_(preprocessOptions(std::move(options))),
exceptionCallback_([](std::exception_ptr eptr, std::string context) {
try {
*/
size_t maxFibersPoolSize{1000};
+ /**
+ * Protect limited amount of fiber stacks with guard pages.
+ */
+ bool useGuardPages{true};
+
constexpr Options() {}
};
std::unique_ptr<StackCache> stackCache_;
};
-GuardPageAllocator::GuardPageAllocator() = default;
+GuardPageAllocator::GuardPageAllocator(bool useGuardPages)
+ : useGuardPages_(useGuardPages) {
+}
+
GuardPageAllocator::~GuardPageAllocator() = default;
unsigned char* GuardPageAllocator::allocate(size_t size) {
- if (!stackCache_) {
+ if (useGuardPages_ && !stackCache_) {
stackCache_ = CacheManager::instance().getStackCache(size);
}
*/
class GuardPageAllocator {
public:
- GuardPageAllocator();
+ /**
+ * @param useGuardPages if true, protect limited amount of stacks with guard
+ * pages, otherwise acts as std::allocator.
+ */
+ explicit GuardPageAllocator(bool useGuardPages);
~GuardPageAllocator();
/**
private:
std::unique_ptr<StackCacheEntry> stackCache_;
std::allocator<unsigned char> fallbackAllocator_;
+ bool useGuardPages_{true};
};
}} // folly::fibers