summaryrefslogtreecommitdiff
path: root/src/report-entry-arrays.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2021-08-23 23:49:17 -0700
committerVito Caputo <vcaputo@pengaru.com>2021-08-24 00:48:46 -0700
commit6150dcd14773517d5c0fff0fee7bc6fe6f75e086 (patch)
tree086cb81303863adaca76364c703bce4dab66953e /src/report-entry-arrays.c
parent34e7db0b48b952141b8fd392ff03dfc57124fc3d (diff)
thunk_h: bump submodule for new lifecycle model
Udpate thunk usage througout to explicitly control thunk instance lifecycles from calleees according to new model. This enables discarding a bunch of the per-object dispatch thunks, eliminates some thunk leaks, and I think generally makes the code more expressive and clear about what's going on. Keep in mind this is all experimental and and I'm not spending a whole lot of time on this, it's mostly a toy and exploring some different programming styles I'd never really consider for production/real work. Though it actually has some interesting properties, and produces some surprisingly succinct and readable listings at times once you have the cumbersome building blocks in place. Especially for non-daemon programs where you can basically either log+ignore errors or treat them as fatal, I think this programming style might actually have its place.
Diffstat (limited to 'src/report-entry-arrays.c')
-rw-r--r--src/report-entry-arrays.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/src/report-entry-arrays.c b/src/report-entry-arrays.c
index 98f54e1..73aea34 100644
--- a/src/report-entry-arrays.c
+++ b/src/report-entry-arrays.c
@@ -125,24 +125,7 @@ THUNK_DEFINE_STATIC(per_entry_array_payload, iou_t *, iou, iou_op_t *, op, uint6
free(payload_buf);
- return thunk_dispatch(closure);
-}
-
-
-/* this is derived from journal_iter_objects_dispatch(), and frankly the need for a separate dispatch
- * thunk is pretty much entirely because thunk.h doesn't have a more streamlined means of controlling
- * thunk instance life-cycles. If the return value could control freeing in thunk_dispatch(), I don't
- * think this kruft would exist at all. But in the interest of just making things work for now, leave
- * it be and do this junk TODO FIXME
- * XXX also, if this manual dispatch sticks around, journals.[ch] should prolly just export this variant
- * for the manual iter cases...
- */
-THUNK_DEFINE_STATIC(per_object_dispatch, uint64_t *, iter_offset, thunk_t *, closure)
-{
- if (!(*iter_offset))
- return thunk_dispatch(closure);
-
- return thunk_dispatch_keep(closure);
+ return thunk_end(thunk_dispatch(closure));
}
@@ -235,8 +218,7 @@ THUNK_DEFINE_STATIC(per_object, thunk_t *, self, uint64_t *, iter_offset, Object
/* skip non-entry-array objects */
if (iter_object_header->type != OBJECT_ENTRY_ARRAY)
- return journal_iter_next_object(iou, journal, header, iter_offset, iter_object_header, THUNK(
- per_object_dispatch(iter_offset, self)));
+ return thunk_mid(journal_iter_next_object(iou, journal, header, iter_offset, iter_object_header, self));
stats->count++;
@@ -260,12 +242,10 @@ THUNK_DEFINE_STATIC(per_object, thunk_t *, self, uint64_t *, iter_offset, Object
op->sqe->flags = IOSQE_FIXED_FILE;
op_queue(iou, op, THUNK(
per_entry_array_payload(iou, op, payload_size, buf, stats, THUNK(
- journal_iter_next_object(iou, journal, header, iter_offset, iter_object_header, THUNK(
- per_object_dispatch(iter_offset, self)))))));
+ journal_iter_next_object(iou, journal, header, iter_offset, iter_object_header, self)))));
}
-
- return 0;
+ return 1;
}
@@ -288,9 +268,8 @@ THUNK_DEFINE_STATIC(per_journal, iou_t *, iou, journal_t **, journal_iter)
foo->journal = *journal_iter;
return journal_get_header(iou, &foo->journal, &foo->header, THUNK(
- journal_iter_next_object(iou, &foo->journal, &foo->header, &foo->iter_offset, &foo->iter_object_header, THUNK(
- per_object_dispatch(&foo->iter_offset, THUNK_INIT(
- per_object(closure, closure, &foo->iter_offset, &foo->iter_object_header, iou, &foo->journal, &foo->header, &foo->stats)))))));
+ journal_iter_next_object(iou, &foo->journal, &foo->header, &foo->iter_offset, &foo->iter_object_header, THUNK_INIT(
+ per_object(closure, closure, &foo->iter_offset, &foo->iter_object_header, iou, &foo->journal, &foo->header, &foo->stats)))));
}
© All Rights Reserved