mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 00:13:12 +03:00
u3: backports u3v_soft_peek()
This commit is contained in:
parent
d0dc3e7710
commit
4d57c3c9a0
@ -77,6 +77,11 @@
|
||||
u3_noun
|
||||
u3v_peek(u3_noun hap);
|
||||
|
||||
/* u3v_soft_peek(): softly query the reck namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3v_soft_peek(c3_w mil_w, u3_noun sam);
|
||||
|
||||
/* u3v_poke(): insert and apply an input ovum (protected).
|
||||
*/
|
||||
u3_noun
|
||||
|
@ -216,6 +216,32 @@ u3v_peek(u3_noun sam)
|
||||
return u3n_slam_on(fun, sam);
|
||||
}
|
||||
|
||||
/* u3v_soft_peek(): softly query the reck namespace.
|
||||
*/
|
||||
u3_noun
|
||||
u3v_soft_peek(c3_w mil_w, u3_noun sam)
|
||||
{
|
||||
u3_noun gon = u3m_soft(mil_w, u3v_peek, sam);
|
||||
u3_noun tag, dat;
|
||||
u3x_cell(gon, &tag, &dat);
|
||||
|
||||
// read failed, produce trace
|
||||
//
|
||||
// NB, reads *should not* fail deterministically
|
||||
//
|
||||
if ( u3_blip != tag ) {
|
||||
return u3nc(c3n, gon);
|
||||
}
|
||||
|
||||
// read succeeded, produce result
|
||||
//
|
||||
{
|
||||
u3_noun pro = u3nc(c3y, u3k(dat));
|
||||
u3z(gon);
|
||||
return pro;
|
||||
}
|
||||
}
|
||||
|
||||
/* u3v_poke(): insert and apply an input ovum (protected).
|
||||
*/
|
||||
u3_noun
|
||||
|
Loading…
Reference in New Issue
Block a user