Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FDWatcher instead of _FDWatcher #215

Merged
merged 1 commit into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ZMQ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ZMQ
using ZeroMQ_jll

using Base.Libc: EAGAIN
using FileWatching: UV_READABLE, uv_pollcb, _FDWatcher
using FileWatching: UV_READABLE, uv_pollcb, FDWatcher
import Sockets
using Sockets: connect, bind, send, recv
import Base.GC: @preserve
Expand Down
4 changes: 2 additions & 2 deletions src/comm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function _send(socket::Socket, zmsg, more::Bool=false)
wait(socket)
end
else
notify_is_expensive = !isempty(getfield(socket,:pollfd).notify.waitq)
notify_is_expensive = !isempty(getfield(socket,:pollfd).watcher.notify.waitq)
if notify_is_expensive
socket.events != 0 && notify(socket)
end
Expand Down Expand Up @@ -80,7 +80,7 @@ function _recv!(socket::Socket, zmsg)
wait(socket)
end
else
notify_is_expensive = !isempty(getfield(socket,:pollfd).notify.waitq)
notify_is_expensive = !isempty(getfield(socket,:pollfd).watcher.notify.waitq)
if notify_is_expensive
socket.events != 0 && notify(socket)
end
Expand Down
10 changes: 5 additions & 5 deletions src/socket.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Do-block constructor.
"""
mutable struct Socket
data::Ptr{Cvoid}
pollfd::_FDWatcher
pollfd::FDWatcher

"""
Socket(ctx::Context, typ::Integer)
Expand All @@ -32,7 +32,7 @@ mutable struct Socket
throw(StateError(jl_zmq_error_str()))
end
socket = new(p)
setfield!(socket, :pollfd, _FDWatcher(fd(socket), #=readable=#true, #=writable=#false))
setfield!(socket, :pollfd, FDWatcher(fd(socket), #=readable=#true, #=writable=#false))
finalizer(close, socket)
push!(getfield(ctx, :sockets), WeakRef(socket))
return socket
Expand Down Expand Up @@ -72,7 +72,7 @@ Base.isopen(socket::Socket) = getfield(socket, :data) != C_NULL
"""
function Base.close(socket::Socket)
if isopen(socket)
close(getfield(socket, :pollfd), #=readable=#true, #=writable=#false)
close(getfield(socket, :pollfd))
rc = ccall((:zmq_close, libzmq), Cint, (Ptr{Cvoid},), socket)
setfield!(socket, :data, C_NULL)
if rc != 0
Expand All @@ -90,8 +90,8 @@ if Sys.iswindows()
Base.fd(socket::Socket) = WindowsRawSocket(convert(Ptr{Cvoid}, socket.fd))
end

Base.wait(socket::Socket) = wait(getfield(socket, :pollfd), readable=true, writable=false)
Base.notify(socket::Socket) = @preserve socket uv_pollcb(getfield(socket, :pollfd).handle, Int32(0), Int32(UV_READABLE))
Base.wait(socket::Socket) = wait(getfield(socket, :pollfd))
Base.notify(socket::Socket) = @preserve socket uv_pollcb(getfield(socket, :pollfd).watcher.handle, Int32(0), Int32(UV_READABLE))

"""
Sockets.bind(socket::Socket, endpoint::AbstractString)
Expand Down
Loading