Skip to content

Commit f2e9027

Browse files
lredlinzeldovich
authored andcommittedJan 26, 2025·
Remove unused slice capacity and add new function that returns pointer for queue tutorial.
This will make proofs easier by proving a function that directly returns a pointer which will have a spec and proof that do the work of initializing all of the ghost state. Also the capacity here is unused. It seems like the idea was to make the slice fixed length but in reality the capacity is only used in Go slices to determine when to upsize and in this case since the initial size is queue_size it actually has no effect. This will be followed by updates to goose code and proofs.
1 parent 05dfe0e commit f2e9027

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎tutorial/queue/queue.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@ type Queue struct {
1515
func NewQueue(queue_size uint64) Queue {
1616
lock := new(sync.Mutex)
1717
return Queue{
18-
queue: make([]uint64, queue_size, queue_size),
18+
queue: make([]uint64, queue_size),
19+
cond: sync.NewCond(lock),
20+
lock: lock,
21+
first: 0,
22+
count: 0,
23+
}
24+
}
25+
26+
func NewQueueRef(queue_size uint64) *Queue {
27+
lock := new(sync.Mutex)
28+
return &Queue{
29+
queue: make([]uint64, queue_size),
1930
cond: sync.NewCond(lock),
2031
lock: lock,
2132
first: 0,

0 commit comments

Comments
 (0)
Please sign in to comment.