Skip to content

Commit e50706a

Browse files
authored
Merge pull request #907 from wedsonaf/rename-to-arc
rust: rename `Ref` to `Arc`
2 parents 5423795 + 0e27b8a commit e50706a

23 files changed

+430
-430
lines changed

drivers/android/allocation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use core::mem::{replace, size_of, MaybeUninit};
44
use kernel::{
5-
bindings, linked_list::List, pages::Pages, prelude::*, sync::Ref, user_ptr::UserSlicePtrReader,
5+
bindings, linked_list::List, pages::Pages, prelude::*, sync::Arc, user_ptr::UserSlicePtrReader,
66
};
77

88
use crate::{
@@ -17,7 +17,7 @@ pub(crate) struct Allocation<'a> {
1717
pub(crate) offset: usize,
1818
size: usize,
1919
pub(crate) ptr: usize,
20-
pages: Ref<[Pages<0>]>,
20+
pages: Arc<[Pages<0>]>,
2121
pub(crate) process: &'a Process,
2222
allocation_info: Option<AllocationInfo>,
2323
free_on_drop: bool,
@@ -30,7 +30,7 @@ impl<'a> Allocation<'a> {
3030
offset: usize,
3131
size: usize,
3232
ptr: usize,
33-
pages: Ref<[Pages<0>]>,
33+
pages: Arc<[Pages<0>]>,
3434
) -> Self {
3535
Self {
3636
process,

drivers/android/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use kernel::{
44
bindings,
55
prelude::*,
66
security,
7-
sync::{Mutex, Ref, UniqueRef},
7+
sync::{Arc, Mutex, UniqueArc},
88
};
99

1010
use crate::{
@@ -26,8 +26,8 @@ unsafe impl Send for Context {}
2626
unsafe impl Sync for Context {}
2727

2828
impl Context {
29-
pub(crate) fn new() -> Result<Ref<Self>> {
30-
let mut ctx = Pin::from(UniqueRef::try_new(Self {
29+
pub(crate) fn new() -> Result<Arc<Self>> {
30+
let mut ctx = Pin::from(UniqueArc::try_new(Self {
3131
// SAFETY: Init is called below.
3232
manager: unsafe {
3333
Mutex::new(Manager {

drivers/android/node.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use kernel::{
55
io_buffer::IoBufferWriter,
66
linked_list::{GetLinks, Links, List},
77
prelude::*,
8-
sync::{Guard, LockedBy, Mutex, Ref, SpinLock},
8+
sync::{Arc, Guard, LockedBy, Mutex, SpinLock},
99
user_ptr::UserSlicePtrWriter,
1010
};
1111

@@ -40,7 +40,7 @@ impl CountState {
4040
struct NodeInner {
4141
strong: CountState,
4242
weak: CountState,
43-
death_list: List<Ref<NodeDeath>>,
43+
death_list: List<Arc<NodeDeath>>,
4444
}
4545

4646
struct NodeDeathInner {
@@ -55,8 +55,8 @@ struct NodeDeathInner {
5555
}
5656

5757
pub(crate) struct NodeDeath {
58-
node: Ref<Node>,
59-
process: Ref<Process>,
58+
node: Arc<Node>,
59+
process: Arc<Process>,
6060
// TODO: Make this private.
6161
pub(crate) cookie: usize,
6262
work_links: Links<dyn DeliverToRead>,
@@ -72,7 +72,7 @@ impl NodeDeath {
7272
/// # Safety
7373
///
7474
/// The caller must call `NodeDeath::init` before using the notification object.
75-
pub(crate) unsafe fn new(node: Ref<Node>, process: Ref<Process>, cookie: usize) -> Self {
75+
pub(crate) unsafe fn new(node: Arc<Node>, process: Arc<Process>, cookie: usize) -> Self {
7676
Self {
7777
node,
7878
process,
@@ -102,7 +102,7 @@ impl NodeDeath {
102102
/// once.
103103
///
104104
/// Returns whether it needs to be queued.
105-
pub(crate) fn set_cleared(self: &Ref<Self>, abort: bool) -> bool {
105+
pub(crate) fn set_cleared(self: &Arc<Self>, abort: bool) -> bool {
106106
let (needs_removal, needs_queueing) = {
107107
// Update state and determine if we need to queue a work item. We only need to do it
108108
// when the node is not dead or if the user already completed the death notification.
@@ -127,7 +127,7 @@ impl NodeDeath {
127127
/// Sets the 'notification done' flag to `true`.
128128
///
129129
/// Returns whether it needs to be queued.
130-
pub(crate) fn set_notification_done(self: Ref<Self>, thread: &Thread) {
130+
pub(crate) fn set_notification_done(self: Arc<Self>, thread: &Thread) {
131131
let needs_queueing = {
132132
let mut inner = self.inner.lock();
133133
inner.notification_done = true;
@@ -140,7 +140,7 @@ impl NodeDeath {
140140
}
141141

142142
/// Sets the 'dead' flag to `true` and queues work item if needed.
143-
pub(crate) fn set_dead(self: Ref<Self>) {
143+
pub(crate) fn set_dead(self: Arc<Self>) {
144144
let needs_queueing = {
145145
let mut inner = self.inner.lock();
146146
if inner.cleared {
@@ -168,7 +168,7 @@ impl GetLinks for NodeDeath {
168168
}
169169

170170
impl DeliverToRead for NodeDeath {
171-
fn do_work(self: Ref<Self>, _thread: &Thread, writer: &mut UserSlicePtrWriter) -> Result<bool> {
171+
fn do_work(self: Arc<Self>, _thread: &Thread, writer: &mut UserSlicePtrWriter) -> Result<bool> {
172172
let done = {
173173
let inner = self.inner.lock();
174174
if inner.aborted {
@@ -211,13 +211,13 @@ pub(crate) struct Node {
211211
ptr: usize,
212212
cookie: usize,
213213
pub(crate) flags: u32,
214-
pub(crate) owner: Ref<Process>,
214+
pub(crate) owner: Arc<Process>,
215215
inner: LockedBy<NodeInner, Mutex<ProcessInner>>,
216216
links: Links<dyn DeliverToRead>,
217217
}
218218

219219
impl Node {
220-
pub(crate) fn new(ptr: usize, cookie: usize, flags: u32, owner: Ref<Process>) -> Self {
220+
pub(crate) fn new(ptr: usize, cookie: usize, flags: u32, owner: Arc<Process>) -> Self {
221221
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
222222
let inner = LockedBy::new(
223223
&owner.inner,
@@ -245,13 +245,13 @@ impl Node {
245245
pub(crate) fn next_death(
246246
&self,
247247
guard: &mut Guard<'_, Mutex<ProcessInner>>,
248-
) -> Option<Ref<NodeDeath>> {
248+
) -> Option<Arc<NodeDeath>> {
249249
self.inner.access_mut(guard).death_list.pop_front()
250250
}
251251

252252
pub(crate) fn add_death(
253253
&self,
254-
death: Ref<NodeDeath>,
254+
death: Arc<NodeDeath>,
255255
guard: &mut Guard<'_, Mutex<ProcessInner>>,
256256
) {
257257
self.inner.access_mut(guard).death_list.push_back(death);
@@ -296,7 +296,7 @@ impl Node {
296296
}
297297
}
298298

299-
pub(crate) fn update_refcount(self: &Ref<Self>, inc: bool, strong: bool) {
299+
pub(crate) fn update_refcount(self: &Arc<Self>, inc: bool, strong: bool) {
300300
self.owner
301301
.inner
302302
.lock()
@@ -344,7 +344,7 @@ impl Node {
344344
}
345345

346346
impl DeliverToRead for Node {
347-
fn do_work(self: Ref<Self>, _thread: &Thread, writer: &mut UserSlicePtrWriter) -> Result<bool> {
347+
fn do_work(self: Arc<Self>, _thread: &Thread, writer: &mut UserSlicePtrWriter) -> Result<bool> {
348348
let mut owner_inner = self.owner.inner.lock();
349349
let inner = self.inner.access_mut(&mut owner_inner);
350350
let strong = inner.strong.count > 0;
@@ -396,13 +396,13 @@ impl DeliverToRead for Node {
396396
}
397397

398398
pub(crate) struct NodeRef {
399-
pub(crate) node: Ref<Node>,
399+
pub(crate) node: Arc<Node>,
400400
strong_count: usize,
401401
weak_count: usize,
402402
}
403403

404404
impl NodeRef {
405-
pub(crate) fn new(node: Ref<Node>, strong_count: usize, weak_count: usize) -> Self {
405+
pub(crate) fn new(node: Arc<Node>, strong_count: usize, weak_count: usize) -> Self {
406406
Self {
407407
node,
408408
strong_count,

0 commit comments

Comments
 (0)