Skip to content

Commit 5167cbe

Browse files
committed
Add file async_disk, clean up
1 parent 28ba2a3 commit 5167cbe

File tree

3 files changed

+13
-94
lines changed

3 files changed

+13
-94
lines changed

machine/async_disk/async_disk.go

-72
Original file line numberDiff line numberDiff line change
@@ -14,75 +14,3 @@ type Block = disk.Block
1414
const BlockSize uint64 = disk.BlockSize
1515

1616
type Disk = disk.Disk
17-
18-
/*
19-
// Disk provides access to a logical block-based disk
20-
type Disk interface {
21-
// Read reads a disk block by address
22-
//
23-
// Expects a < Size().
24-
Read(a uint64) Block
25-
26-
// ReadTo reads the disk block at a and stores the result in b
27-
//
28-
// Expects a < Size().
29-
ReadTo(a uint64, b Block)
30-
31-
// Write updates a disk block by address
32-
//
33-
// Expects a < Size().
34-
Write(a uint64, v Block)
35-
36-
// Size reports how big the disk is, in blocks
37-
Size() uint64
38-
39-
// Barrier ensures data is persisted.
40-
//
41-
// When it returns, all outstanding writes are guaranteed to be durably on
42-
// disk
43-
Barrier()
44-
45-
// Close releases any resources used by the disk and makes it unusable.
46-
Close()
47-
}
48-
49-
var implicitDisk Disk
50-
51-
// Init sets up the global disk
52-
func Init(d Disk) {
53-
implicitDisk = d
54-
}
55-
56-
// Get returns the previously-initialized global disk
57-
func Get() Disk {
58-
return implicitDisk
59-
}
60-
61-
// Read (see the Disk documentation)
62-
//
63-
// Deprecated: use Get() and the Disk method
64-
func Read(a uint64) Block {
65-
return implicitDisk.Read(a)
66-
}
67-
68-
// Write (see the Disk documentation)
69-
//
70-
// Deprecated: use Get() and the Disk method
71-
func Write(a uint64, v Block) {
72-
implicitDisk.Write(a, v)
73-
}
74-
75-
// Size (see the Disk documentation)
76-
//
77-
// Deprecated: use Get() and the Disk method
78-
func Size() uint64 {
79-
return implicitDisk.Size()
80-
}
81-
82-
// Barrier (see the Disk documentation)
83-
//
84-
// Deprecated: use Get() and the Disk method
85-
func Barrier() {
86-
implicitDisk.Barrier()
87-
}
88-
*/

machine/async_disk/file.go

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package async_disk
2+
3+
import (
4+
"github.com/tchajed/goose/machine/disk"
5+
)
6+
7+
type FileDisk = disk.FileDisk
8+
9+
func NewFileDisk(path string, numBlocks uint64) (FileDisk, error) {
10+
return disk.NewFileDisk(path, numBlocks)
11+
}
12+
13+
var _ Disk = FileDisk{}

machine/async_disk/mem.go

-22
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,3 @@ func NewMemDisk(numBlocks uint64) MemDisk {
1111
}
1212

1313
var _ Disk = MemDisk{}
14-
15-
/*
16-
func (d MemDisk) ReadTo(a uint64, buf Block) {
17-
d.disk.ReadTo(a, buf)
18-
}
19-
20-
func (d MemDisk) Read(a uint64) Block {
21-
return d.disk.Read(a)
22-
}
23-
24-
func (d MemDisk) Write(a uint64, v Block) {
25-
d.disk.Write(a, v)
26-
}
27-
28-
func (d MemDisk) Size() uint64 {
29-
return d.disk.Size()
30-
}
31-
32-
func (d MemDisk) Barrier() { d.disk.Barrier() }
33-
34-
func (d MemDisk) Close() { d.disk.Close () }
35-
*/

0 commit comments

Comments
 (0)