On 07/23/2015 06:48 AM, Frank Pagliughi wrote:
So, passing a pointer to a stack-based reference from one thread is
another is not necessarily a good thing to do, as the original reference
might disappear while the thread is using it.
Right.
Is there a way to get the address of the actual
On Friday, 24 July 2015 at 18:55:26 UTC, Frank Pagliughi wrote:
So then, of course, I hope/wonder/assume that the pointer to
the heap is sufficient to keep the heap memory alive, and that
this would be OK from the GC perspective to do something like
this:
B* make_b_thing(int i) { cast(B*)
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
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
On Friday, 24 July 2015 at 21:51:44 UTC, Frank Pagliughi wrote:
So then: is there a pointer notation to which you can cast the
B reference, which thus points to the heap, but retains type
identity of the heap object?
There's no straight forward way to do that. D has no types for
the actual
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
On Wednesday, 22 July 2015 at 17:17:17 UTC, Frank Pagliughi wrote:
Or, to put it another way, getting threads out of the equation,
is this safe?
class MyThing { ... }
MyThing* create_a_thing() {
MyThing mt = new MyThing();
do_something_with(mt);
return mt;
}
void main() {
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
On Wednesday, 22 July 2015 at 17:17:17 UTC, Frank Pagliughi wrote:
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
On Tuesday, 21 July 2015 at 21:50:35 UTC, rsw0x wrote:
On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote:
On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:
[...]
wow, I don't even remember posting this.
This is (mostly) wrong, but I'm unsure if a pointer to another
pointer on the
On Wednesday, 22 July 2015 at 09:04:49 UTC, Marc Schütz wrote:
On Tuesday, 21 July 2015 at 21:50:35 UTC, rsw0x wrote:
On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote:
[...]
addendum:
http://dlang.org/garbage.html
[...]
[...]
I believe this implies that it would *not* keep the
On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:
On Sunday, 19 July 2015 at 17:04:07 UTC, Frank Pagliughi wrote:
[...]
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
On Tuesday, 21 July 2015 at 21:44:07 UTC, rsw0x wrote:
On Sunday, 19 July 2015 at 17:12:07 UTC, rsw0x wrote:
[...]
wow, I don't even remember posting this.
This is (mostly) wrong, but I'm unsure if a pointer to another
pointer on the stack would correctly keep its object alive(but,
I
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()
{
It is a pitty that although Variant is the default message type in
concurrency, it still has issues:
https://issues.dlang.org/buglist.cgi?quicksearch=variant%20concurrencylist_id=202195
It looks like passing a pointer to an immutable(Message) works as well:
import std.stdio;
import
On Sunday, 19 July 2015 at 17:04:07 UTC, Frank Pagliughi wrote:
[...]
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 -
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 -
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:
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
19 matches
Mail list logo