Re: shared and nonshared dtor

2014-07-20 Thread Vlad Levenfeld via Digitalmars-d-learn

On Sunday, 20 July 2014 at 08:29:55 UTC, Jonathan M Davis wrote:
What you will probably need to do is to not try and use the 
same type as both shared and non-shared if it has a destructor.


Unfortunately this option would require an unrealistic lot of 
refactoring for me. I'm basically using this thing as a drop-in 
replacement for arrays, so they go everywhere. I use array-based 
swap buffers to transfer data between threads. I have to declare 
the buffers shared, which makes the arrays shared.
This problem only emerged when I decided I wanted them to free on 
destruction, so it looks like I'll be sticking with manual free 
for awhile longer.


I would however suggest that you report this as a bug, since it 
really should be able to distinguish between shared and 
unshared destructors.


Would it be considered a duplicate of 
https://issues.dlang.org/show_bug.cgi?id=12004 ? At least, all of 
my use cases agree with the bug filer's argument against having 
any shared dtors.


shared is a great concept, but we are going to need a few 
adjustments to its design in order to make it properly, fully 
useable.


Agreed. It's given me a few headaches in the past, but I do like 
the idea of a transitive qualifier that helps me identify 
potentially racy data.


Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't look 
like anything along the lines of an OS thread handle is exposed 
in the API.


What do you need the OS thread handle for?


Re: get os thread handles

2014-07-20 Thread Sean Campbell via Digitalmars-d-learn

On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote:

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't look 
like anything along the lines of an OS thread handle is exposed 
in the API.


What do you need the OS thread handle for?


sonce the standard so i can get pause/resume support for d threads


Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn

On Sunday, 20 July 2014 at 10:03:47 UTC, Sean Campbell wrote:

On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote:

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't 
look like anything along the lines of an OS thread handle is 
exposed in the API.


What do you need the OS thread handle for?


sonce the standard so i can get pause/resume support for d 
threads


I'd suggest opening up an enhancement request. Assuming that that 
functionality exists across all of the various OSes, it can 
probably be added:


https://issues.dlang.org

You can also open an enhancement request for getting access to 
the OS thread handles, but my guess is that that wouldn't happen, 
because it makes it so that the Thread class no longer has full 
control, which would make it impossible to have any kind of 
@safety for Thread (though it doesn't seem to currently have any 
such annotations).


But if what you're looking for is thread functionality that is 
common across OSes, then there's a good chance that it's 
reasonable to add it to Thread, making it unnecessary to provide 
access to its innards.


In the meantime, I expect that you'll have to either use the C 
APIs directly or create your own class  which is a copy of Thread 
and tweak it to do what you need.


How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-20 Thread Uranuz via Digitalmars-d-learn

The question is in the header:
How to say to compiler that I want to inherit final template 
bethod of base interface into derived class?


I have the following example. I know that it is maybe 
overcomplicated but still I need this feature in my code.


import std.stdio;

interface IBase
{

template getStr(string fieldName)
{
final string getStr()
{
return George;
}
}


string getStr(string fieldName);
}


class Derived: IBase
{
override string getStr(string fieldName)
{
return Sam;
}

}


void main()
{
auto obj = new Derived;

writeln( obj.getStr!(aaa)() );

}

Compilation output:
/d907/f266.d(33): Error: obj.getStr isn't a template


When I have all of these methods having the same name compiler 
shadows template method from the base interface. So the question 
is how to inherit template method without reimplementing it in 
derived class?


Re: How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-20 Thread anonymous via Digitalmars-d-learn

import std.stdio;

interface IBase
{

template getStr(string fieldName)
{
final string getStr()
{
return George;
}
}


string getStr(string fieldName);
}


class Derived: IBase
{
alias getStr = IBase.getStr; /* order matters, see below */
override string getStr(string fieldName)
{
return Sam;
}
/* alias getStr = IBase.getStr; /* doesn't work here, I guess
that's a compiler bug */
}


void main()
{
auto obj = new Derived;

assert( obj.getStr!(aaa)() == George );
assert( obj.getStr(aaa) == Sam );

}