updates u3_raft_work() to be async, adds sync u3_raft_play()

This commit is contained in:
Ted Blackman 2017-12-19 07:22:02 -08:00 committed by Joe Bryan
parent 6e77f2b2c1
commit d8b7068345
4 changed files with 40 additions and 20 deletions

View File

@ -1104,7 +1104,12 @@
void
u3_raft_init(void);
/* u3_raft_work(): poke, kick, and push pending events.
/* u3_raft_play(): synchronously poke, kick, and push pending events.
*/
void
u3_raft_play(void);
/* u3_raft_work(): asynchronously poke, kick, and push pending events.
*/
void
u3_raft_work(void);

View File

@ -442,6 +442,7 @@ u3_lo_shut(c3_o inn)
if ( c3n == u3_Host.liv ) {
// direct save and die
//
u3_raft_play();
// u3_lo_grab("lo_exit", u3_none);
// u3_loom_save(u3A->ent_d);
// u3_loom_exit();

View File

@ -2070,26 +2070,38 @@ u3_raft_chip(void)
}
}
/* u3_raft_work(): work, either synchronously or asynchronously.
/* u3_raft_play(): synchronously process events.
*/
void
u3_raft_play(void)
{
c3_assert( u3Z->typ_e == u3_raty_lead );
u3_raft_chip();
if ( u3_nul != u3A->roe ) {
u3_raft_play();
}
}
/* _raft_work_cb(): callback to recurse into u3_raft_work().
*/
static void
_raft_work_cb(uv_timer_t* tim_u)
{
u3_raft_work();
}
/* u3_raft_work(): asynchronously process events.
*/
void
u3_raft_work(void)
{
if ( u3Z->typ_e != u3_raty_lead ) {
c3_assert(u3A->ova.egg_p == 0);
if ( u3_nul != u3A->roe ) {
uL(fprintf(uH, "raft: dropping roe!!\n"));
u3z(u3A->roe);
u3A->roe = u3_nul;
}
}
else {
c3_assert( u3Z->typ_e == u3_raty_lead );
// Cartify, jam, and encrypt this batch of events.
// Take a number, Raft will be with you shortly.
//
while ( u3_nul != u3A->roe ) {
u3_raft_chip();
}
u3_raft_chip();
if ( u3_nul != u3A->roe ) {
uv_timer_start(&u3Z->tim_u, _raft_work_cb, 0, 0);
}
}

View File

@ -595,7 +595,8 @@ _sist_zest()
}
// Work through the boot events.
u3_raft_work();
//
u3_raft_play();
}
/* _sist_rest_nuu(): upgrade log from previous format.
@ -1223,8 +1224,9 @@ u3_sist_boot(void)
u3C.wag_w |= u3o_hashless;
}
// process pending events
u3_raft_work();
// process pending events
//
u3_raft_play();
}
else {
u3_noun pig, who;