Version: dev

take

Stable function · Prefetch and windows

Tier: stable · Kind: function · Topic: Prefetch and windows

PythonJuliaRust
not exportedtake!not exported

Python

Python does not export this function.

Julia

take!(m::FileWatching.FolderMonitor)
take!(g::PrefetchGroup, k::Integer)
take!(c::Channel)
take!(io::Base.GenericIOBuffer)
take!(io::IOBuffer)
take!(s::IOStream)
take!(c::Channel)

Removes and returns a value from a Channel in order. Blocks until data is available. For unbuffered channels, blocks until a put! is performed by a different task.

Examples

Buffered channel

julia> c = Channel(1);

julia> put!(c, 1);

julia> take!(c)
1

Unbuffered channel

julia> c = Channel(0);

julia> task = Task(() -> put!(c, 1));

julia> schedule(task);

julia> take!(c)
1

take!(b::IOBuffer)

Obtain the contents of an IOBuffer as an array. Afterwards, the IOBuffer is reset to its initial state.

Examples

julia> io = IOBuffer();

julia> write(io, "JuliaLang is a GitHub organization.", " It has many members.")
56

julia> String(take!(io))
"JuliaLang is a GitHub organization. It has many members."

take!(g::PrefetchGroup, k::Integer) -> EpochSample

Block until epoch k is decoded and return it (spec/prefetch.md §3.3–3.4). k must be the next entry of the order declared by [start!]; anything else is an error naming the epoch expected, and consumes nothing. Taking after the order is exhausted, before any start!, after [cancel!], or after a take! raised a stored error is an error too: call start! again to re-seek.

A decode (or transform) error is raised by the take! of the slot it belongs to and never earlier — if several members fail, the first by key order — exactly as refresh would raise it (no wrapper).

Source

Rust

Rust does not export this function.