Jump to content

Vadimbr

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vadimbr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I try to explain what I'm doing to make it more clear. I'm extracting data from a web site. The data I want arranged under "center_tabOpBody_XX" tags and each tag contains up to 15 elements. Meaning: center_tabOpBody_0 contains 10 elements center_tabOpBody_1 contains 3 elements and so on... I can get only 15 elements per one ip before it get black listed so I need to arrange "center_tabOpBody_XX" in groups up to 15 elements total per group and then parse those groups individually, one proxy per group.
  2. Ok, Let say I have a bunch of numbers and I want to sort them in groups of up to 15. Those numbers: 1,5,8,10,8,3 Result in: 1) 5,10 2) 8,1,3 3)8
  3. Hi, I need to sort variables in groups of up to 15 and put it in an array. For example: $exstract['center_tabOpBody_0'] =5 $exstract['center_tabOpBody_1'] =6 $exstract['center_tabOpBody_2'] =8 $exstract['center_tabOpBody_3'] =1 Should yield: ARRAY( [0] = center_tabOpBody_1,center_tabOpBody_2,center_tabOpBody_3 // <-----15 [1] = center_tabOpBody_0 //<----5 ) Is there some simple function do do the "efficiency" sort? Thanks, Vadim
  4. What happens if I want to open 10000 threads? Is there some variable assignment to do it?
  5. It worked. Thanks. Stupid brackets. But now the $joinPoint = new Threadi_JoinPoint($thread); gives me an error, it's expecting list of variables separated by commas.
  6. Hi, I'm trying to implement multithreading using Threadi https://github.com/danielpoe/Threadi Here is a sample code to what I'm trying to do: require_once(dirname(__FILE__).'/../Loader.php'); class Worker { public function fetchAWebsite($url) { $content = file_get_contents($url); return "fetched website $url - lenght ".strlen($content).PHP_EOL; } } $worker = new Worker(); $startTime = microtime(TRUE); $thread1 = Threadi_ThreadFactory::getReturnableThread(array($worker,'fetchAWebsite')); $thread1->start('http://www.google.de'); $thread2 = Threadi_ThreadFactory::getReturnableThread(array($worker,'fetchAWebsite')); $thread2->start('http://www.aoemedia.de'); $joinPoint = new Threadi_JoinPoint($thread1, $thread2); $joinPoint->waitTillReady(); echo $thread1->getResult(); echo $thread2->getResult(); echo "Time needed in seconds: ". ( microtime(TRUE)-$startTime).PHP_EOL; The problem that I'm having is that I need to call each thread separately by name. Creating 10 or more threads makes a lot redundant code. How can I assign Threadi_ThreadFactory::getReturnableThread to an indexed variable(array) ? I tried something in this lines but with no success: $hArr = array();//handle array for ($i=0;$i<THREADS;$i++) { $thread[$i] = Threadi_ThreadFactory::getReturnableThread(array($worker,'fetchAWebsite')); $thread[$i]->start($site[$i]); array_push($hArr,$thread[$i]-); } $joinPoint = new Threadi_JoinPoint($hArr); $joinPoint->waitTillReady(); What I'm doing wrong? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.