updates %behn to use effects instead of u3v_keep polling

This commit is contained in:
Joe Bryan 2018-11-26 02:52:53 -05:00
parent a9c8615674
commit a77f6401a7
6 changed files with 62 additions and 17 deletions

View File

@ -325,6 +325,7 @@
# define c3__dorn c3_s4('d','o','r','n')
# define c3__dost c3_s4('d','o','s','t')
# define c3__dot c3_s3('d','o','t')
# define c3__doze c3_s4('d','o','z','e')
# define c3__drag c3_s4('d','r','a','g')
# define c3__draz c3_s4('d','r','a','z')
# define c3__drib c3_s4('d','r','i','b')

View File

@ -1061,6 +1061,15 @@
void
u2_behn_io_poll(void);
/* u3_behn_ef_bake(): notify %behn that we're live
*/
void
u3_behn_ef_bake(void);
/* u3_behn_ef_doze(): set or cancel timer
*/
void
u3_behn_ef_doze(u3_noun wen);
/** HTTP server.
**/

View File

@ -45,6 +45,9 @@ static void
_behn_time_cb(uv_timer_t* tim_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
// XX remove timer backoff
//
if(teh_u->run_w < 1024) {
teh_u->run_w++;
}
@ -62,34 +65,42 @@ _behn_time_cb(uv_timer_t* tim_u)
*/
void
u3_behn_io_poll(void)
{
}
/* u3_behn_ef_doze(): set or cancel timer
*/
void
u3_behn_ef_doze(u3_noun wen)
{
u3_behn* teh_u = &u3_Host.teh_u;
u3_noun wen = u3v_keep(u3nt(u3_blip, c3__behn, u3_nul));
if ( c3y == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
teh_u->alm = c3n;
}
if ( (u3_nul != wen) &&
(c3y == u3du(wen)) &&
(c3y == u3ud(u3t(wen))) )
{
c3_d gap_d = u3_time_gap_ms(u3k(u3A->now), u3k(u3t(wen)));
#if 0
fprintf(stderr, "gap_d %llu, plus %llu\r\n",
gap_d, gap_d + (c3_d)teh_u->run_w);
#endif
// XX remove timer backoff
//
gap_d += teh_u->run_w;
if ( c3y == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
}
else teh_u->alm = c3y;
uv_timer_start(&teh_u->tim_u, _behn_time_cb, gap_d, 0);
}
else {
if ( c3y == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
}
teh_u->alm = c3n;
}
u3z(wen);
}
/* u3_behn_ef_bake(): notify %behn that we're live
*/
void
u3_behn_ef_bake(void)
{
u3_noun pax = u3nq(u3_blip, c3__behn, u3k(u3A->sen), u3_nul);
u3v_plan(pax, u3nc(c3__born, u3_nul));
}

View File

@ -669,6 +669,7 @@ u3_lo_lead(void)
{
if ( c3n == u3_Host.ops_u.nuu ) {
u3_ames_ef_bake();
u3_behn_ef_bake();
}
u3_http_ef_bake();

View File

@ -166,6 +166,22 @@ _reck_kick_http(u3_noun pox,
c3_assert(!"not reached"); return c3n;
}
/* _reck_kick_behn(): apply packet network outputs.
*/
static u3_noun
_reck_kick_behn(u3_noun pox, u3_noun fav)
{
switch ( u3h(fav) ) {
default: break;
case c3__doze: {
u3_behn_ef_doze(u3k(u3t(fav)));
u3z(pox); u3z(fav); return c3y;
} break;
}
u3z(pox); u3z(fav); return c3n;
}
/* _reck_kick_sync(): apply sync outputs.
*/
static u3_noun
@ -277,6 +293,10 @@ _reck_kick_spec(u3_noun pox, u3_noun fav)
return _reck_kick_http(pox, sev_l, coq_l, seq_l, fav);
} break;
case c3__behn: {
return _reck_kick_behn(pox, fav);
} break;
case c3__clay:
case c3__boat:
case c3__sync: {

View File

@ -1687,6 +1687,9 @@ u3_sist_boot(void)
u3_ames_ef_bake();
}
// initialize %behn
u3_behn_ef_bake();
// Authenticate and initialize terminal.
u3_term_ef_bake(pig);