Jump to page: 1 2
Thread overview
What wrong?
May 02, 2015
Fyodor Ustinov
May 02, 2015
Dennis Ritchie
May 02, 2015
Fyodor Ustinov
May 02, 2015
Dennis Ritchie
May 04, 2015
Fyodor Ustinov
May 04, 2015
Dennis Ritchie
May 05, 2015
sclytrack
May 14, 2015
sclytrack
May 15, 2015
thedeemon
May 15, 2015
Gary Willoughby
May 15, 2015
Daniel Kozak
May 15, 2015
anonymous
May 02, 2015
Simple code:

http://pastebin.com/raw.php?i=7jVeMFXQ

This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0.

$ ./z
TUQLUE
42
11

Compiled by DMD v2.067.1 the program crashes:
$ ./aa
TUQLUE
Segmentation fault

What I'm doing wrong?
May 02, 2015
On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote:
> Simple code:
>
> http://pastebin.com/raw.php?i=7jVeMFXQ
>
> This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0.
>
> $ ./z
> TUQLUE
> 42
> 11
>
> Compiled by DMD v2.067.1 the program crashes:
> $ ./aa
> TUQLUE
> Segmentation fault
>
> What I'm doing wrong?


I think the problem is in these lines:

-----
receive(
	(supervisorAnswer a) => r = a.ret
);

Partially it works :)

-----
import std.variant;

private struct Exit{};
private struct supervisorAnswer {
	Variant ret;
}

private __gshared Tid supervisorTid;

private void supervisor() {
	static Variant[string] zval;
	bool done = false;
	void _store(T)(string k, T v) {
		assert(k.length > 0);
		zval[k] = v;
	}
	
	void _get(Tid id, string k) {
		id.send(supervisorAnswer(zval.get(k, Variant("NOTFOUND"))));
	}
	
	while (!done) {
		supervisorAnswer answer;
		receive(
			(Exit s) { done = true; },
			&_store!long,
			&_store!ulong,
			&_store!int,
			&_store!uint,
			&_store!float,
			&_store!double,
			&_store!string,
			&_store!Variant,
			&_get,
			(Variant e) {  writeln(e); },
			);
	}
}

Variant Get(const string s) {
	Variant r;
	supervisorTid.send(thisTid, s);
	writeln("TUQLUE");
	/*receive(
		(supervisorAnswer a) => r = a.ret
		);*/
	writeln("42");
	return r;
}

void Set(T)(const string s, T v) {
	supervisorTid.send(s, v);
}

shared static this() {
	supervisorTid = spawn(&supervisor);
}

shared static ~this() {
	send(supervisorTid, Exit());
}

void main() {
	Set("1", 11);
	writeln(Get("1"));
	send(supervisorTid, Exit());
	thread_joinAll();
}
May 02, 2015
On Saturday, 2 May 2015 at 19:13:45 UTC, Dennis Ritchie wrote:
> On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote:
>> Simple code:
>>
>> http://pastebin.com/raw.php?i=7jVeMFXQ
>>
>> This code works compiled by DMD v2.066.1 and LDC2 (0.15.1) based on DMD v2.066.1 and LLVM 3.5.0.
>>
>> $ ./z
>> TUQLUE
>> 42
>> 11
>>
>> Compiled by DMD v2.067.1 the program crashes:
>> $ ./aa
>> TUQLUE
>> Segmentation fault
>>
>> What I'm doing wrong?
>
>
> I think the problem is in these lines:
>
> -----
> receive(
> 	(supervisorAnswer a) => r = a.ret
> );
>
> Partially it works :)

I see it by the lack of "42". :)

But why is this "receive" breaks down?
May 02, 2015
On Saturday, 2 May 2015 at 19:38:01 UTC, Fyodor Ustinov wrote:
> I see it by the lack of "42". :)
>
> But why is this "receive" breaks down?

