|
13 | 13 |
|
14 | 14 | ## types ##
|
15 | 15 | abstract type IOServer end
|
| 16 | +""" |
| 17 | + LibuvServer |
| 18 | +
|
| 19 | +An abstract type for IOServers handled by libuv. |
| 20 | +
|
| 21 | +If `server isa LibuvServer`, it must obey the following interface: |
| 22 | +
|
| 23 | +- `server.handle` must be a `Ptr{Cvoid}` |
| 24 | +- `server.status` must be an `Int` |
| 25 | +- `server.cond` must be a `GenericCondition` |
| 26 | +""" |
16 | 27 | abstract type LibuvServer <: IOServer end
|
| 28 | + |
| 29 | +function getproperty(server::LibuvServer, name::Symbol) |
| 30 | + if name === :handle |
| 31 | + return getfield(server, :handle)::Ptr{Cvoid} |
| 32 | + elseif name === :status |
| 33 | + return getfield(server, :status)::Int |
| 34 | + elseif name === :cond |
| 35 | + return getfield(server, :cond)::GenericCondition |
| 36 | + else |
| 37 | + return getfield(server, name) |
| 38 | + end |
| 39 | +end |
| 40 | + |
| 41 | +""" |
| 42 | + LibuvStream |
| 43 | +
|
| 44 | +An abstract type for IO streams handled by libuv. |
| 45 | +
|
| 46 | +If`stream isa LibuvStream`, it must obey the following interface: |
| 47 | +
|
| 48 | +- `stream.handle`, if present, must be a `Ptr{Cvoid}` |
| 49 | +- `stream.status`, if present, must be an `Int` |
| 50 | +- `stream.buffer`, if present, must be an `IOBuffer` |
| 51 | +- `stream.sendbuf`, if present, must be a `Union{Nothing,IOBuffer}` |
| 52 | +- `stream.cond`, if present, must be a `GenericCondition` |
| 53 | +- `stream.lock`, if present, must be an `AbstractLock` |
| 54 | +- `stream.throttle`, if present, must be an `Int` |
| 55 | +""" |
17 | 56 | abstract type LibuvStream <: IO end
|
18 | 57 |
|
| 58 | +function getproperty(stream::LibuvStream, name::Symbol) |
| 59 | + if name === :handle |
| 60 | + return getfield(stream, :handle)::Ptr{Cvoid} |
| 61 | + elseif name === :status |
| 62 | + return getfield(stream, :status)::Int |
| 63 | + elseif name === :buffer |
| 64 | + return getfield(stream, :buffer)::IOBuffer |
| 65 | + elseif name === :sendbuf |
| 66 | + return getfield(stream, :sendbuf)::Union{Nothing,IOBuffer} |
| 67 | + elseif name === :cond |
| 68 | + return getfield(stream, :cond)::GenericCondition |
| 69 | + elseif name === :lock |
| 70 | + return getfield(stream, :lock)::AbstractLock |
| 71 | + elseif name === :throttle |
| 72 | + return getfield(stream, :throttle)::Int |
| 73 | + else |
| 74 | + return getfield(stream, name) |
| 75 | + end |
| 76 | +end |
19 | 77 |
|
20 | 78 | # IO
|
21 | 79 | # +- GenericIOBuffer{T<:AbstractArray{UInt8,1}} (not exported)
|
|
0 commit comments