7
7
extern crate std;
8
8
9
9
#[ cfg( feature = "use_spin" ) ]
10
- extern crate spin ;
10
+ extern crate spinning_top ;
11
11
12
12
extern crate alloc;
13
13
14
- use alloc:: alloc:: { AllocRef , AllocErr , Layout } ;
15
- use core:: alloc:: { GlobalAlloc } ;
14
+ use alloc:: alloc:: { AllocErr , AllocRef , Layout } ;
15
+ use core:: alloc:: GlobalAlloc ;
16
16
use core:: mem;
17
17
#[ cfg( feature = "use_spin" ) ]
18
18
use core:: ops:: Deref ;
19
19
use core:: ptr:: NonNull ;
20
20
use hole:: { Hole , HoleList } ;
21
21
#[ cfg( feature = "use_spin" ) ]
22
- use spin :: Mutex ;
22
+ use spinning_top :: Spinlock ;
23
23
24
24
mod hole;
25
25
#[ cfg( test) ]
@@ -140,21 +140,21 @@ unsafe impl AllocRef for Heap {
140
140
}
141
141
142
142
#[ cfg( feature = "use_spin" ) ]
143
- pub struct LockedHeap ( Mutex < Heap > ) ;
143
+ pub struct LockedHeap ( Spinlock < Heap > ) ;
144
144
145
145
#[ cfg( feature = "use_spin" ) ]
146
146
impl LockedHeap {
147
147
/// Creates an empty heap. All allocate calls will return `None`.
148
148
pub const fn empty ( ) -> LockedHeap {
149
- LockedHeap ( Mutex :: new ( Heap :: empty ( ) ) )
149
+ LockedHeap ( Spinlock :: new ( Heap :: empty ( ) ) )
150
150
}
151
151
152
152
/// Creates a new heap with the given `bottom` and `size`. The bottom address must be valid
153
153
/// and the memory in the `[heap_bottom, heap_bottom + heap_size)` range must not be used for
154
154
/// anything else. This function is unsafe because it can cause undefined behavior if the
155
155
/// given address is invalid.
156
156
pub unsafe fn new ( heap_bottom : usize , heap_size : usize ) -> LockedHeap {
157
- LockedHeap ( Mutex :: new ( Heap {
157
+ LockedHeap ( Spinlock :: new ( Heap {
158
158
bottom : heap_bottom,
159
159
size : heap_size,
160
160
holes : HoleList :: new ( heap_bottom, heap_size) ,
@@ -164,9 +164,9 @@ impl LockedHeap {
164
164
165
165
#[ cfg( feature = "use_spin" ) ]
166
166
impl Deref for LockedHeap {
167
- type Target = Mutex < Heap > ;
167
+ type Target = Spinlock < Heap > ;
168
168
169
- fn deref ( & self ) -> & Mutex < Heap > {
169
+ fn deref ( & self ) -> & Spinlock < Heap > {
170
170
& self . 0
171
171
}
172
172
}
0 commit comments