Commit 9d2ead08 authored by Kenton Varda's avatar Kenton Varda

Convert KJ filesystem API to be entirely threadsafe.

The disk-backed implementations were already inherently threadsafe. Making this explicit allows callers to rely on it.

This is particularly useful for SchemaParser, which is intended to be threadsafe.
parent fc620c73
This diff is collapsed.
This diff is collapsed.
......@@ -264,13 +264,13 @@ public:
time += 1 * SECONDS;
}
Date now() override { return time; }
Date now() const override { return time; }
void expectChanged(FsNode& file) {
void expectChanged(const FsNode& file) {
KJ_EXPECT(file.stat().lastModified == time);
time += 1 * SECONDS;
}
void expectUnchanged(FsNode& file) {
void expectUnchanged(const FsNode& file) {
KJ_EXPECT(file.stat().lastModified != time);
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -26,12 +26,12 @@
namespace kj {
Clock& nullClock() {
const Clock& nullClock() {
class NullClock final: public Clock {
public:
Date now() override { return UNIX_EPOCH; }
Date now() const override { return UNIX_EPOCH; }
};
static NullClock NULL_CLOCK;
static KJ_CONSTEXPR(const) NullClock NULL_CLOCK;
return NULL_CLOCK;
}
......
......@@ -63,10 +63,10 @@ constexpr Date UNIX_EPOCH = origin<Date>();
class Clock {
// Interface to read the current date and time.
public:
virtual Date now() = 0;
virtual Date now() const = 0;
};
Clock& nullClock();
const Clock& nullClock();
// A clock which always returns UNIX_EPOCH as the current time. Useful when you don't care about
// time.
......
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