Discussion:
[rust-dev] Async Message passing.
Wink Saville
2014-09-28 01:54:28 UTC
Permalink
I'd like to have one API which would allow sending/receiving messages
asynchronously, safely and efficiently over any transport and should work
for components that run in the same thread, different threads, different
processes or between devices which might be connected via any arbitrary
hardware.

Has any such API been developed?

-- wink
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140927/4269bf0d/attachment.html>
Heiko Braun
2014-09-29 10:04:27 UTC
Permalink
I havn't looked at it in detail, but nanomsg [1] seems to cover these requirements. There's a rust binding [2] available too.

Regards, Heiko

[1] http://nanomsg.org
[2] https://github.com/thehydroimpulse/nanomsg.rs
I'd like to have one API which would allow sending/receiving messages asynchronously, safely and efficiently over any transport and should work for components that run in the same thread, different threads, different processes or between devices which might be connected via any arbitrary hardware.
Has any such API been developed?
-- wink
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/4fb9a819/attachment.html>
Wink Saville
2014-09-29 20:01:03 UTC
Permalink
Nanomsg looks interesting and I'll take a closer look. But I'm interested
in a pure rust implementation of async messaging because I'd like to create
an embedded OS using rust and not use C if possible.

I been thinking about the problem and one of the questions I have is how to
transfer ownership of a pointer from one entity to another. Not borrow but
actually transfer ownership. So if I "allocated" a Message in one entity
then send it to another I want the receiver to "free" the Message.

Does the rust ownership model allow ownership to be transferred?

-- Wink
Post by Heiko Braun
I havn't looked at it in detail, but nanomsg [1] seems to cover these
requirements. There's a rust binding [2] available too.
Regards, Heiko
[1] http://nanomsg.org
[2] https://github.com/thehydroimpulse/nanomsg.rs
I'd like to have one API which would allow sending/receiving messages
asynchronously, safely and efficiently over any transport and should work
for components that run in the same thread, different threads, different
processes or between devices which might be connected via any arbitrary
hardware.
Has any such API been developed?
-- wink
_______________________________________________
Rust-dev mailing list
Rust-dev at mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/7e6602d1/attachment.html>
Paul Colomiets
2014-09-29 20:10:50 UTC
Permalink
Hi,
Nanomsg looks interesting and I'll take a closer look. But I'm interested in
a pure rust implementation of async messaging because I'd like to create an
embedded OS using rust and not use C if possible.
I think even if there will be nanomsg implementation in pure rust,
that would probably require rust stdlib, which is usually not used for
embedded purposes, right?
I been thinking about the problem and one of the questions I have is how to
transfer ownership of a pointer from one entity to another. Not borrow but
actually transfer ownership. So if I "allocated" a Message in one entity
then send it to another I want the receiver to "free" the Message.
Does the rust ownership model allow ownership to be transferred?
Sure, you can just send Vec of bytes or any other rust object though
the channel (just like almost any rust object). And semantics is just
like you described. You can also use Arc<Vec<u8>> that allows to use
that message in several places simultaneously (e.g. if you want
publish-subscribe)
--
Paul
Wink Saville
2014-09-30 04:46:08 UTC
Permalink
Hi,
Post by Wink Saville
Nanomsg looks interesting and I'll take a closer look. But I'm
interested in
Post by Wink Saville
a pure rust implementation of async messaging because I'd like to create
an
Post by Wink Saville
embedded OS using rust and not use C if possible.
I think even if there will be nanomsg implementation in pure rust,
that would probably require rust stdlib, which is usually not used for
embedded purposes, right?
Post by Wink Saville
I been thinking about the problem and one of the questions I have is how
to
Post by Wink Saville
transfer ownership of a pointer from one entity to another. Not borrow
but
Post by Wink Saville
actually transfer ownership. So if I "allocated" a Message in one entity
then send it to another I want the receiver to "free" the Message.
Does the rust ownership model allow ownership to be transferred?
Sure, you can just send Vec of bytes or any other rust object though
the channel (just like almost any rust object). And semantics is just
like you described. You can also use Arc<Vec<u8>> that allows to use
that message in several places simultaneously (e.g. if you want
publish-subscribe)
I'd rather not use a channel as channels appear to only work between
tasks. I'd like to have the transfer semantics work between any two
entities.

For instance, I'd like to have a queue between two entities and transfer a
reference via the queue from A to B. .i.e. allocate a Message in A then
place the Message on a queue. A would no longer have a reference to the
Message and the only reference would be the one in the queue. Then when B
retrieved the message from the queue B would have the only reference.
Finally, when B went out of scope, the message would be freed.

