You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -66,3 +66,36 @@ function do_get(sto::Store{T}, get_ev::Get, key::StoreGetKey) where {T}
66
66
end
67
67
true
68
68
end
69
+
70
+
"""
71
+
isready(::Store)
72
+
73
+
Returns `true` if the store is not empty, similarly to the meaning of `isready` for `Base.Channel`.
74
+
75
+
```jldoctest
76
+
julia> sim = Simulation(); store = Store{Symbol}(sim); isready(store)
77
+
false
78
+
79
+
julia> put!(store, :message); isready(store)
80
+
true
81
+
```
82
+
"""
83
+
isready(sto::Store) = sto.load >0
84
+
85
+
"""
86
+
islocked(::Store)
87
+
88
+
Returns `true` if the store is full, similarly to the meaning of `islocked` for `Base.ReentrantLock`.
89
+
90
+
```jldoctest
91
+
julia> sim = Simulation(); store = Store{Symbol}(sim; capacity=1); islocked(store)
92
+
false
93
+
94
+
julia> put!(store, :message); islocked(store)
95
+
true
96
+
```
97
+
"""
98
+
islocked(sto::Store) = sto.load==sto.capacity
99
+
100
+
unlock(::Store) =error("There is no well defined way to \"unlock\" a store. Instead of attempting `unlock` consider using `pop!(::Store)` or use a `Resource` instead of a `Store`.")
101
+
lock(::Store) =error("There is no well defined way to \"lock\" a store. Instead of attempting `lock` consider using `put!(::Store, ...)` or use a `Resource` instead of a `Store`.")
0 commit comments