Re: Sending an immutable object to a thread

2015-07-24 Thread Frank Pagliughi via Digitalmars-d-learn
On Friday, 24 July 2015 at 18:02:58 UTC, Ali Çehreli wrote: Although the example casts to void*, ubyte* and others are possible as well, and casting back to the correct class type seems to work: Thanks, Ali. I just tried a few things, and apparently, you don't need to go to a different type

Re: Sending an immutable object to a thread

2015-07-24 Thread Frank Pagliughi via Digitalmars-d-learn
On Friday, 24 July 2015 at 19:28:35 UTC, anonymous wrote: I haven't followed the discussion, so I may be missing the point here. I started by asking how to send a reference to an immutable class object from one thread to another if the reference is one of several parameters being sent. The

Re: Sending an immutable object to a thread

2015-07-23 Thread Frank Pagliughi via Digitalmars-d-learn
On Thursday, 23 July 2015 at 09:05:12 UTC, Marc Schütz wrote: It is not safe, but for a different reason: `mt` is already a _reference_ to the actual object (that's how classes behave in D). This reference is located in a register or on the stack, and `mt` is therefore a pointer into the

Re: Sending an immutable object to a thread

2015-07-22 Thread Frank Pagliughi via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 09:04:49 UTC, Marc Schütz wrote: But as long as the original pointer is still on the stack, that one _will_ keep the object alive. It is only a problem if all pointers to a GC managed object are stored in places the GC isn't informed about. Sorry, I have

Re: Sending an immutable object to a thread

2015-07-21 Thread Frank Pagliughi via Digitalmars-d-learn
On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote: a pointer to a pointer(or in this case, a reference) does not keep it alive. Interesting. If you de-reference the pointer and assign it back, do you get back the keep-alive? Like, in the receiving thread: void threadFunc() {

Re: Sending an immutable object to a thread

2015-07-19 Thread Frank Pagliughi via Digitalmars-d-learn
It looks like passing a pointer to an immutable(Message) works as well: Oh, yes, pointer. Ha! I didn't even think of that. Thanks. I'm not familiar with how garbage collection works in D. If the initial reference goes out of scope, and you just have a pointer - in another thread, no less -

Sending an immutable object to a thread

2015-07-18 Thread Frank Pagliughi via Digitalmars-d-learn
Hey All, I'm trying to send immutable class objects to a thread, and am having trouble if the object is one of several variables sent to the thread. For example, I have a Message class: class Message { ... } and I create an immutable object from it, and send it to another thread:

Re: Sending an immutable object to a thread

2015-07-18 Thread Frank Pagliughi via Digitalmars-d-learn
OK, I found a couple of solutions, though if anyone can tell me something better, I would love to hear it. By making an alias to a rebindable reference, the receive() was able to create the tuple. So I renamed the class MessageType: class MessageType { ... }; and then made a Message an

Re: Looking for MQTT client library

2015-04-23 Thread Frank Pagliughi via Digitalmars-d-learn
I got the OK to submit the D library to Eclipse Paho. So, hopefully within the next few weeks there will be a Paho incubator project for the D language client.