Is that possible as the language is currently defined, if so could I be
pointed
to an example or documentation?


Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/ebb8f2aa/attachment.html>
Clark Gaebel
2014-09-30 04:50:11 UTC
Permalink
These are the semantics of a boxed value.
Post by Wink Saville
Hi,
Post by Wink Saville
Nanomsg looks interesting and I'll take a closer look. But I'm
interested in
Post by Wink Saville
a pure rust implementation of async messaging because I'd like to create
an
Post by Wink Saville
embedded OS using rust and not use C if possible.
I think even if there will be nanomsg implementation in pure rust,
that would probably require rust stdlib, which is usually not used for
embedded purposes, right?
Post by Wink Saville
I been thinking about the problem and one of the questions I have is how
to
Post by Wink Saville
transfer ownership of a pointer from one entity to another. Not borrow
but
Post by Wink Saville
actually transfer ownership. So if I "allocated" a Message in one entity
then send it to another I want the receiver to "free" the Message.
Does the rust ownership model allow ownership to be transferred?
Sure, you can just send Vec of bytes or any other rust object though
the channel (just like almost any rust object). And semantics is just
like you described. You can also use Arc<Vec<u8>> that allows to use
that message in several places simultaneously (e.g. if you want
publish-subscribe)
I'd rather not use a channel as channels appear to only work between
tasks. I'd like to have the transfer semantics work between any two
entities.
For instance, I'd like to have a queue between two entities and transfer a
reference via the queue from A to B. .i.e. allocate a Message in A then
place the Message on a queue. A would no longer have a reference to the
Message and the only reference would be the one in the queue. Then when B
retrieved the message from the queue B would have the only reference.
Finally, when B went out of scope, the message would be freed.
Is that possible as the language is currently defined, if so could I be
pointed
to an example or documentation?
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/9247a7f7/attachment.html>
Wink Saville
2014-09-30 04:53:52 UTC
Permalink
Perfect!
Post by Clark Gaebel
These are the semantics of a boxed value.
Post by Wink Saville
Hi,
Post by Wink Saville
Nanomsg looks interesting and I'll take a closer look. But I'm
interested in
Post by Wink Saville
a pure rust implementation of async messaging because I'd like to
create an
Post by Wink Saville
embedded OS using rust and not use C if possible.
I think even if there will be nanomsg implementation in pure rust,
that would probably require rust stdlib, which is usually not used for
embedded purposes, right?
Post by Wink Saville
I been thinking about the problem and one of the questions I have is
how to
Post by Wink Saville
transfer ownership of a pointer from one entity to another. Not borrow
but
Post by Wink Saville
actually transfer ownership. So if I "allocated" a Message in one
entity
Post by Wink Saville
then send it to another I want the receiver to "free" the Message.
Does the rust ownership model allow ownership to be transferred?
Sure, you can just send Vec of bytes or any other rust object though
the channel (just like almost any rust object). And semantics is just
like you described. You can also use Arc<Vec<u8>> that allows to use
that message in several places simultaneously (e.g. if you want
publish-subscribe)
I'd rather not use a channel as channels appear to only work between
tasks. I'd like to have the transfer semantics work between any two
entities.
For instance, I'd like to have a queue between two entities and transfer a
reference via the queue from A to B. .i.e. allocate a Message in A then
place the Message on a queue. A would no longer have a reference to the
Message and the only reference would be the one in the queue. Then when B
retrieved the message from the queue B would have the only reference.
Finally, when B went out of scope, the message would be freed.
Is that possible as the language is currently defined, if so could I be
pointed
to an example or documentation?
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/8c9144d1/attachment.html>
Tony Arcieri
2014-09-29 21:03:16 UTC
Permalink
Post by Wink Saville
Nanomsg looks interesting and I'll take a closer look. But I'm interested
in a pure rust implementation of async messaging because I'd like to create
an embedded OS using rust and not use C if possible
You might take a look at capnproto-rust:

https://github.com/dwrensha/capnproto-rust

It doesn't support asynchronous messaging (yet) but it is planned. That
said it supports an RPC system that's fully asynchronous under the covers,
so async messaging becomes effectively "disregard the response"

It also provides a typed description language for messages that maps nicely
to Rust's type system.
--
Tony Arcieri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/ad1bf5fb/attachment.html>
Wink Saville
2014-09-30 04:50:22 UTC
Permalink
Cool, I've been following capn proto and have used protobufs a little. This
is the direction of what I'm thinking and I'm wondering if the rust notion
of
ownership can be leveraged in message passing. Hence my silly questions.
Post by Tony Arcieri
Post by Wink Saville
Nanomsg looks interesting and I'll take a closer look. But I'm interested
in a pure rust implementation of async messaging because I'd like to create
an embedded OS using rust and not use C if possible
https://github.com/dwrensha/capnproto-rust
It doesn't support asynchronous messaging (yet) but it is planned. That
said it supports an RPC system that's fully asynchronous under the covers,
so async messaging becomes effectively "disregard the response"
It also provides a typed description language for messages that maps
nicely to Rust's type system.
--
Tony Arcieri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140929/a77ffa07/attachment.html>
Loading...