random stuff you might find useful

Downs default_357-line at yahoo.de
Tue May 22 10:44:22 PDT 2007


torhu wrote:
> Downs wrote:
>> Here's a collection of random stuff I made. Feel free to grab sniplets 
>> as you see fit.
>>
>> module tools.Tools;
>> import std.string, std.thread, std.file, std.bind, std.stdio: FILE;
>> import std.c.stdio;
>>
>> /// get the currently active thread (duh)
>> int getThread() { foreach (idx, thr; Thread.getAll) if (thr.isSelf) 
>> return idx; assert(false); }
>>
> <snip>
> 
>  From std.thread docs:
> 
> static Thread getThis();
>     Returns a reference to the Thread for the thread that called the 
> function.
> 
> Isn't this what you're doing?
Basically yes, but in this case I needed an index for the current thread that is more easily readable than the reference address - note that getThread returns an integer.



More information about the Digitalmars-d mailing list