This is my first time using pthreads.
I have a Controller that runs multiple threads. Each thread will do lots of processing, and it will wait for a file to download. Later, it will save to a database.
Previously in the controller I used to get an instance of the database connection using:
public function getAppTable() {
if (!$this->appTable) {
$sm = $this->getServiceLocator();
$this->appTable = $sm->get('AppTable');
}
return $this->appTable;
}
However if I try to do this in my Thread
extending class, I'll get getServiceLocator
is not defined due to the fact that the class does not extend Controller. I cannot pass $this->appTable
to the Thread as PDO cannot be serialized or unserialized.
How can I get this to work?