mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
129d87fe23
Summary: While EdenFS does not use a separate privhelper process on Windows, it still defines a stub PrivHelper class. However, this class was previously defined in a separate win/utils/Stub.h header file, which led to awkward `#ifdef`s to include the correct platform-specific header file. This diff moves the definition of the dummy PrivHelper class in Windows into the same `PrivHelper.h` header file used on POSIX platforms. This results in a few more `ifdef`s in the PrivHelper files, but fewer `ifdef`s in the calling code, and will make it easier to start unifying more of the `EdenMain` logic on Windows and non-Windows platforms. Reviewed By: xavierd Differential Revision: D21332568 fbshipit-source-id: c63bf2b4a8b7e767d7db7dcda28675f735c23bf8
59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#include "eden/fs/fuse/privhelper/PrivHelper.h"
|
|
|
|
#include <folly/File.h>
|
|
#include <folly/futures/Future.h>
|
|
#include <folly/io/async/EventBase.h>
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
#ifndef _WIN32
|
|
|
|
void PrivHelper::setLogFileBlocking(folly::File logFile) {
|
|
folly::EventBase evb;
|
|
attachEventBase(&evb);
|
|
|
|
auto future = setLogFile(std::move(logFile));
|
|
if (future.isReady()) {
|
|
std::move(future).get();
|
|
return;
|
|
}
|
|
|
|
future = std::move(future).ensure([&evb] { evb.terminateLoopSoon(); });
|
|
evb.loopForever();
|
|
std::move(future).get();
|
|
}
|
|
|
|
void PrivHelper::setDaemonTimeoutBlocking(std::chrono::nanoseconds duration) {
|
|
folly::EventBase evb;
|
|
attachEventBase(&evb);
|
|
|
|
auto future = setDaemonTimeout(std::move(duration));
|
|
if (future.isReady()) {
|
|
std::move(future).get();
|
|
return;
|
|
}
|
|
|
|
future = std::move(future).ensure([&evb] { evb.terminateLoopSoon(); });
|
|
evb.loopForever();
|
|
std::move(future).get();
|
|
}
|
|
|
|
#else // _WIN32
|
|
|
|
void PrivHelper::setLogFileBlocking(folly::File) {}
|
|
|
|
void PrivHelper::setDaemonTimeoutBlocking(std::chrono::nanoseconds) {}
|
|
|
|
#endif // _WIN32
|
|
|
|
} // namespace eden
|
|
} // namespace facebook
|