Factor behn

This commit is contained in:
Raymond Pasco 2017-02-22 18:11:04 -05:00
parent f3e7e7c27d
commit 3751e9212d
4 changed files with 25 additions and 20 deletions

View File

@ -659,7 +659,6 @@
u3_save sav_u; // autosave
u3_opts ops_u; // commandline options
u3_unix unx_u; // sync and clay
u3_behn teh_u; // behn timer
c3_o liv; // if u3_no, shut down
c3_i xit_i; // exit code for shutdown
void* ssl_u; // struct SSL_CTX*
@ -734,7 +733,8 @@
c3_d key_d[4]; // save and passkey
u3_disk* log_u; // event log
u3_lord* god_u; // computer
u3_ames* sam_u; // packet interface
u3_ames* sam_u; // packet interface
u3_behn* teh_u; // behn timer
u3_writ* ent_u; // entry of queue
u3_writ* ext_u; // exit of queue
} u3_pier;
@ -1395,17 +1395,17 @@
/* u3_behn_io_init(): initialize time timer.
*/
void
u3_behn_io_init(void);
u3_behn_io_init(u3_pier *pir_u);
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void);
u3_behn_io_exit(u3_pier *pir_u);
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void);
u3_behn_io_poll(u3_pier *pir_u);
/** HTTP client.

View File

@ -24,9 +24,9 @@
/* u3_behn(): initialize time timer.
*/
void
u3_behn_io_init(void)
u3_behn_io_init(u3_pier *pir_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_behn* teh_u = pir_u->teh_u;
uv_timer_init(u3L, &teh_u->tim_u);
teh_u->alm = c3n;
@ -35,7 +35,7 @@ u3_behn_io_init(void)
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void)
u3_behn_io_exit(u3_pier *pir_u)
{
}
@ -44,14 +44,16 @@ u3_behn_io_exit(void)
static void
_behn_time_cb(uv_timer_t* tim_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_pier *pir_u = tim_u->data;
u3_behn* teh_u = pir_u->teh_u;
if(teh_u->run_w < 1024) {
teh_u->run_w++;
}
{
u3_pier_plan
(u3nt(u3_blip, c3__behn, u3_nul),
u3_pier_work
(pir_u,
u3nt(u3_blip, c3__behn, u3_nul),
u3nc(c3__wake, u3_nul));
}
}
@ -59,9 +61,9 @@ _behn_time_cb(uv_timer_t* tim_u)
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void)
u3_behn_io_poll(u3_pier *pir_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_behn* teh_u = pir_u->teh_u;
u3_noun wen = u3v_keep(u3nt(u3_blip, c3__behn, u3_nul));
if ( (u3_nul != wen) &&
@ -81,6 +83,7 @@ u3_behn_io_poll(void)
}
else teh_u->alm = c3y;
teh_u->tim_u.data = pir_u;
uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0);
}
else {

View File

@ -288,7 +288,7 @@ void _king_loop_exit()
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_exit();
u3_behn_io_exit(u3_pier_stub());
u3a_lop(cod_l);
unlink("/tmp/urbit.sock");

View File

@ -1271,6 +1271,8 @@ u3_pier_create(c3_c* pax_c, c3_c* sys_c)
pir_u->sam_u = c3_malloc(sizeof(u3_ames));
memset(pir_u->sam_u, 0, sizeof(u3_ames));
pir_u->teh_u = c3_malloc(sizeof(u3_behn));
memset(pir_u->teh_u, 0, sizeof(u3_behn));
}
/* start process
@ -1416,10 +1418,6 @@ _pier_loop_init(void)
cod_l = u3a_lush(c3__save);
u3_save_io_init();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_init();
u3a_lop(cod_l);
}
/* _pier_loop_init_pier(): initialize loop handlers.
@ -1432,6 +1430,10 @@ _pier_loop_init_pier(u3_pier* pir_u)
cod_l = u3a_lush(c3__ames);
u3_ames_io_init(pir_u);
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_init(pir_u);
u3a_lop(cod_l);
}
/* _pier_loop_wake(): initialize listeners and send initial events.
@ -1494,7 +1496,7 @@ _pier_loop_exit(void)
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_exit();
u3_behn_io_exit(u3_pier_stub());
u3a_lop(cod_l);
}
@ -1526,7 +1528,7 @@ _pier_loop_poll(u3_pier* pir_u)
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_poll();
u3_behn_io_poll(pir_u);
u3a_lop(cod_l);
}