Re: Thread Attributes

2014-07-15 Thread Jacob Carlborg via Digitalmars-d
On 14/07/14 23:26, Jonathan Marler wrote: Ah I see now. It looks like AST macros are going to open up alot of new paradigms, I'm excited to see how they progress and what they can do. It doesn't get us all the way there in this example but its a very good alternative without having to add

Re: Thread Attributes

2014-07-14 Thread Jonathan Marler via Digitalmars-d
On Sunday, 13 July 2014 at 10:45:29 UTC, Jacob Carlborg wrote: This would be implemented as a declaration macro [1], something like this: macro thread (Context, Ast!(string) name, Declaration decl) { if (decl.isVariable) decl.attributes ~= Thread(name); else if

Re: Thread Attributes

2014-07-13 Thread Jacob Carlborg via Digitalmars-d
On 2014-07-11 19:07, Jonathan Marler wrote: I'm not sure how AST macros would assist in thread safety the way that this feature would. Maybe you could elaborate? Looking at the first example: @thread:main int mainThreadGlobal; @thread:main int main(string[] args) { // Start the worker

Re: Thread Attributes

2014-07-12 Thread Jonathan Marler via Digitalmars-d
On Friday, 11 July 2014 at 18:56:07 UTC, Timon Gehr wrote: On 07/10/2014 08:12 PM, Jonathan Marler wrote: So what do people think? How do you make sure there is at most one thread of each kind? Good question. First, since the language doesn't support starting threads itself (like Go) but

Re: Thread Attributes

2014-07-11 Thread Jacob Carlborg via Digitalmars-d
On 10/07/14 20:12, Jonathan Marler wrote: I had an idea this morning and wanted to post it to see what people think. I know we have alot of attributes already but I'm wondering if people think adding a thread attribute could be useful. Something that says a variable or function or class/struct

Re: Thread Attributes

2014-07-11 Thread Jonathan Marler via Digitalmars-d
I'm not sure how AST macros would assist in thread safety the way that this feature would. Maybe you could elaborate? To explain a little more, when you put a @thread:name or @sync(object) attribute on something, the compiler will guarantee that no safe D code will ever use that code or data

Re: Thread Attributes

2014-07-11 Thread Timon Gehr via Digitalmars-d
On 07/10/2014 08:12 PM, Jonathan Marler wrote: So what do people think? How do you make sure there is at most one thread of each kind?

Thread Attributes

2014-07-10 Thread Jonathan Marler via Digitalmars-d
I had an idea this morning and wanted to post it to see what people think. I know we have alot of attributes already but I'm wondering if people think adding a thread attribute could be useful. Something that says a variable or function or class/struct can only be accessed by code that has