From 383ab05977ede8b5f99a1e0ea3bcbc049c0aba6e Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 15 Oct 2014 02:25:23 +0000 Subject: [PATCH 1/2] added %time vane --- Makefile | 1 + include/c/motes.h | 2 + include/v/vere.h | 27 ++++++++++++++ v/loop.c | 4 ++ v/raft.c | 1 + v/reck.c | 1 - v/temp.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 v/temp.c diff --git a/Makefile b/Makefile index 62b28ded28..2bdcee4fed 100644 --- a/Makefile +++ b/Makefile @@ -283,6 +283,7 @@ V_OFILES=\ v/reck.o \ v/save.o \ v/sist.o \ + v/temp.o \ v/term.o \ v/time.o \ v/unix.o \ diff --git a/include/c/motes.h b/include/c/motes.h index 4bb4e88f6c..82427b6940 100644 --- a/include/c/motes.h +++ b/include/c/motes.h @@ -994,6 +994,7 @@ # define c3__teal c3_s4('t','e','a','l') # define c3__teck c3_s4('t','e','c','k') # define c3__tell c3_s4('t','e','l','l') +# define c3__temp c3_s4('t','e','m','p') # define c3__terg c3_s4('t','e','r','g') # define c3__term c3_s4('t','e','r','m') # define c3__test c3_s4('t','e','s','t') @@ -1001,6 +1002,7 @@ # define c3__this c3_s4('t','h','i','s') # define c3__thin c3_s4('t','h','i','n') # define c3__thud c3_s4('t','h','u','d') +# define c3__time c3_s4('t','i','m','e') # define c3__tgbn c3_s4('t','g','b','n') # define c3__tgbr c3_s4('t','g','b','r') # define c3__tgdg c3_s4('t','g','d','g') diff --git a/include/v/vere.h b/include/v/vere.h index 6159c2d10b..70a8b9679f 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -373,6 +373,14 @@ u2_bean alm; // alarm } u2_batz; + /* u2_temp: just a timer for ever + */ + typedef struct _u2_temp { + uv_timer_t tim_u; // clay timer + c3_w run_w; // run of consecutive alarms + u2_bean alm; // alarm + } u2_temp; + /* u2_utfo: unix terminfo strings. */ typedef struct { @@ -553,6 +561,7 @@ u2_opts ops_u; // commandline options u2_unix unx_u; // sync and clay u2_batz beh_u; // batz timer + u2_temp teh_u; // temp timer u2_bean liv; // if u2_no, shut down c3_i xit_i; // exit code for shutdown void* ssl_u; // struct SSL_CTX* @@ -1097,6 +1106,24 @@ u2_batz_io_poll(void); + /** Temp, just a timer. + **/ + /* u2_temp_io_init(): initialize temp timer. + */ + void + u2_temp_io_init(void); + + /* u2_temp_io_exit(): terminate timer. + */ + void + u2_temp_io_exit(void); + + /* u2_temp_io_poll(): update temp IO state. + */ + void + u2_temp_io_poll(void); + + /** HTTP server. **/ /* u2_http_ef_thou(): send %thou effect to http. diff --git a/v/loop.c b/v/loop.c index 6d1979438d..8a344dd8b6 100644 --- a/v/loop.c +++ b/v/loop.c @@ -168,6 +168,7 @@ _lo_init() u2_cttp_io_init(); u2_save_io_init(); u2_batz_io_init(); + u2_temp_io_init(); } /* _lo_talk(): bring up listeners across the process. @@ -193,6 +194,7 @@ u2_lo_exit(void) u2_cttp_io_exit(); u2_save_io_exit(); u2_batz_io_exit(); + u2_temp_io_exit(); } /* _lo_poll(): reset event flags across the process. @@ -206,6 +208,7 @@ _lo_poll(void) u2_save_io_poll(); u2_unix_io_poll(); u2_batz_io_poll(); + u2_temp_io_poll(); } #if 0 @@ -219,6 +222,7 @@ _lo_how(u2_noun how) case c3__ames: return "ames"; case c3__batz: return "batz"; + case c3__temp: return "temp"; case c3__term: return "cons"; case c3__htcn: return "http-conn"; case c3__htls: return "http-lisn"; diff --git a/v/raft.c b/v/raft.c index f0c071609c..99023f6e0f 100644 --- a/v/raft.c +++ b/v/raft.c @@ -1562,6 +1562,7 @@ _raft_punk(u2_reck* rec_u, u2_noun ovo) // if ( c3__wake != u2h(u2t(ovo)) ) { u2_Host.beh_u.run_w = 0; + u2_Host.teh_u.run_w = 0; } #ifdef GHETTO diff --git a/v/reck.c b/v/reck.c index 19b194282c..311d8c425e 100644 --- a/v/reck.c +++ b/v/reck.c @@ -169,7 +169,6 @@ _reck_nock_keep(u2_reck* rec_u, u2_noun hap) { u2_noun fun = u2_cn_nock(u2k(rec_u->roc), u2k(u2_cx_at(4, rec_u->roc))); u2_noun sam = u2nc(u2k(rec_u->now), hap); - return u2_cn_mung(fun, sam); } diff --git a/v/temp.c b/v/temp.c new file mode 100644 index 0000000000..a13ee153d5 --- /dev/null +++ b/v/temp.c @@ -0,0 +1,93 @@ +/* v/temp.c +** +** This file is in the public domain. +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "all.h" +#include "f/coal.h" +#include "v/vere.h" + +/* u2_temp(): initialize time timer. +*/ +void +u2_temp_io_init(void) +{ + u2_temp* teh_u = &u2_Host.teh_u; + + uv_timer_init(u2L, &teh_u->tim_u); + teh_u->alm = u2_no; +} + +/* u2_temp_io_exit(): terminate timer. +*/ +void +u2_temp_io_exit(void) +{ +} + +/* _temp_time_cb(): timer callback. +*/ +static void +_temp_time_cb(uv_timer_t* tim_u) +{ + u2_temp* teh_u = &u2_Host.teh_u; + if(teh_u->run_w < 1024) { + teh_u->run_w++; + } + + u2_lo_open(); + { + u2_reck_plan + (u2A, + u2nt(u2_blip, c3__temp, u2_nul), + u2nc(c3__wake, u2_nul)); + } + u2_lo_shut(u2_no); +} + +/* u2_temp_io_poll(): update temp IO state. +*/ +void +u2_temp_io_poll(void) +{ + u2_temp* teh_u = &u2_Host.teh_u; + u2_noun wen = u2_reck_keep(u2A, u2nt(u2_blip, c3__temp, u2_nul)); + + if ( (u2_nul != wen) && + (u2_yes == u2du(wen)) && + (u2_yes == u2ud(u2t(wen))) ) + { + c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); + + gap_d += teh_u->run_w; + + if ( u2_yes == teh_u->alm ) { + uv_timer_stop(&teh_u->tim_u); + } + else teh_u->alm = u2_yes; + + uv_timer_start(&teh_u->tim_u, _temp_time_cb, gap_d, 0); + } + else { + if ( u2_yes == teh_u->alm ) { + uv_timer_stop(&teh_u->tim_u); + } + teh_u->alm = u2_no; + } + u2z(wen); +} From 1cd74683f0118bd4678811efa57367c9d3c45d91 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 16 Oct 2014 22:54:01 +0000 Subject: [PATCH 2/2] removed clay timer from unix.c --- include/v/vere.h | 6 ++---- v/unix.c | 41 ----------------------------------------- 2 files changed, 2 insertions(+), 45 deletions(-) diff --git a/include/v/vere.h b/include/v/vere.h index 70a8b9679f..c122306314 100644 --- a/include/v/vere.h +++ b/include/v/vere.h @@ -349,9 +349,7 @@ /* u2_unix: clay support system, also */ typedef struct _u2_unix { - uv_timer_t tim_u; // clay timer uv_check_t syn_u; // fs sync check - u2_bean alm; // alarm u2_uhot* hot_u; // host state u2_usig* sig_u; // signal list #ifdef SYNCLOG @@ -368,7 +366,7 @@ /* u2_batz: just a timer for now */ typedef struct _u2_batz { - uv_timer_t tim_u; // clay timer + uv_timer_t tim_u; // batz timer c3_w run_w; // run of consecutive alarms u2_bean alm; // alarm } u2_batz; @@ -376,7 +374,7 @@ /* u2_temp: just a timer for ever */ typedef struct _u2_temp { - uv_timer_t tim_u; // clay timer + uv_timer_t tim_u; // temp timer c3_w run_w; // run of consecutive alarms u2_bean alm; // alarm } u2_temp; diff --git a/v/unix.c b/v/unix.c index 3d696cd8c3..dd46fc5339 100644 --- a/v/unix.c +++ b/v/unix.c @@ -1405,21 +1405,6 @@ _unix_ef_sync(uv_check_t* han_u) u2_lo_shut(u2_yes); } -/* _unix_time_cb(): timer callback. -*/ -static void -_unix_time_cb(uv_timer_t* tim_u) -{ - u2_lo_open(); - { - u2_reck_plan - (u2A, - u2nt(u2_blip, c3__clay, u2_nul), - u2nc(c3__wake, u2_nul)); - } - u2_lo_shut(u2_no); -} - /* _unix_sign_cb: signal callback. */ static void @@ -1475,9 +1460,6 @@ u2_unix_io_init(void) { u2_unix* unx_u = &u2_Host.unx_u; - uv_timer_init(u2L, &unx_u->tim_u); - unx_u->alm = u2_no; - { u2_usig* sig_u; @@ -1552,27 +1534,4 @@ u2_unix_io_exit(void) void u2_unix_io_poll(void) { - u2_unix* unx_u = &u2_Host.unx_u; - u2_noun wen = u2_reck_keep(u2A, u2nt(u2_blip, c3__clay, u2_nul)); - - if ( (u2_nul != wen) && - (u2_yes == u2du(wen)) && - (u2_yes == u2ud(u2t(wen))) ) - { - c3_d gap_d = u2_time_gap_ms(u2k(u2A->now), u2k(u2t(wen))); - - if ( u2_yes == unx_u->alm ) { - uv_timer_stop(&unx_u->tim_u); - } - else unx_u->alm = u2_yes; - - uv_timer_start(&unx_u->tim_u, _unix_time_cb, gap_d, 0); - } - else { - if ( u2_yes == unx_u->alm ) { - uv_timer_stop(&unx_u->tim_u); - } - unx_u->alm = u2_no; - } - u2z(wen); }