Aditya P
Aditya P

Reputation: 1942

Moving a function in a running thread to a new thread?

I have a read and write function in a class file. this class subclasses QThread class and overrides run, does not have signals and slots ,It basically runs data processing functions in a thread. in its constructor is the method movetothread(this). To have the two functions to form a queue and implement muli-threading , can i make a movetothread(secondthread) call in the write function?

void write(args)
{
 movetothread(secondthread);
}

to make the write function run on a separate thread. How and when does the write function stop?.

Upvotes: 0

Views: 1106

Answers (1)

MSalters
MSalters

Reputation: 179917

It doesn't work that way. QObject::moveToThread associates the object with another thread, not the calling function. Furthermore, this affects future event processing only.

Upvotes: 1

Related Questions