These are the semantics of a boxed value.

On Mon, Sep 29, 2014 at 9:47 PM, Wink Saville <w...@saville.com> wrote:

> On Mon, Sep 29, 2014 at 1:10 PM, Paul Colomiets <p...@colomiets.name> wrote:
>> Hi,
>>
>> On Mon, Sep 29, 2014 at 11:01 PM, Wink Saville <w...@saville.com> wrote:
>> > 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)
>>
> 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
>>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to