$black_key = "black"; $settler_key = "settler"; if (!($forum_id = $redis->GET("{$black_key}:{$alliance_key}:forum:id"))) { $forum_id = $bot->forum->get_forum_id_by_name(BOT_BLACK_FORUM, true); $redis->SET("{$black_key}:{$alliance_key}:forum:id", $forum_id); } sort($continents); if (is_array($continents) && $bot->forum->exist_forum_id($forum_id)) { # if (is_array($continents) && $forum_id) { $executeThread = array(); $childs = array_chunk($continents, MAXCHILDS, true); $bot->log("Fork: starting fork " . count($childs) . " childs!"); foreach ($childs as $c_id => $c_continents) { // define child #$bot->lou->check(); $thread = new executeThread("{$black_key}Thread-" . $c_id); $thread->worker = function ($_this, $bot, $continents, $forum_id) { global $_black_user_points, $_black_user_state, $_black_user_last; // working child $error = 0; $redis = RedisWrapper::getInstance(); $last_update = $redis->SMEMBERS('stats:ContinentPlayerUpdate'); sort($last_update); $last_update = end($last_update); $alliance_key = "alliance:{$bot->ally_id}"; $black_key = "black"; $settler_key = "settler"; $inactive_chunks = 30; $str_time = (string) time(); $bot->log("Fork: " . $_this->getName() . ": start"); foreach ($continents as $continent) {
public function add_thread_event($events, $command, $name, $function) { if (!is_array($events)) { $events = array($events); } foreach ($events as $event) { if (!empty($event)) { $this->events[$event][md5($name)] = executeThread::factory(trim($command), $function); } } }
<?php include_once 'thread/Thread.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <?php for ($index = 1; $index < 5; $index++) { $a = time(); echo "<br>----->thread:{$index} time: {$a}"; $thread = new executeThread("hilo numero -> " . $index); $thread->start(); //$thread->run(); echo "<br> <-----------thread:{$index} diff" . time() - $a; } for ($i = 1; $i < 5; $i++) { echo $i . "\n"; } ?> </body> </html>