@@ -76,6 +76,9 @@ class DiskManagerUnlimitedMemory : public DiskManager {
76
76
ProcessLatency (page_id);
77
77
78
78
std::unique_lock<std::mutex> l (mutex_);
79
+ if (!thread_id_.has_value ()) {
80
+ thread_id_ = std::this_thread::get_id ();
81
+ }
79
82
if (page_id >= static_cast <int >(data_.size ())) {
80
83
data_.resize (page_id + 1 );
81
84
}
@@ -100,6 +103,9 @@ class DiskManagerUnlimitedMemory : public DiskManager {
100
103
ProcessLatency (page_id);
101
104
102
105
std::unique_lock<std::mutex> l (mutex_);
106
+ if (!thread_id_.has_value ()) {
107
+ thread_id_ = std::this_thread::get_id ();
108
+ }
103
109
if (page_id >= static_cast <int >(data_.size ()) || page_id < 0 ) {
104
110
fmt::println (stderr, " page {} not in range" , page_id);
105
111
std::terminate ();
@@ -148,6 +154,13 @@ class DiskManagerUnlimitedMemory : public DiskManager {
148
154
149
155
void EnableLatencySimulator (bool enabled) { latency_simulator_enabled_ = enabled; }
150
156
157
+ auto GetLastReadThreadAndClear () -> std::optional<std::thread::id> {
158
+ std::unique_lock<std::mutex> lck (mutex_);
159
+ auto t = thread_id_;
160
+ thread_id_ = std::nullopt;
161
+ return t;
162
+ }
163
+
151
164
private:
152
165
bool latency_simulator_enabled_{false };
153
166
@@ -159,6 +172,7 @@ class DiskManagerUnlimitedMemory : public DiskManager {
159
172
using ProtectedPage = std::pair<Page, std::shared_mutex>;
160
173
161
174
std::mutex mutex_;
175
+ std::optional<std::thread::id> thread_id_;
162
176
std::vector<std::shared_ptr<ProtectedPage>> data_;
163
177
};
164
178
0 commit comments