Commit 586a200d authored by Misha Shneerson's avatar Misha Shneerson Committed by Facebook GitHub Bot

Saturation detector. Basic algorithm. Diff 1/7

Summary: Basic FIFO queues observation hooks.

Reviewed By: andriigrynenko

Differential Revision: D20773870

fbshipit-source-id: 3f9cbab1b8b10204139ce153d92e08ffb5f6254c
parent bddd247e
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/concurrency/QueueObserver.h>
namespace {
std::unique_ptr<folly::QueueObserverFactory>
make_queue_observer_factory_fallback() noexcept {
return {};
}
} // namespace
namespace folly {
/* static */ std::unique_ptr<QueueObserverFactory>
QueueObserverFactory::make() {
auto f = make_queue_observer_factory ? make_queue_observer_factory
: make_queue_observer_factory_fallback;
return f();
}
} // namespace folly
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <stdint.h>
#include <memory>
#include <folly/Portability.h>
namespace folly {
class QueueObserver {
public:
virtual ~QueueObserver() {}
virtual intptr_t onEnqueued() = 0;
virtual void onDequeued(intptr_t) = 0;
};
class QueueObserverFactory {
public:
virtual ~QueueObserverFactory() {}
virtual std::unique_ptr<QueueObserver> create() = 0;
static std::unique_ptr<QueueObserverFactory> make();
};
using MakeQueueObserverFactory = std::unique_ptr<QueueObserverFactory>();
#if FOLLY_HAVE_WEAK_SYMBOLS
FOLLY_ATTR_WEAK MakeQueueObserverFactory make_queue_observer_factory;
#else
constexpr MakeQueueObserverFactory* make_queue_observer_factory = nullptr;
#endif
} // namespace folly
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