Changeset 387
- Timestamp:
- 07/12/08 19:36:11 (3 months ago)
- Files:
-
- trunk/tools/tools/threadpool.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tools/tools/threadpool.d
r386 r387 61 61 void mt_foreach(T, C)(T iterable, C callable) { 62 62 int left; auto sync = new Object; 63 static if (is(typeof({ foreach (i, entry; array) callable(i, entry); }))) {64 foreach (i, entry; array) {63 static if (is(typeof({ foreach (i, entry; iterable) callable(i, entry); }))) { 64 foreach (i, entry; iterable) { 65 65 synchronized(sync) left ++; 66 66 addTask(stuple(i, entry) /apply/ (typeof(i) i, typeof(entry) entry) { … … 69 69 }); 70 70 } 71 } else static if (is(typeof({ foreach (entry; array) callable(entry); }))) {72 foreach (entry; array) {71 } else static if (is(typeof({ foreach (entry; iterable) callable(entry); }))) { 72 foreach (entry; iterable) { 73 73 synchronized(sync) left ++; 74 74 addTask(entry /apply/ (typeof(entry) entry) { … … 77 77 }); 78 78 } 79 } 79 } else static assert(false, "Cannot seem to iterate over "~T.stringof~", calling "~C.stringof~"!"); 80 80 while (left) if (idle()) slowyield(); 81 81 }
