Re: [Interest] Executing a small function as a thread

2015-03-17 Thread Syam Krishnan
On 03/17/2015 09:23 PM, Sze Howe Koh wrote: > >> Well, my situation already needs me to poll objects periodically. >> The following is indicative of my problem: >> >> while(1) >> { >> for(all_objects) >> { >>ret = object[i]->execute() >>if(ret == complete) all_objects.remove

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread Sze Howe Koh
On 17 March 2015 at 23:39, Syam Krishnan wrote: > On 03/17/2015 08:51 PM, André Somers wrote: >> Well, in any multi-threaded programming, you basicaly have no control >> over when something runs. That's up to the OS, not you. It will usually >> be "soonish", but... True. The only time when I've e

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread Syam Krishnan
On 03/17/2015 08:51 PM, André Somers wrote: > Well, in any multi-threaded programming, you basicaly have no control > over when something runs. That's up to the OS, not you. It will usually > be "soonish", but... Understood. >>> That is not acceptable to me. I am looking for the simplest solution

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread André Somers
Sze Howe Koh schreef op 17-3-2015 om 16:15: > Hi, > > On 17 March 2015 at 23:06, Syam Krishnan wrote: >> On 03/17/2015 08:03 PM, André Somers wrote: >>> Might I suggest a third method? Use QtConcurrent::run(yourFunction) >>> instead. >> The documentation on QtConcurrent::run() says >> "Note that t

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread Sze Howe Koh
Hi, On 17 March 2015 at 23:06, Syam Krishnan wrote: > On 03/17/2015 08:03 PM, André Somers wrote: >> Might I suggest a third method? Use QtConcurrent::run(yourFunction) >> instead. > > The documentation on QtConcurrent::run() says > "Note that the function may not run immediately; the function wi

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread Syam Krishnan
On 03/17/2015 08:03 PM, André Somers wrote: > Might I suggest a third method? Use QtConcurrent::run(yourFunction) > instead. The documentation on QtConcurrent::run() says "Note that the function may not run immediately; the function will only be run when a thread is available." That is not accep

Re: [Interest] Executing a small function as a thread

2015-03-17 Thread André Somers
Syam Krishnan schreef op 17-3-2015 om 15:18: > Hi > > I have a function that I need to execute as in a thread in response to > some event. The event is not a signal. > My function do_something() typically takes less than 20 milliseconds to > finish. > > Method-1 > -- > 1. I derive from QThr

[Interest] Executing a small function as a thread

2015-03-17 Thread Syam Krishnan
Hi I have a function that I need to execute as in a thread in response to some event. The event is not a signal. My function do_something() typically takes less than 20 milliseconds to finish. Method-1 -- 1. I derive from QThread and override run() to: void run() { do_something();