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

Rewrite of wait_readable to use the Cellulid::ZMQ mailbox reactor #21

Closed
wants to merge 2 commits into from

Conversation

CootCraig
Copy link
Contributor

A change in response to #20

@halorgium
Copy link
Contributor

@CootCraig could you remove the version changes in this commit?
Did you get what I meant about moving #evented? to the module and using that in the wait_* methods?

if actor && actor.mailbox.is_a?(Celluloid::ZMQ::Mailbox)
actor.mailbox.reactor.wait_readable(socket)
else
throw NotZmqActorError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure we should raise here.
@tarcieri ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably just call it a TypeError or ArgumentError

@CootCraig
Copy link
Contributor Author

@halorgium I'm removing the version change and yes I'll move #evented?

On the socket read, only call Celluloid::ZMQ.wait_readable if Celluloid::ZMQ.evented?
Set the version back to 0.13.0
Set the celluloid-io dependency back to 0.13.0
@CootCraig
Copy link
Contributor Author

Pushed changes to the craig branch on CootCraig/celluloid-zmq

Move the evented? function to the module, Celluloid::ZMQ.evented?
On the socket read, only call Celluloid::ZMQ.wait_readable if Celluloid::ZMQ.evented?
Set the version back to 0.13.0
Set the celluloid-io dependency back to 0.13.0

@@ -68,7 +59,7 @@ def connect(addr)

# Read a message from the socket
def read(buffer = '')
Celluloid.current_actor.wait_readable(@socket) if evented?
Celluloid::ZMQ.wait_readable(@socket) if Celluloid::ZMQ.evented?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you moved the check inside the method, it would be more closer to celluloid-io.
https://github.com/celluloid/celluloid-io/blob/032a100f46fb1887e12c2faad9f6bfa377cee5e1/lib/celluloid/io/stream.rb#L39

@halorgium
Copy link
Contributor

@CootCraig I am not sure the change is being solved in the right way here.
Could you jump on IRC?
We can talk through the change.

Also, I just cleaned up celluloid-io.

@CootCraig
Copy link
Contributor Author

I just got up for the day. Let me know about doing IRC. I'll fetch the latest and have a look now.

@CootCraig
Copy link
Contributor Author

Also my read test case is working on Windows JRuby as well.

$ jruby -v
jruby 1.7.4.dev (1.9.3p392) 2013-04-16 cb556ed on Java HotSpot(TM) Client VM 1.8
.0-ea-b78 +indy [Windows 2003-x86]

@CootCraig
Copy link
Contributor Author

I have grabbed the spelling change by @halorgium and done a new branch with ZMQ::Socket#read
changes.
branch fix-0mq-io-wait on CootCraig/celluloid-zmq
Notes:
zmq.rb: removed the reactor delegators.
zmq.rb: add ZMQ::evented? - Is this a Celluloid::ZMQ evented actor?
zmq.rb: add ZMQ::wait_readable using the ZMQ::Reactor
zmq/sockets.rb: evented? now in zmq.rb. remove Socket#evented?
zmq/sockets.rb: Change Socket#read to use ZMQ#wait_readable

I have kept the evented? guard on the wait in Socket#read. This would prevent an exception if evented? fails
and the 0mq socket read that follows is not evented.

@CootCraig
Copy link
Contributor Author

I have a test script that does Socket#read with Celluloid/zmq. It is working on Ubuntu and Windows
with these JRuby environments

$ jruby -v
jruby 1.7.4.dev (1.9.3p392) 2013-04-16 cb556ed on Java HotSpot(TM) 64-Bit Server VM 1.8.0-ea-b80 +indy [linux-amd64]

$ jruby -v
jruby 1.7.4.dev (1.9.3p392) 2013-04-16 cb556ed on Java HotSpot(TM) Client VM 1.8.0-ea-b78 +indy [Windows 2003-x86]

@CootCraig
Copy link
Contributor Author

Also I made no changes for Socket#write.

@halorgium
Copy link
Contributor

@CootCraig sorry I missed you on IRC, timezones are hard!
We have another few changes we are looking at making on top of this, I will try and get this finished and merged.
I hope you get a chance to have a look at the solution, I appreciate the time taken!

@halorgium halorgium closed this Apr 19, 2013
@halorgium
Copy link
Contributor

See #20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants