@@ -5,7 +5,7 @@ use kernel::{
5
5
io_buffer:: IoBufferWriter ,
6
6
linked_list:: { GetLinks , Links , List } ,
7
7
prelude:: * ,
8
- sync:: { Guard , LockedBy , Mutex , Ref , SpinLock } ,
8
+ sync:: { Arc , Guard , LockedBy , Mutex , SpinLock } ,
9
9
user_ptr:: UserSlicePtrWriter ,
10
10
} ;
11
11
@@ -40,7 +40,7 @@ impl CountState {
40
40
struct NodeInner {
41
41
strong : CountState ,
42
42
weak : CountState ,
43
- death_list : List < Ref < NodeDeath > > ,
43
+ death_list : List < Arc < NodeDeath > > ,
44
44
}
45
45
46
46
struct NodeDeathInner {
@@ -55,8 +55,8 @@ struct NodeDeathInner {
55
55
}
56
56
57
57
pub ( crate ) struct NodeDeath {
58
- node : Ref < Node > ,
59
- process : Ref < Process > ,
58
+ node : Arc < Node > ,
59
+ process : Arc < Process > ,
60
60
// TODO: Make this private.
61
61
pub ( crate ) cookie : usize ,
62
62
work_links : Links < dyn DeliverToRead > ,
@@ -72,7 +72,7 @@ impl NodeDeath {
72
72
/// # Safety
73
73
///
74
74
/// 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 {
76
76
Self {
77
77
node,
78
78
process,
@@ -102,7 +102,7 @@ impl NodeDeath {
102
102
/// once.
103
103
///
104
104
/// 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 {
106
106
let ( needs_removal, needs_queueing) = {
107
107
// Update state and determine if we need to queue a work item. We only need to do it
108
108
// when the node is not dead or if the user already completed the death notification.
@@ -127,7 +127,7 @@ impl NodeDeath {
127
127
/// Sets the 'notification done' flag to `true`.
128
128
///
129
129
/// 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 ) {
131
131
let needs_queueing = {
132
132
let mut inner = self . inner . lock ( ) ;
133
133
inner. notification_done = true ;
@@ -140,7 +140,7 @@ impl NodeDeath {
140
140
}
141
141
142
142
/// 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 > ) {
144
144
let needs_queueing = {
145
145
let mut inner = self . inner . lock ( ) ;
146
146
if inner. cleared {
@@ -168,7 +168,7 @@ impl GetLinks for NodeDeath {
168
168
}
169
169
170
170
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 > {
172
172
let done = {
173
173
let inner = self . inner . lock ( ) ;
174
174
if inner. aborted {
@@ -211,13 +211,13 @@ pub(crate) struct Node {
211
211
ptr : usize ,
212
212
cookie : usize ,
213
213
pub ( crate ) flags : u32 ,
214
- pub ( crate ) owner : Ref < Process > ,
214
+ pub ( crate ) owner : Arc < Process > ,
215
215
inner : LockedBy < NodeInner , Mutex < ProcessInner > > ,
216
216
links : Links < dyn DeliverToRead > ,
217
217
}
218
218
219
219
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 {
221
221
static NEXT_ID : AtomicU64 = AtomicU64 :: new ( 1 ) ;
222
222
let inner = LockedBy :: new (
223
223
& owner. inner ,
@@ -245,13 +245,13 @@ impl Node {
245
245
pub ( crate ) fn next_death (
246
246
& self ,
247
247
guard : & mut Guard < ' _ , Mutex < ProcessInner > > ,
248
- ) -> Option < Ref < NodeDeath > > {
248
+ ) -> Option < Arc < NodeDeath > > {
249
249
self . inner . access_mut ( guard) . death_list . pop_front ( )
250
250
}
251
251
252
252
pub ( crate ) fn add_death (
253
253
& self ,
254
- death : Ref < NodeDeath > ,
254
+ death : Arc < NodeDeath > ,
255
255
guard : & mut Guard < ' _ , Mutex < ProcessInner > > ,
256
256
) {
257
257
self . inner . access_mut ( guard) . death_list . push_back ( death) ;
@@ -296,7 +296,7 @@ impl Node {
296
296
}
297
297
}
298
298
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 ) {
300
300
self . owner
301
301
. inner
302
302
. lock ( )
@@ -344,7 +344,7 @@ impl Node {
344
344
}
345
345
346
346
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 > {
348
348
let mut owner_inner = self . owner . inner . lock ( ) ;
349
349
let inner = self . inner . access_mut ( & mut owner_inner) ;
350
350
let strong = inner. strong . count > 0 ;
@@ -396,13 +396,13 @@ impl DeliverToRead for Node {
396
396
}
397
397
398
398
pub ( crate ) struct NodeRef {
399
- pub ( crate ) node : Ref < Node > ,
399
+ pub ( crate ) node : Arc < Node > ,
400
400
strong_count : usize ,
401
401
weak_count : usize ,
402
402
}
403
403
404
404
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 {
406
406
Self {
407
407
node,
408
408
strong_count,
0 commit comments