Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well here's a pthreads example that will allow you to multi-thread your operations ... I have chosen the worker model and am using 8 workers, how many workers you use depends on your hardware and the service receiving the requests ... I've never used SEOstats or godaddy domain auctions, I'm not sure of the CSV fields and will leave the getting of page ranks to you ...</p> <pre><code>&lt;?php define ("CSV", "https://auctions.godaddy.com/trpSearchResults.aspx?t=12&amp;action=export"); /* I have no idea how to get the actual page rank */ function get_page_rank($domain) { return rand(1,10); } class Ranking extends Worker { public function run(){} } class Domain extends Stackable { public $auction; public $name; public $bids; public $traffic; public $valuation; public $price; public $ending; public $type; public $ranking; public function __construct($csv) { $this-&gt;auction = $csv[0]; $this-&gt;name = $csv[1]; $this-&gt;traffic = $csv[2]; $this-&gt;bids = $csv[3]; $this-&gt;price = $csv[5]; $this-&gt;valuation = $csv[4]; $this-&gt;ending = $csv[6]; $this-&gt;type = $csv[7]; } public function run() { /* we convert the time to a stamp here to keep the main thread moving */ $this-&gt;ending = strtotime( $this-&gt;ending); $this-&gt;ranking = get_page_rank($this-&gt;name); /* now write the Domain to database or whatever */ } } /* start some workers */ $workers = array(); while (@$worker++ &lt; 8) { $workers[$worker] = new Ranking(); $workers[$worker]-&gt;start(); } /* open the CSV and start processing */ $handle = fopen(CSV, "r"); $domains = array(); while (($line = fgetcsv($handle))) { $domains[$line[0]] = new Domain($line); $workers[array_rand($workers)]-&gt;stack( $domains[$line[0]]); } /* cleanup handle to csv */ fclose($handle); /* shutdown all workers (forcing all processing to finish) */ foreach ($workers as $worker) $worker-&gt;shutdown(); /* we now have ranked domains in memory and database */ var_dump($domains); var_dump(count($domains)); ?&gt; </code></pre> <p>Questions:</p> <ol> <li>Right, 8 workers</li> <li>Workers execute Stackable objects in the order they were stack()'d, this line chooses a random worker to execute the Stackable</li> <li>You can traverse the list of $domains in the main process during execution, checking the status of each Stackable as you are executing</li> <li>All of each workers stack will be executed before the shutdown takes place, the shutdown ensures that all work is therefore done by that point in the execution of the script.</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload