@@ -17,10 +17,26 @@ mutable struct Anonymous <: IO
1717end
1818
1919"""
20- Mmap.Anonymous(name, readonly, create)
20+ Mmap.Anonymous(name::AbstractString="" , readonly::Bool=false , create::Bool=true )
2121
2222Create 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+ ```
2440"""
2541Anonymous () = Anonymous (" " ,false ,true )
2642
@@ -239,13 +255,39 @@ mmap(::Type{T}, i::Integer...; shared::Bool=true) where {T<:Array} = mmap(Anonym
239255"""
240256 Mmap.mmap(io, BitArray, [dims, offset])
241257
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
243259purpose, works in the same way, and has the same arguments, as [`mmap`](@ref Mmap.mmap), but
244260the byte representation is different.
245261
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;
247271
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`.
249291"""
250292function mmap (io:: IOStream , :: Type{<:BitArray} , dims:: NTuple{N,Integer} ,
251293 offset:: Int64 = position (io); grow:: Bool = true , shared:: Bool = true ) where N
@@ -290,7 +332,7 @@ const MS_SYNC = 4
290332 Mmap.sync!(array)
291333
292334Forces 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.
294336"""
295337function sync! (m:: Array{T} , flags:: Integer = MS_SYNC) where T
296338 offset = rem (UInt (pointer (m)), PAGESIZE)
0 commit comments