osquery-1/osquery/dispatcher/scheduler.h
Jesse Kornblum c7355b19aa Update osquery licensing wording (#5452)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5452

As suggested in another diff, this diff updates the language we use to describe the osquery licensing terms. We are changing all instances of

//This source code is licensed as defined on the LICENSE file found in the root directory of this source tree.//

to

//This source code is licensed in accordance with the terms specified in the LICENSE file found in the root directory of this source tree.//

We accomplish this with a codemod:

  $ codemod -md xplat/osquery/oss --extensions cpp,h,in,py,sh,mm,ps1 "(.\s+)This source code is licensed as defined on the LICENSE file found in the(.*)root directory of this source tree\." "\1This source code is licensed in accordance with the terms specified in\2the LICENSE file found in the root directory of this source tree."

Reviewed By: fmanco

Differential Revision: D14131290

fbshipit-source-id: 52c90da342263e2a80f5a678ecd760c19cf7513e
2019-02-19 10:59:48 -08:00

66 lines
1.8 KiB
C++

/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed in accordance with the terms specified in
* the LICENSE file found in the root directory of this source tree.
*/
#pragma once
#include <chrono>
#include <map>
#include <osquery/dispatcher.h>
#include "osquery/sql/sqlite_util.h"
namespace osquery {
/// A Dispatcher service thread that watches an ExtensionManagerHandler.
class SchedulerRunner : public InternalRunnable {
public:
SchedulerRunner(
unsigned long int timeout,
size_t interval,
std::chrono::milliseconds max_time_drift = std::chrono::seconds::zero())
: InternalRunnable("SchedulerRunner"),
interval_{std::chrono::seconds{interval}},
timeout_(timeout),
time_drift_{std::chrono::milliseconds::zero()},
max_time_drift_{max_time_drift} {}
public:
/// The Dispatcher thread entry point.
void start() override;
/// The Dispatcher interrupt point.
void stop() override {}
/// Accumulated for some time time drift to compensate.
std::chrono::milliseconds getCurrentTimeDrift() const noexcept;
private:
/// Interval in seconds between schedule steps.
const std::chrono::milliseconds interval_;
/// Maximum number of steps.
const unsigned long int timeout_;
/// Accumulated for some time time drift to compensate.
/// It will be either reduced during compensation process or
/// after exceding the limit @see max_time_drift_
std::chrono::milliseconds time_drift_;
const std::chrono::milliseconds max_time_drift_;
};
SQLInternal monitor(const std::string& name, const ScheduledQuery& query);
/// Start querying according to the config's schedule
void startScheduler();
/// Helper scheduler start with variable settings for testing.
void startScheduler(unsigned long int timeout, size_t interval);
}