socketry / async

An awesome asynchronous event-driven reactor for Ruby.
MIT License
2.14k stars 88 forks source link

Use def_delegator instead of alias in Queue #129

Closed zhulik closed 2 years ago

zhulik commented 3 years ago

Description

Replace alias with def_delegator in Queue.

Problem: Async::LimitedQueue#<< does not block when the queue is full.

Explanation: both alias and alias_method despite their misleading names do not create aliases, they create full copies of methods with new names. Therefore if one overrides aliased method in a subclass, the alias name still points to the copy of the original base class method. There are 2 ways of dealing with it:

Check out a gist and a blog post

I'd also recommend replacing aliases everywhere where a class with aliases may potentially be inherited.

Thank you!

Types of Changes

Testing

ioquatix commented 3 years ago

Ohhh this is a terrible bug lol. Okay, I'll fix it.

ioquatix commented 2 years ago

I don't want to introduce forwardable so I've just manually created a proper alias.