mirror of
https://github.com/rdmsr/zag.git
synced 2026-10-27 13:58:20 +00:00
ke/smr: expose simpler APIs
This commit is contained in:
@@ -92,6 +92,8 @@ pub const smr = struct {
|
||||
pub const exit = p.smr.exit;
|
||||
pub const enter = p.smr.enter;
|
||||
pub const poll = p.smr.poll;
|
||||
pub const wait = p.smr.wait;
|
||||
pub const synchronize = p.smr.synchronize;
|
||||
|
||||
pub const seq_invalid = p.smr.seq_invalid;
|
||||
|
||||
|
||||
@@ -321,6 +321,16 @@ pub fn exit(dom: *Domain, ipl: ke.Ipl) void {
|
||||
ke.ipl.lower(ipl);
|
||||
}
|
||||
|
||||
/// Wait for a given goal to happen.
|
||||
pub fn wait(dom: *Domain, goal: Sequence) void {
|
||||
poll(dom, goal, true);
|
||||
}
|
||||
|
||||
/// Wait until all readers have left their read sections.
|
||||
pub fn synchronize(dom: *Domain) void {
|
||||
wait(dom, advance(dom));
|
||||
}
|
||||
|
||||
// Called by the scheduler when a thread in an SMR section got preempted.
|
||||
pub fn mark_thread_stalled(td: *ke.Thread) void {
|
||||
var it = td.smr_sections.iterator();
|
||||
|
||||
+2
-2
@@ -801,7 +801,7 @@ pub const Zone = struct {
|
||||
|
||||
if (self.smr) |smr| {
|
||||
// Direct frees must synchronize, the object is instantly reusable.
|
||||
_ = ke.smr.poll(smr, ke.smr.advance(smr), true);
|
||||
_ = ke.smr.synchronize(smr);
|
||||
}
|
||||
|
||||
self.lock.acquire();
|
||||
@@ -1080,7 +1080,7 @@ pub const Zone = struct {
|
||||
ke.smr.deferred_advance_commit(smr, magazine.seq);
|
||||
|
||||
// Wait until we can destroy the magazine.
|
||||
_ = ke.smr.poll(smr, magazine.seq, true);
|
||||
_ = ke.smr.wait(smr, magazine.seq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user