Report, please, about it (D)evepopers :)
https://issues.dlang.org/
May 04, 2015
On Saturday, 2 May 2015 at 20:46:32 UTC, Dennis Ritchie wrote:
> On Saturday, 2 May 2015 at 19:38:01 UTC, Fyodor Ustinov wrote:
>> I see it by the lack of "42". :)
>>
>> But why is this "receive" breaks down?
>
> Report, please, about it (D)evepopers :)
> https://issues.dlang.org/

I'm not sure that it's not my fault. So I hope that will come by knowledgeable people and say "Hey, buddy, your mistake is..." :)
May 04, 2015
On Monday, 4 May 2015 at 01:03:43 UTC, Fyodor Ustinov wrote:
> I'm not sure that it's not my fault. So I hope that will come by knowledgeable people and say "Hey, buddy, your mistake is..." :)

OK. But if one does not come within three days :), duplicate topic in this section:
http://forum.dlang.org/group/digitalmars.D
May 05, 2015
On Monday, 4 May 2015 at 01:03:43 UTC, Fyodor Ustinov wrote:
> On Saturday, 2 May 2015 at 20:46:32 UTC, Dennis Ritchie wrote:
>> On Saturday, 2 May 2015 at 19:38:01 UTC, Fyodor Ustinov wrote:
>>> I see it by the lack of "42". :)
>>>
>>> But why is this "receive" breaks down?
>>


import std.stdio;
import std.concurrency;

struct Answer
{
        int number = 10;
        ~this()
        {
                writeln(number);
        }
}

void threadRoutine()
{
  receive(
       (int value){ }          //handle question
  );

  ownerTid.send( Answer() );   //answer
}

void main()
{
        Tid childId = spawn(&threadRoutine);
        childId.send(100);              //question
        receive((Answer t) {});         //answer
}


//DMD64 D Compiler v2.067.1

/*
10
10
10
10
10
10
10
10
10
10
10
7080544
10
10
10
*/
May 14, 2015
On Tuesday, 5 May 2015 at 07:41:04 UTC, sclytrack wrote:
> On Monday, 4 May 2015 at 01:03:43 UTC, Fyodor Ustinov wrote:
>> On Saturday, 2 May 2015 at 20:46:32 UTC, Dennis Ritchie wrote:
>>> On Saturday, 2 May 2015 at 19:38:01 UTC, Fyodor Ustinov wrote:
>>>> I see it by the lack of "42". :)
>>>>
>>>> But why is this "receive" breaks down?
>>>


import std.stdio;
import std.variant;

struct SoMany
{
        int number = 10;
        ~this()
        {
                writeln(number);
        }
}

void main()
{
        Variant v = SoMany();
}


DMD64 D Compiler v2.067.1
10
10
10
10
gdc (Debian 4.9.2-10) 4.9.2
10
10


For DMD I'm getting 4x10 and for gdc 2x10






May 15, 2015
On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote:
> Simple code:
>
> http://pastebin.com/raw.php?i=7jVeMFXQ
>
> What I'm doing wrong?

Try using class instead of struct.
Last time I played with std.concurrency it used Variants to store the messages, so when something bigger than a little basic value or a reference, like a class object, is sent it behaves unpredictably: can crash or shit garbage. Trying to send structs larger than ~20 bytes usually caused problems.
May 15, 2015
On Friday, 15 May 2015 at 07:51:29 UTC, thedeemon wrote:
> On Saturday, 2 May 2015 at 02:51:52 UTC, Fyodor Ustinov wrote:
>> Simple code:
>>
>> http://pastebin.com/raw.php?i=7jVeMFXQ
>>
>> What I'm doing wrong?
>
> Try using class instead of struct.
> Last time I played with std.concurrency it used Variants to store the messages, so when something bigger than a little basic value or a reference, like a class object, is sent it behaves unpredictably: can crash or shit garbage. Trying to send structs larger than ~20 bytes usually caused problems.

Please raise a bugzilla issue for this.
« First   ‹ Prev
1 2