summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorJosh Watson <josh@joshwatson.com>2021-03-06 15:41:06 -0800
committerKyle Martin <krm504@nyu.edu>2021-03-15 13:35:44 -0400
commitf401a352f4930bc8c98ee63679fa111493018c4e (patch)
tree4c354acaf48ea9d8167096fe03d96c05b25868e1 /rust/src
parent023af80bad02bd451c062e3fcb97e239426bcc49 (diff)
Implement BackgroundTask::running_tasks()
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/backgroundtask.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/rust/src/backgroundtask.rs b/rust/src/backgroundtask.rs
index 985b8a83..363b91a8 100644
--- a/rust/src/backgroundtask.rs
+++ b/rust/src/backgroundtask.rs
@@ -85,6 +85,15 @@ impl BackgroundTask {
)
}
}
+
+ pub fn running_tasks() -> Array<BackgroundTask> {
+ unsafe {
+ let mut count = 0;
+ let handles = BNGetRunningBackgroundTasks(&mut count);
+
+ Array::new(handles, count, ())
+ }
+ }
}
unsafe impl RefCountable for BackgroundTask {
@@ -99,6 +108,23 @@ unsafe impl RefCountable for BackgroundTask {
}
}
+unsafe impl CoreOwnedArrayProvider for BackgroundTask {
+ type Raw = *mut BNBackgroundTask;
+ type Context = ();
+
+ unsafe fn free(raw: *mut *mut BNBackgroundTask, count: usize, _context: &()) {
+ BNFreeBackgroundTaskList(raw, count);
+ }
+}
+
+unsafe impl<'a> CoreOwnedArrayWrapper<'a> for BackgroundTask {
+ type Wrapped = Guard<'a, BackgroundTask>;
+
+ unsafe fn wrap_raw(raw: &'a *mut BNBackgroundTask, context: &'a ()) -> Guard<'a, BackgroundTask> {
+ Guard::new(BackgroundTask::from_raw(*raw), context)
+ }
+}
+
impl AsRef<BackgroundTask> for BackgroundTask {
fn as_ref(&self) -> &Self {
self