Permalink
Browse files

Reintroduce destructor for ThreadPool and extend the example

  • Loading branch information...
1 parent 4918437 commit bffd4a4dd1f260d8f8ecfe0dad43aada13e47e3d @meh committed May 11, 2012
Showing with 9 additions and 1 deletion.
  1. +3 −1 examples/threadpool.d
  2. +6 −0 nucular/threadpool.d
View
@@ -1,12 +1,14 @@
import std.stdio;
+import std.array;
+import core.thread;
import nucular.threadpool;
void main () {
auto pool1 = new ThreadPool;
auto pool2 = new ThreadPool;
pool1.process({ writeln(";)"); });
- pool2.process({ writeln(":("); });
+ pool2.processWith(23, (int a) { writeln(":( ".replicate(a)); });
// shutdown has to be done, otherwise the process won't end properly
pool1.shutdown();
View
@@ -18,6 +18,8 @@
module nucular.threadpool;
+import std.stdio;
+
import std.container;
import std.algorithm;
import std.array;
@@ -44,6 +46,10 @@ class ThreadPool {
}
}
+ ~this () {
+ shutdown();
+ }
+
void resize (int min, int max = 0) {
if (max == 0) {
max = min;

0 comments on commit bffd4a4

Please sign in to comment.