Merge pull request #1074 from urbit/keep-no-more

removes i/o polling, adds timer effects for %behn
This commit is contained in:
Joe Bryan 2018-11-26 17:27:42 -05:00 committed by GitHub
commit 06ea97414c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 59 additions and 216 deletions

View File

@ -1 +1 @@
97b340675934ce196878a569d4fa1b78e26a0d33
e661d55e491bbb28a2f7272bd1ab244f34a8ee17

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

@ -253,7 +253,6 @@
uv_udp_t wax_u;
uv_handle_t had_u;
};
uv_timer_t tim_u; // network timer
c3_o liv; // listener on
c3_o alm; // alarm on
c3_w law_w; // last wakeup, unix time
@ -434,7 +433,6 @@
*/
typedef struct _u3_behn {
uv_timer_t tim_u; // behn timer
c3_w run_w; // run of consecutive alarms
c3_o alm; // alarm
} u3_behn;
@ -904,11 +902,6 @@
void
u3_term_io_exit(void);
/* u3_term_io_poll(): update terminal IO state.
*/
void
u3_term_io_poll(void);
/* u3_term_io_hija(): hijack console for cooked print.
*/
FILE*
@ -960,11 +953,6 @@
void
u3_ames_io_exit(void);
/* u3_ames_io_poll(): update ames IO state.
*/
void
u3_ames_io_poll(void);
/** Autosave.
**/
/* u3_save_ef_chld(): report SIGCHLD.
@ -982,11 +970,6 @@
void
u3_save_io_exit(void);
/* u3_save_io_poll(): update autosave state.
*/
void
u3_save_io_poll(void);
/** Storage, new school.
**/
/* u3_unix_ef_hold():
@ -1039,12 +1022,6 @@
void
u3_unix_io_exit(void);
/* u3_unix_io_poll(): update storage state.
*/
void
u3_unix_io_poll(void);
/** behn, just a timer.
**/
/* u2_behn_io_init(): initialize behn timer.
@ -1057,11 +1034,15 @@
void
u2_behn_io_exit(void);
/* u2_behn_io_poll(): update behn IO state.
/* u3_behn_ef_bake(): notify %behn that we're live
*/
void
u2_behn_io_poll(void);
u3_behn_ef_bake(void);
/* u3_behn_ef_doze(): set or cancel timer
*/
void
u3_behn_ef_doze(u3_noun wen);
/** HTTP server.
**/
@ -1109,11 +1090,6 @@
void
u3_http_io_exit(void);
/* u3_http_io_poll(): update http IO state.
*/
void
u3_http_io_poll(void);
/** Raft log syncing.
**/
/* u3_raft_readopt(): parse command line options.
@ -1202,24 +1178,6 @@
void
u3_sist_rand(c3_w* rad_w);
/** New timer system.
**/
/* u3_behn_io_init(): initialize time timer.
*/
void
u3_behn_io_init(void);
/* u3_behn_io_exit(): terminate timer.
*/
void
u3_behn_io_exit(void);
/* u3_behn_io_poll(): update behn IO state.
*/
void
u3_behn_io_poll(void);
/** HTTP client.
**/
/* u3_cttp_ef_thus(): send %thus effect to cttp.
@ -1237,8 +1195,3 @@
*/
void
u3_cttp_io_exit(void);
/* u3_cttp_io_poll(): update cttp IO state.
*/
void
u3_cttp_io_poll(void);

View File

@ -2,4 +2,4 @@
mkdir ./build &> /dev/null
meson . ./build --buildtype=release "$@"
ninja -C build
ninja -C build urbit

View File

@ -324,30 +324,6 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac)
u3z(lan); u3z(pac);
}
/* _ames_time_cb(): timer callback.
*/
static void
_ames_time_cb(uv_timer_t* tim_uo)
{
u3_ames* sam_u = &u3_Host.sam_u;
// defer until started via u3_ames_ef_turf()
if ( c3n == sam_u->liv ) {
uv_timer_start(&sam_u->tim_u, _ames_time_cb, 1000, 0);
}
else {
u3_lo_open();
sam_u->law_w = time(0);
{
u3v_plan
(u3nt(u3_blip, c3__ames, u3_nul),
u3nc(c3__wake, u3_nul));
}
u3_lo_shut(c3n);
}
}
/* _ames_recv_cb(): receive callback.
*/
static void
@ -545,7 +521,6 @@ u3_ames_io_init()
{
u3_ames* sam_u = &u3_Host.sam_u;
sam_u->liv = c3n;
uv_timer_init(u3L, &sam_u->tim_u);
}
/* u3_ames_io_talk(): start receiving ames traffic.
@ -562,44 +537,8 @@ u3_ames_io_exit()
{
u3_ames* sam_u = &u3_Host.sam_u;
uv_close((uv_handle_t*)&sam_u->tim_u, 0);
if ( c3y == sam_u->liv ) {
// XX remove had_u/wax_u union, cast and close wax_u
uv_close(&sam_u->had_u, 0);
}
}
/* u3_ames_io_poll(): update ames IO state.
*/
void
u3_ames_io_poll()
{
u3_ames* sam_u = &u3_Host.sam_u;
u3_noun wen = u3v_keep(u3nt(u3_blip, c3__ames, u3_nul));
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)));
c3_w lem_w = (time(0) - sam_u->law_w);
c3_w lef_w = (lem_w > 32) ? 0 : (32 - lem_w);
gap_d = c3_min(gap_d, (c3_d)(1000 * lef_w));
if ( c3y == sam_u->alm ) {
uv_timer_stop(&sam_u->tim_u);
}
else sam_u->alm = c3y;
uv_timer_start(&sam_u->tim_u, _ames_time_cb, gap_d, 0);
}
else {
if ( c3y == sam_u->alm ) {
uv_timer_stop(&sam_u->tim_u);
}
sam_u->alm = c3n;
}
u3z(wen);
}

