Skip to content

Commit

Permalink
cleanup async names
Browse files Browse the repository at this point in the history
  • Loading branch information
rtjohnso committed Jan 12, 2025
1 parent 88f3848 commit 708b57a
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 240 deletions.
48 changes: 24 additions & 24 deletions src/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,7 @@ btree_lookup_node(cache *cc, // IN
* - state->child_node: the child node
*/
static inline async_status
btree_lookup_node_async2(btree_lookup_async2_state *state, uint64 depth)
btree_lookup_node_async(btree_lookup_async_state *state, uint64 depth)
{
async_begin(state, depth);

Expand All @@ -2100,19 +2100,19 @@ btree_lookup_node_async2(btree_lookup_async2_state *state, uint64 depth)
|| state->type == PAGE_TYPE_MEMTABLE);
state->node.addr = state->root_addr;

cache_get_async2_state_init(state->cache_get_state,
state->cc,
state->node.addr,
state->type,
state->callback,
state->callback_arg);
while (cache_get_async2(state->cc, state->cache_get_state)
cache_get_async_state_init(state->cache_get_state,
state->cc,
state->node.addr,
state->type,
state->callback,
state->callback_arg);
while (cache_get_async(state->cc, state->cache_get_state)
!= ASYNC_STATUS_DONE)
{
async_yield(state);
}
state->node.page =
cache_get_async2_state_result(state->cc, state->cache_get_state);
cache_get_async_state_result(state->cc, state->cache_get_state);
state->node.hdr = (btree_hdr *)state->node.page->data;

for (state->h = btree_height(state->node.hdr);
Expand All @@ -2137,19 +2137,19 @@ btree_lookup_node_async2(btree_lookup_async2_state *state, uint64 depth)
}


cache_get_async2_state_init(state->cache_get_state,
state->cc,
state->child_node.addr,
state->type,
state->callback,
state->callback_arg);
while (cache_get_async2(state->cc, state->cache_get_state)
cache_get_async_state_init(state->cache_get_state,
state->cc,
state->child_node.addr,
state->type,
state->callback,
state->callback_arg);
while (cache_get_async(state->cc, state->cache_get_state)
!= ASYNC_STATUS_DONE)
{
async_yield(state);
}
state->child_node.page =
cache_get_async2_state_result(state->cc, state->cache_get_state);
cache_get_async_state_result(state->cc, state->cache_get_state);
state->child_node.hdr = (btree_hdr *)state->child_node.page->data;

debug_assert(state->child_node.page->disk_addr == state->child_node.addr);
Expand Down Expand Up @@ -2180,13 +2180,13 @@ btree_lookup_node_async2(btree_lookup_async2_state *state, uint64 depth)
* - state->child_node: the child node
*/
static inline async_status
btree_lookup_with_ref_async2(btree_lookup_async2_state *state, uint64 depth)
btree_lookup_with_ref_async(btree_lookup_async_state *state, uint64 depth)
{
async_begin(state, depth);

state->stop_at_height = 0;
state->stats = NULL;
async_await_subroutine(state, btree_lookup_node_async2);
async_await_subroutine(state, btree_lookup_node_async);

int64 idx = btree_find_tuple(
state->cfg, state->node.hdr, state->target, &state->found);
Expand Down Expand Up @@ -2221,11 +2221,11 @@ btree_lookup_with_ref(cache *cc, // IN
}

async_status
btree_lookup_async2(btree_lookup_async2_state *state)
btree_lookup_async(btree_lookup_async_state *state)
{
async_begin(state, 0);

async_await_subroutine(state, btree_lookup_with_ref_async2);
async_await_subroutine(state, btree_lookup_with_ref_async);
bool32 success = TRUE;
if (state->found) {
success = merge_accumulator_copy_message(state->result, state->msg);
Expand Down Expand Up @@ -2267,7 +2267,7 @@ btree_lookup(cache *cc, // IN
// merge_accumulator *result) // OUT
// {
// return async_call_sync_callback(cache_cleanup(cc),
// btree_lookup_async2,
// btree_lookup_async,
// cc,
// cfg,
// root_addr,
Expand Down Expand Up @@ -2329,11 +2329,11 @@ btree_lookup_and_merge(cache *cc, // IN
* - state->msg: the message of the target
*/
async_status
btree_lookup_and_merge_async2(btree_lookup_async2_state *state)
btree_lookup_and_merge_async(btree_lookup_async_state *state)
{
async_begin(state, 0);

async_await_subroutine(state, btree_lookup_with_ref_async2);
async_await_subroutine(state, btree_lookup_with_ref_async);

platform_status rc = STATUS_OK;
if (state->found) {
Expand Down
28 changes: 14 additions & 14 deletions src/btree.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ btree_lookup_and_merge(cache *cc,
bool32 *local_found);

// clang-format off
DEFINE_ASYNC_STATE(btree_lookup_async2_state, 3,
DEFINE_ASYNC_STATE(btree_lookup_async_state, 3,
param, cache *, cc,
param, const btree_config *, cfg,
param, uint64, root_addr,
Expand All @@ -241,29 +241,29 @@ DEFINE_ASYNC_STATE(btree_lookup_async2_state, 3,
local, uint32, h,
local, bool32, found,
local, message, msg,
local, page_get_async2_state_buffer, cache_get_state)
local, page_get_async_state_buffer, cache_get_state)
// clang-format on

static inline void
btree_lookup_and_merge_async2_state_init(btree_lookup_async2_state *state,
cache *cc,
const btree_config *cfg,
uint64 root_addr,
page_type type,
key target,
merge_accumulator *result,
async_callback_fn callback,
void *callback_arg)
btree_lookup_and_merge_async_state_init(btree_lookup_async_state *state,
cache *cc,
const btree_config *cfg,
uint64 root_addr,
page_type type,
key target,
merge_accumulator *result,
async_callback_fn callback,
void *callback_arg)
{
btree_lookup_async2_state_init(
btree_lookup_async_state_init(
state, cc, cfg, root_addr, type, target, result, callback, callback_arg);
}

async_status
btree_lookup_async2(btree_lookup_async2_state *state);
btree_lookup_async(btree_lookup_async_state *state);

async_status
btree_lookup_and_merge_async2(btree_lookup_async2_state *state);
btree_lookup_and_merge_async(btree_lookup_async_state *state);

void
btree_iterator_init(cache *cc,
Expand Down
53 changes: 26 additions & 27 deletions src/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,17 @@ typedef page_handle *(*page_get_fn)(cache *cc,
bool32 blocking,
page_type type);

#define PAGE_GET_ASYNC2_STATE_BUFFER_SIZE (2048)
typedef uint8 page_get_async2_state_buffer[PAGE_GET_ASYNC2_STATE_BUFFER_SIZE];
typedef void (*page_get_async2_state_init_fn)(
page_get_async2_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg);
typedef async_status (*page_get_async2_fn)(page_get_async2_state_buffer buffer);
typedef page_handle *(*page_get_async2_state_result_fn)(
page_get_async2_state_buffer buffer);
#define PAGE_GET_ASYNC_STATE_BUFFER_SIZE (2048)
typedef uint8 page_get_async_state_buffer[PAGE_GET_ASYNC_STATE_BUFFER_SIZE];
typedef void (*page_get_async_state_init_fn)(page_get_async_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg);
typedef async_status (*page_get_async_fn)(page_get_async_state_buffer buffer);
typedef page_handle *(*page_get_async_state_result_fn)(
page_get_async_state_buffer buffer);

typedef bool32 (*page_try_claim_fn)(cache *cc, page_handle *page);
typedef void (*page_sync_fn)(cache *cc,
Expand Down Expand Up @@ -151,9 +150,9 @@ typedef struct cache_ops {
extent_discard_fn extent_discard;
page_get_fn page_get;

page_get_async2_state_init_fn page_get_async2_state_init;
page_get_async2_fn page_get_async2;
page_get_async2_state_result_fn page_get_async2_result;
page_get_async_state_init_fn page_get_async_state_init;
page_get_async_fn page_get_async;
page_get_async_state_result_fn page_get_async_result;

page_generic_fn page_unget;
page_try_claim_fn page_try_claim;
Expand Down Expand Up @@ -261,27 +260,27 @@ cache_get(cache *cc, uint64 addr, bool32 blocking, page_type type)
}

static inline void
cache_get_async2_state_init(page_get_async2_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg)
{
return cc->ops->page_get_async2_state_init(
cache_get_async_state_init(page_get_async_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg)
{
return cc->ops->page_get_async_state_init(
buffer, cc, addr, type, callback, callback_arg);
}

static inline async_status
cache_get_async2(cache *cc, page_get_async2_state_buffer buffer)
cache_get_async(cache *cc, page_get_async_state_buffer buffer)
{
return cc->ops->page_get_async2(buffer);
return cc->ops->page_get_async(buffer);
}

static inline page_handle *
cache_get_async2_state_result(cache *cc, page_get_async2_state_buffer buffer)
cache_get_async_state_result(cache *cc, page_get_async_state_buffer buffer)
{
return cc->ops->page_get_async2_result(buffer);
return cc->ops->page_get_async_result(buffer);
}

/*
Expand Down
56 changes: 28 additions & 28 deletions src/clockcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ clockcache_get(clockcache *cc, uint64 addr, bool32 blocking, page_type type)
*/

// clang-format off
DEFINE_ASYNC_STATE(clockcache_get_async2_state, 3,
DEFINE_ASYNC_STATE(clockcache_get_async_state, 3,
param, clockcache *, cc,
param, uint64, addr,
param, page_type, type,
Expand All @@ -1783,17 +1783,17 @@ DEFINE_ASYNC_STATE(clockcache_get_async2_state, 3,
local, async_waiter, wait_node)
// clang-format on

_Static_assert(sizeof(clockcache_get_async2_state)
<= PAGE_GET_ASYNC2_STATE_BUFFER_SIZE,
"clockcache_get_async2_state is too large");
_Static_assert(sizeof(clockcache_get_async_state)
<= PAGE_GET_ASYNC_STATE_BUFFER_SIZE,
"clockcache_get_async_state is too large");


/*
* Result is FALSE if we failed to find the page in cache and hence need to
* retry the get from the beginning, TRUE if we succeeded.
*/
static async_status
clockcache_get_in_cache_async(clockcache_get_async2_state *state, uint64 depth)
clockcache_get_in_cache_async(clockcache_get_async_state *state, uint64 depth)
{
async_begin(state, depth);

Expand Down Expand Up @@ -1846,13 +1846,13 @@ clockcache_get_in_cache_async(clockcache_get_async2_state *state, uint64 depth)
void
clockcache_get_from_disk_async_callback(void *arg)
{
clockcache_get_async2_state *state = (clockcache_get_async2_state *)arg;
clockcache_get_async_state *state = (clockcache_get_async_state *)arg;
clockcache_finish_load(state->cc, state->addr, state->entry_number);
state->callback(state->callback_arg);
}

static async_status
clockcache_get_from_disk_async(clockcache_get_async2_state *state, uint64 depth)
clockcache_get_from_disk_async(clockcache_get_async_state *state, uint64 depth)
{
async_begin(state, depth);

Expand Down Expand Up @@ -1896,7 +1896,7 @@ clockcache_get_from_disk_async(clockcache_get_async2_state *state, uint64 depth)

// Result is TRUE if successful, FALSE otherwise
static async_status
clockcache_get_internal_async(clockcache_get_async2_state *state, uint64 depth)
clockcache_get_internal_async(clockcache_get_async_state *state, uint64 depth)
{
async_begin(state, depth);

Expand Down Expand Up @@ -1944,7 +1944,7 @@ clockcache_get_internal_async(clockcache_get_async2_state *state, uint64 depth)
}

async_status
clockcache_get_async2(clockcache_get_async2_state *state)
clockcache_get_async(clockcache_get_async_state *state)
{
async_begin(state, 0);

Expand Down Expand Up @@ -2836,31 +2836,31 @@ clockcache_unpin_virtual(cache *c, page_handle *page)
}

static void
clockcache_get_async2_state_init_virtual(page_get_async2_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg)
clockcache_get_async_state_init_virtual(page_get_async_state_buffer buffer,
cache *cc,
uint64 addr,
page_type type,
async_callback_fn callback,
void *callback_arg)
{
clockcache_get_async2_state_init((clockcache_get_async2_state *)buffer,
(clockcache *)cc,
addr,
type,
callback,
callback_arg);
clockcache_get_async_state_init((clockcache_get_async_state *)buffer,
(clockcache *)cc,
addr,
type,
callback,
callback_arg);
}

static async_status
clockcache_get_async2_virtual(page_get_async2_state_buffer buffer)
clockcache_get_async_virtual(page_get_async_state_buffer buffer)
{
return clockcache_get_async2((clockcache_get_async2_state *)buffer);
return clockcache_get_async((clockcache_get_async_state *)buffer);
}

static page_handle *
clockcache_get_async2_state_result_virtual(page_get_async2_state_buffer buffer)
clockcache_get_async_state_result_virtual(page_get_async_state_buffer buffer)
{
clockcache_get_async2_state *state = (clockcache_get_async2_state *)buffer;
clockcache_get_async_state *state = (clockcache_get_async_state *)buffer;
return state->__async_result;
}

Expand Down Expand Up @@ -2998,9 +2998,9 @@ static cache_ops clockcache_ops = {
.extent_discard = clockcache_extent_discard_virtual,
.page_get = clockcache_get_virtual,

.page_get_async2_state_init = clockcache_get_async2_state_init_virtual,
.page_get_async2 = clockcache_get_async2_virtual,
.page_get_async2_result = clockcache_get_async2_state_result_virtual,
.page_get_async_state_init = clockcache_get_async_state_init_virtual,
.page_get_async = clockcache_get_async_virtual,
.page_get_async_result = clockcache_get_async_state_result_virtual,

.page_unget = clockcache_unget_virtual,
.page_try_claim = clockcache_try_claim_virtual,
Expand Down
Loading

0 comments on commit 708b57a

Please sign in to comment.