== Quote from Jerry Quinn ([email protected])'s article
> > Hmm, currently there isn't an easy/obvious way, though I'm thinking maybe 
> > one
> > should be added.  I've kind of needed it, too, and I don't anticipate it 
> > being
> > very hard to implement.  If you can suggest a good API for this, I'll work 
> > on it
> > for next release.
> I'd probably naturally want to do something like:
> auto engines = taskPool.init(new Engine(params));
> auto lines = File("foo.txt").byLine();
> auto results = taskPool.map!(engines.process)(lines)
> foreach (auto r; results)
>   writeln(r);
> This would create a set of new Engine objects per object, but initialized 
> within
each thread as thread-local data.  Each Engine object has a process() call 
taking
a line as input and returning a string in this case.  Any free engine can 
process
more work as long as there is still work available.
> For the large-scale use case, it could take an extra argument and allow only N
simultaneous init's under the covers.

>From reading your later posts, it seems like what you really want is 
>worker-local
storage that's initialized from the thread that owns it rather than the thread
that workerLocalStorage() was called from.  This may be do-able but I'll have to
think about the consequences and the implementation.  In the mean time, see my
other posts for a workaround.

Reply via email to