Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.programming.threads > #1140
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "aminer" <aminer@videotron.ca> |
| Newsgroups | comp.programming.threads, comp.programming |
| Subject | Re: My threadpool engine and scalability... |
| Date | Mon, 1 Oct 2012 12:06:49 -0500 |
| Organization | A noiseless patient Spider |
| Lines | 117 |
| Message-ID | <k4cf2v$ja2$1@dont-email.me> (permalink) |
| References | <k4ce5t$cv8$5@dont-email.me> |
| Injection-Date | Mon, 1 Oct 2012 16:06:55 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="c43ca82f9e8d62a602307fe9d2e9b807"; logging-data="19778"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/T5y/RHPrm7pOCao3m4+d+" |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.6157 |
| X-RFC2646 | Format=Flowed; Response |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.5931 |
| Cancel-Lock | sha1:/Ar60tPR+tN6OVogPxJLj40aCcA= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Xref | csiph.com comp.programming.threads:1140 comp.programming:2267 |
Cross-posted to 2 groups.
Show key headers only | View raw
After adding getindex() and execute1() methods , this threadpool engine can also be used as a scalable queue (not a strict FIFO queue, but it's also useful), . Amine Moulay Ramdane "aminer" <aminer@videotron.ca> wrote in message news:k4ce5t$cv8$5@dont-email.me... > > Hello, > > If you take a look at my threadpool engine: > > http://pages.videotron.com/aminer/ > > you will notice that it does not scale in the execute() method > cause LockedIncLong(balance1) is expensive. > > here is the execute method: > > == > > function TThreadPool.execute(func:TMyProc;const Context: Pointer): > Boolean; > > var > local_balance,local_count:long; > > params: PParams; > p:pointer; > > begin > new(params); > setlength(params^,1); > params^[0].proc:=func; > params^[0].data:=context; > > local_balance:=LockedIncLong(balance1) mod FThreadCount; > while not Queues[local_balance].push(tobject(params)) do sleep(0); > events[local_balance].setevent; > end; > > === > > Now to be able to scale the execute() method we have to add a getindex() > method like this > > function TThreadPool.getindex(var index:long); > begin > if index <> 0 > then > begin > inc(index); > index:=index mod FThreadCount; > end; > end; > > > and also add an execute1() method that scales perfectly like this: > > == > function TThreadPool.execute1(func:TMyProc;const Context: > Pointer;index:long): Boolean; > > var > local_balance,local_count:long; > > params: PParams; > p:pointer; > > begin > new(params); > setlength(params^,1); > params^[0].proc:=func; > params^[0].data:=context; > > while not Queues[index].push(tobject(params)) do sleep(0); > events[local_balance].setevent; > end; > > == > > so we have to call the getindex() method from mutiple threads like this: > > // we have to initialize count to zero before: > > getindex(count) > ThreadPool.execute(myproc,data,count) > > and now the execute1() method will scale perfectly. > > > I will try update my threadpol engine soon. > > > > Thank you, > Amine Moulay Ramdane. > > > > > > > > > >
Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar
My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 11:51 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 11:54 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 12:06 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 12:18 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 12:30 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 12:36 -0500 Re: My threadpool engine and scalability... "aminer" <aminer@videotron.ca> - 2012-10-01 12:43 -0500
csiph-web