@@ -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 {
4040struct NodeInner {
4141 strong : CountState ,
4242 weak : CountState ,
43- death_list : List < Ref < NodeDeath > > ,
43+ death_list : List < Arc < NodeDeath > > ,
4444}
4545
4646struct NodeDeathInner {
@@ -55,8 +55,8 @@ struct NodeDeathInner {
5555}
5656
5757pub ( 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
170170impl 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
219219impl 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
346346impl 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
398398pub ( 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
404404impl 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