function mutex($id, $func, $args = NULL)
{
if (!is_dir($tmp = $this->hive['TEMP'])) {
mkdir($tmp, self::MODE, TRUE);
}
// Use filesystem lock
if (is_file($lock = $tmp . $this->get('SEED') . '.' . $this->hash($id) . '.lock') && filemtime($lock) + ini_get('max_execution_time') < microtime(TRUE)) {
// Stale lock
@unlink($lock);
}
while (!($handle = @fopen($lock, 'x')) && !connection_aborted()) {
usleep(mt_rand(0, 100));
}
$out = $this->call($func, $args);
fclose($handle);
@unlink($lock);
return $out;
}