Skip to content

Commit 558030f

Browse files
committed
p1: support custom promise API
Signed-off-by: Alex Chi <[email protected]>
1 parent 03b9be6 commit 558030f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/include/storage/disk/disk_scheduler.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ class DiskScheduler {
7373
*/
7474
void StartWorkerThread();
7575

76+
using DiskSchedulerPromise = std::promise<bool>;
77+
78+
/**
79+
* @brief Create a Promise object. If you want to implement your own version of promise, you can change this function
80+
* so that our test cases can use your promise implementation.
81+
*
82+
* @return std::promise<bool>
83+
*/
84+
auto CreatePromise() -> DiskSchedulerPromise { return {}; };
85+
7686
private:
7787
/** Pointer to the disk manager. */
7888
DiskManager *disk_manager_ __attribute__((__unused__));

test/storage/disk_scheduler_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ TEST(DiskSchedulerTest, DISABLED_ScheduleWriteReadPageTest) {
3333

3434
std::strncpy(data, "A test string.", sizeof(data));
3535

36-
std::promise<bool> promise1;
36+
auto promise1 = disk_scheduler->CreatePromise();
3737
auto future1 = promise1.get_future();
38-
std::promise<bool> promise2;
38+
auto promise2 = disk_scheduler->CreatePromise();
3939
auto future2 = promise2.get_future();
4040

4141
disk_scheduler->Schedule({/*is_write=*/true, reinterpret_cast<char *>(&data), /*page_id=*/0, promise1});

0 commit comments

Comments
 (0)