Skip to content

Commit

Permalink
Missed async-io in a few places...
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 24, 2024
1 parent 57b62f9 commit 3937b25
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 40 deletions.
3 changes: 1 addition & 2 deletions examples/fan-out/pipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.
# Copyright, 2020, by Olle Jonsson.
# Copyright, 2020-2024, by Samuel Williams.

require 'async/container'

Expand Down
2 changes: 1 addition & 1 deletion examples/grace/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Copyright, 2024, by Samuel Williams.

require '../../lib/async/container'
require 'async/io/host_endpoint'
require 'io/endpoint/host_endpoint'

Console.logger.debug!

Expand Down
1 change: 0 additions & 1 deletion examples/http/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

require 'async/http/endpoint'
require 'async/http/server'
require 'async/io/shared_endpoint'

container = Async::Container::Forked.new

Expand Down
2 changes: 1 addition & 1 deletion examples/queue/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.
# Copyright, 2020-2024, by Samuel Williams.

require 'async'
require 'async/container'
Expand Down
14 changes: 3 additions & 11 deletions lib/async/container/notify/server.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.
# Copyright, 2020-2024, by Samuel Williams.
# Copyright, 2020, by Olle Jonsson.

require 'async/io'
require 'async/io/unix_endpoint'
require 'kernel/sync'

require 'tmpdir'
Expand Down Expand Up @@ -62,19 +60,13 @@ def bind
class Context
def initialize(path)
@path = path
@endpoint = IO::Endpoint.unix(@path, ::Socket::SOCK_DGRAM)

Sync do
@bound = @endpoint.bind
end
@bound = Addrinfo.unix(@path, ::Socket::SOCK_DGRAM).bind

@state = {}
end

def close
Sync do
@bound.close
end
@bound.close

File.unlink(@path)
end
Expand Down
9 changes: 4 additions & 5 deletions lib/async/container/notify/socket.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2022, by Samuel Williams.
# Copyright, 2020-2024, by Samuel Williams.

require_relative 'client'

require 'async/io'
require 'async/io/unix_endpoint'
require 'io/endpoint/unix_endpoint'
require 'kernel/sync'

module Async
Expand All @@ -32,7 +31,7 @@ def self.open!(environment = ENV)
# @parameter path [String] The path to the UNIX socket used for sending messages to the process manager.
def initialize(path)
@path = path
@endpoint = IO::Endpoint.unix(path, ::Socket::SOCK_DGRAM)
@endpoint = ::IO::Endpoint.unix(path, ::Socket::SOCK_DGRAM)
end

# Dump a message in the format requied by `sd_notify`.
Expand Down Expand Up @@ -65,7 +64,7 @@ def send(**message)

Sync do
@endpoint.connect do |peer|
peer.send(data)
peer.sendmsg(data)
end
end
end
Expand Down
19 changes: 0 additions & 19 deletions test.rb

This file was deleted.

0 comments on commit 3937b25

Please sign in to comment.