@@ -17,10 +17,26 @@ mutable struct Anonymous <: IO
17
17
end
18
18
19
19
"""
20
- Mmap.Anonymous(name, readonly, create)
20
+ Mmap.Anonymous(name::AbstractString="" , readonly::Bool=false , create::Bool=true )
21
21
22
22
Create an `IO`-like object for creating zeroed-out mmapped-memory that is not tied to a file
23
- for use in `Mmap.mmap`. Used by `SharedArray` for creating shared memory arrays.
23
+ for use in [`Mmap.mmap`](@ref Mmap.mmap). Used by `SharedArray` for creating shared memory arrays.
24
+
25
+ # Examples
26
+ ```jldoctest
27
+ julia> using Mmap
28
+
29
+ julia> anon = Mmap.Anonymous();
30
+
31
+ julia> isreadable(anon)
32
+ true
33
+
34
+ julia> iswritable(anon)
35
+ true
36
+
37
+ julia> isopen(anon)
38
+ true
39
+ ```
24
40
"""
25
41
Anonymous () = Anonymous (" " ,false ,true )
26
42
@@ -239,13 +255,39 @@ mmap(::Type{T}, i::Integer...; shared::Bool=true) where {T<:Array} = mmap(Anonym
239
255
"""
240
256
Mmap.mmap(io, BitArray, [dims, offset])
241
257
242
- Create a `BitArray` whose values are linked to a file, using memory-mapping; it has the same
258
+ Create a [ `BitArray`](@ref) whose values are linked to a file, using memory-mapping; it has the same
243
259
purpose, works in the same way, and has the same arguments, as [`mmap`](@ref Mmap.mmap), but
244
260
the byte representation is different.
245
261
246
- **Example**: `B = Mmap.mmap(s, BitArray, (25,30000))`
262
+ # Examples
263
+ ```jldoctest
264
+ julia> using Mmap
265
+
266
+ julia> io = open("mmap.bin", "w+");
267
+
268
+ julia> B = Mmap.mmap(io, BitArray, (25,30000));
269
+
270
+ julia> B[3, 4000] = true;
247
271
248
- This would create a 25-by-30000 `BitArray`, linked to the file associated with stream `s`.
272
+ julia> Mmap.sync!(B);
273
+
274
+ julia> close(io);
275
+
276
+ julia> io = open("mmap.bin", "r+");
277
+
278
+ julia> C = Mmap.mmap(io, BitArray, (25,30000));
279
+
280
+ julia> C[3, 4000]
281
+ true
282
+
283
+ julia> C[2, 4000]
284
+ false
285
+
286
+ julia> close(io)
287
+
288
+ julia> rm("mmap.bin")
289
+ ```
290
+ This creates a 25-by-30000 `BitArray`, linked to the file associated with stream `io`.
249
291
"""
250
292
function mmap (io:: IOStream , :: Type{<:BitArray} , dims:: NTuple{N,Integer} ,
251
293
offset:: Int64 = position (io); grow:: Bool = true , shared:: Bool = true ) where N
@@ -290,7 +332,7 @@ const MS_SYNC = 4
290
332
Mmap.sync!(array)
291
333
292
334
Forces synchronization between the in-memory version of a memory-mapped `Array` or
293
- `BitArray` and the on-disk version.
335
+ [ `BitArray`](@ref) and the on-disk version.
294
336
"""
295
337
function sync! (m:: Array{T} , flags:: Integer = MS_SYNC) where T
296
338
offset = rem (UInt (pointer (m)), PAGESIZE)
0 commit comments