View File

@ -45,9 +45,7 @@ static void
_behn_time_cb(uv_timer_t* tim_u)
{
u3_behn* teh_u = &u3_Host.teh_u;
if(teh_u->run_w < 1024) {
teh_u->run_w++;
}
teh_u->alm = c3n;
u3_lo_open();
{
@ -58,38 +56,40 @@ _behn_time_cb(uv_timer_t* tim_u)
u3_lo_shut(c3n);
}
/* u3_behn_io_poll(): update behn IO state.
/* u3_behn_ef_doze(): set or cancel timer
*/
void
u3_behn_io_poll(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)));
struct timeval tim_tv;
gettimeofday(&tim_tv, 0);
#if 0
fprintf(stderr, "gap_d %llu, plus %llu\r\n",
gap_d, gap_d + (c3_d)teh_u->run_w);
#endif
gap_d += teh_u->run_w;
if ( c3y == teh_u->alm ) {
uv_timer_stop(&teh_u->tim_u);
}
else teh_u->alm = c3y;
u3_noun now = u3_time_in_tv(&tim_tv);
c3_d gap_d = u3_time_gap_ms(now, u3k(u3t(wen)));
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

@ -976,13 +976,6 @@ u3_cttp_io_init()
u3_Host.ctp_u.ceq_u = 0;
}
/* u3_cttp_io_poll(): poll kernel for cttp I/O.
*/
void
u3_cttp_io_poll(void)
{
}
/* u3_cttp_io_exit(): shut down cttp.
*/
void

View File

@ -1561,13 +1561,6 @@ u3_http_io_talk(void)
{
}
/* u3_http_io_poll(): poll kernel for http I/O.
*/
void
u3_http_io_poll(void)
{
}
/* u3_http_io_exit(): shut down http.
*/
void

View File

@ -254,38 +254,6 @@ u3_lo_exit(void)
u3a_lop(cod_l);
}
/* _lo_poll(): reset event flags across the process.
*/
static void
_lo_poll(void)
{
c3_l cod_l;
cod_l = u3a_lush(c3__ames);
u3_ames_io_poll();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__http);
u3_http_io_poll();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__term);
u3_term_io_poll();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__save);
u3_save_io_poll();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__unix);
u3_unix_io_poll();
u3a_lop(cod_l);
cod_l = u3a_lush(c3__behn);
u3_behn_io_poll();
u3a_lop(cod_l);
}
#if 0
/* _lo_how(): print how.
*/
@ -479,11 +447,6 @@ u3_lo_shut(c3_o inn)
u3e_save();
exit(u3_Host.xit_i);
}
else {
// poll arvo to generate any event binding changes
//
_lo_poll();
}
}
#if 0
@ -669,6 +632,7 @@ u3_lo_lead(void)
{
if ( c3n == u3_Host.ops_u.nuu ) {
u3_ames_ef_bake();
u3_behn_ef_bake();
}
u3_http_ef_bake();
@ -680,7 +644,6 @@ u3_lo_lead(void)
u3v_plan(u3nt(u3_blip, c3__ames, u3_nul),
u3nc(c3__kick, u3k(u3A->now)));
}
_lo_poll();
#if 0
u3_loom_save(u3A->ent_d);

View File

@ -1559,12 +1559,6 @@ _raft_punk(u3_noun ovo)
sec_w = 0;
} else sec_w = 600;
// Control alarm loops.
//
if ( c3__wake != u3h(u3t(ovo)) ) {
u3_Host.teh_u.run_w = 0;
}
#ifdef GHETTO
struct timeval b4, f2, d0;
gettimeofday(&b4, 0);

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

@ -80,10 +80,3 @@ void
u3_save_io_exit(void)
{
}
/* u3_save_io_poll(): poll kernel for save I/O.
*/
void
u3_save_io_poll(void)
{
}

View File

@ -1624,6 +1624,9 @@ u3_sist_boot(void)
u3_Host.ops_u.has = c3y;
u3C.wag_w |= u3o_hashless;
}
// process pending events
u3_raft_work();
}
else {
u3_noun pig, who;
@ -1687,6 +1690,9 @@ u3_sist_boot(void)
u3_ames_ef_bake();
}
// initialize %behn
u3_behn_ef_bake();
// Authenticate and initialize terminal.
u3_term_ef_bake(pig);

View File

@ -303,11 +303,6 @@ u3_term_io_exit(void)
}
}
void
u3_term_io_poll(void)
{
}
/* _term_it_buf(): create a data buffer.
*/
static u3_ubuf*

View File

@ -1486,10 +1486,3 @@ u3_unix_io_exit(void)
uv_check_stop(&u3_Host.unx_u.syn_u);
u3_unix_release(u3_Host.dir_c);
}
/* u3_unix_io_poll(): update unix IO state.
*/
void
u3_unix_io_poll(void)
{
}