Constant GC allocations when sending large messages to threads?
cc
cc at nevernet.com
Sun Feb 2 17:13:34 UTC 2020
On Friday, 31 January 2020 at 15:47:26 UTC, Steven Schveighoffer
wrote:
> You could use RefCounted to build a struct that then is
> sendable with the data you need. RefCounted allocates using C
> malloc, not the GC.
Thanks for the tips. How exactly would I go about sending a
RefCounted value?
static struct Foo {
int a;
@disable this(this);
}
auto t = RefCounted!Foo(Foo(5));
tid.send(t);
Gives me: phobos\std\concurrency.d(625): Error: static assert:
"Aliases to mutable thread-local data not allowed."
Whereas trying to declare it as immutable gives me a pile of
errors including: Error: mutable method
`std.typecons.RefCounted!(int,
cast(RefCountedAutoInitialize)1).RefCounted.__postblit` is not
callable using a `immutable` object
More information about the Digitalmars-d-learn
mailing list