Concurrency send immutable

Daniel Kozak kozzi11 at gmail.com
Fri Nov 24 12:51:28 UTC 2017


import std.stdio;
import std.traits;

int main(string[] args)
{
immutable int[] arr = [1,2,3,4,5];
writeln(ImplicitConversionTargets!(typeof(arr)).stringof);
return 0;
}

On Fri, Nov 24, 2017 at 1:36 PM, Daniel Kozak <kozzi11 at gmail.com> wrote:

> Should print something like this:
> std.concurrency.OwnerTerminated at std/concurrency.d(223): Owner terminated
>
> Because main thread is terminated, because types do not match
>
> this will work
> import std.stdio;
> import std.concurrency;
>
> void fun()
> {
> receive( (immutable (int)[] v) => writeln(v) );
> }
>
> int main(string[] args)
> {
> immutable int[] arr = [1,2,3,4,5];
> auto t = spawn(&fun);
> t.send(arr);
> return 0;
> }
>
> On Fri, Nov 24, 2017 at 1:06 PM, SrMordred via Digitalmars-d-learn <
> digitalmars-d-learn at puremagic.com> wrote:
>
>> On Friday, 24 November 2017 at 12:05:16 UTC, SrMordred wrote:
>>
>>> immutable int[] arr = [1,2,3,4,5];
>>> auto t = spawn({ receive( (immutable int[] v) => writeln(v) );});
>>> t.send(arr);
>>>
>>> whats the problem here?
>>>
>>
>> Nothing prints out
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20171124/1634d779/attachment.html>


More information about the Digitalmars-d-learn mailing list