Queued Custom Type Example was of much help. thanks a lot victor.
Now I am stuck with another issue, and I think its again a silly one. Still gotta find a solution!
Here is my code:
master.cpp
thread = new RenderThread();
connect(ui.updateStatsButton, SIGNAL(clicked()), this, SLOT(updateStats()));
....
//in updateStats()
thread->startOffThread(sessionName, logPos, event_id);
thread = new RenderThread();
connect(ui.updateStatsButton, SIGNAL(clicked()), this, SLOT(updateStats()));
....
//in updateStats()
thread->startOffThread(sessionName, logPos, event_id);
To copy to clipboard, switch view to plain text mode
thread.cpp
void RenderThread
::startOffThread(const QString &str,
int logPos, Event_Id event_id
) {
...
//some manipulations on variables supplied
start();
}
//in RenderThread::run()
do {
...
emit sendString(str, str2);
sleep(1);
}while (some_condition);
void RenderThread::startOffThread(const QString &str, int logPos, Event_Id event_id)
{
...
//some manipulations on variables supplied
start();
}
//in RenderThread::run()
do {
...
emit sendString(str, str2);
sleep(1);
}while (some_condition);
To copy to clipboard, switch view to plain text mode
Now here is my problem - I have multiple Events on which the above actions have to be performed independently.
suppose i have Event01 and Event02. I clicked updateStats button for Event01 and code is executed properly and stats are being updated. Meanwhile I clicked updateStats for Event02 (where in functioncall
thread->startOffThread(sessionName, logPos, event_id);
thread->startOffThread(sessionName, logPos, event_id);
To copy to clipboard, switch view to plain text mode
the variables supplied differ) Event01 updation stops and Event02 starts!
I want Event01 and Event02 (and many many more) to run parallelly without affecting each other.
How do I implement multiple threads?
How do start and stop them? I could not find anything similar to thread_id from pthreads.
someone please help...
Bookmarks