@@ -23,21 +23,21 @@ interface cache {
23
23
// of the `get` method, the outer `option` returns `none` when the pollable
24
24
// is not yet ready and the inner `option` returns `none` when the
25
25
// requested key wasn't present.
26
- type future-get-result = u32 ;
27
- drop- future-get-result: func (f : future-get- result) ;
28
- future-get-result-get : func (f : future-get-result ) -> option < result < option < incoming-value >, error >> ;
29
- listen-to-future-get-result : func ( f : future-get-result ) -> pollable ;
26
+ resource future-get-result {
27
+ future-get-result-get : func () -> option < result < option < incoming-value >, error >> ;
28
+ listen-to- future-get-result : func () -> pollable ;
29
+ }
30
30
31
31
// The `exists` operation returns whether a value was previously `set` for
32
32
// the given key within the TTL.
33
33
exists : func (k : key ) -> future-exists-result ;
34
34
35
35
// This block defines a special resource type used by `exists` to emulate
36
36
// `future<result<bool,error>>`.
37
- type future-exists-result = u32 ;
38
- drop- future-exists-result: func (f : future-exists- result) ;
39
- future-exists-result-get : func (f : future-exists-result ) -> option < result < bool , error >> ;
40
- listen-to-future-exists-result : func ( f : future-exists-result ) -> pollable ;
37
+ resource future-exists-result {
38
+ future-exists-result-get : func () -> option < result < bool , error >> ;
39
+ listen-to- future-exists-result : func () -> pollable ;
40
+ }
41
41
42
42
// The `set` operation sets the given value for the given key for the given
43
43
// time-to-live (TTL) duration, if supplied, specified in milliseconds. If
@@ -46,14 +46,14 @@ interface cache {
46
46
// value is updated in-place. In the common case of computing and caching a
47
47
// value if the given key is not already in the cache, consider using
48
48
// `get-or-set` (below) intead of separate `get` and `set` operations.
49
- set : func (k : key , v : outgoing-value , TTL-ms : option <u32 >) -> future-result ;
49
+ set : func (k : key , v : borrow < outgoing-value > , TTL-ms : option <u32 >) -> future-result ;
50
50
51
51
// This block defines a special resource type used by `set` and `delete` to
52
52
// emulate `future<result<_,error>>`.
53
- type future-result = u32 ;
54
- drop- future-result: func (f : future- result) ;
55
- future-result-get : func (f : future-result ) -> option < result < _ , error >> ;
56
- listen-to-future-result : func ( f : future-result ) -> pollable ;
53
+ resource future-result {
54
+ future-result-get : func () -> option < result < _ , error >> ;
55
+ listen-to- future-result : func () -> pollable ;
56
+ }
57
57
58
58
// The `get-or-set` operation asynchronously returns one of two cases
59
59
// enumerated by `get-or-set-entry`: in the `occupied` case, the given key
@@ -73,10 +73,10 @@ interface cache {
73
73
74
74
// This block defines a special resource type used by `get-or-set` to
75
75
// emulate `future<result<get-or-set-entry,error>>`.
76
- type future-get-or-set-result = u32 ;
77
- drop- future-get-or-set-result: func (f : future- get-or-set-result ) ;
78
- future-get-or-set-result-get : func (f : future-get-or-set-result ) -> option < result < get-or-set-entry , error >> ;
79
- listen-to-future-get-or-set-result : func ( f : future-get-or-set-result ) -> pollable ;
76
+ resource future-get-or-set-result {
77
+ future-get-or-set-result-get : func () -> option < result < get-or-set-entry , error >> ;
78
+ listen-to- future-get-or-set-result : func () -> pollable ;
79
+ }
80
80
81
81
// The following block defines the `vacancy` resource type. (When resource
82
82
// types are added, the `u32` type aliases can be replaced by proper
@@ -85,14 +85,14 @@ interface cache {
85
85
// indicate an error that prevents calling `fill`. An implementation MAY
86
86
// have a timeout that drops a vacancy that hasn't been filled in order
87
87
// to unblock other waiting `get-or-set` callers.
88
- type vacancy = u32 ;
89
- drop- vacancy: func (v : vacancy ) ;
90
- vacancy-fill : func ( v : vacancy , TTL-ms : option < u32 >) -> outgoing-value ;
88
+ resource vacancy {
89
+ vacancy-fill : func (TTL-ms : option < u32 >) -> outgoing-value ;
90
+ }
91
91
92
92
// The `delete` operation removes any value with the given key from the
93
93
// cache. Like all cache operations, `delete` is weakly ordered and thus
94
94
// concurrent `get` calls may still see deleted keys for a period of time.
95
95
// Additionally, due to weak ordering, concurrent `set` calls for the same
96
96
// key may or may not get deleted.
97
97
delete : func (k : key ) -> future-result ;
98
- }
98
+ }
0 commit comments