Removed all unused files

This commit is contained in:
Netkas 2023-06-16 02:17:34 -04:00
parent 2b39a9df9e
commit 44b554d08c
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
6 changed files with 0 additions and 452 deletions

View file

@ -1,77 +0,0 @@
<?php
/** @noinspection PhpMissingFieldTypeInspection */
namespace TamerLib\Classes;
class AdaptiveSleep
{
/**
* @var int int
*/
private $max_sleep_time;
/**
* @var array
*/
private $busy_buffer;
/**
* @var int
*/
private $buffer_size;
/**
* @var int
*/
private $buffer_index;
/**
* AdaptiveSleep constructor.
*
* @param int $max_sleep_time
* @param int $buffer_size
*/
public function __construct(int $max_sleep_time=500, int $buffer_size=30)
{
$this->max_sleep_time = $max_sleep_time;
$this->busy_buffer = array_fill(0, $buffer_size, false); // Fill the buffer with false values (not busy
$this->buffer_size = $buffer_size;
$this->buffer_index = 0;
}
/**
* Preforms an adaptive sleep.
*
* @param bool $busy
* @return int
*/
public function sleep(bool $busy): int
{
// Add the busy state to the buffer
$this->busy_buffer[$this->buffer_index] = $busy;
$this->buffer_index = ($this->buffer_index + 1) % $this->buffer_size; // Circular buffer
// Calculate the average busy state
$busy_count = 0;
foreach($this->busy_buffer as $busy_state)
{
if($busy_state)
{
$busy_count++;
}
}
$busy_average = $busy_count / $this->buffer_size;
// Calculate the sleep time
$sleep_time = $this->max_sleep_time * (1 - $busy_average);
// Sleep
if($sleep_time > 0)
{
usleep($sleep_time);
}
return $sleep_time;
}
}

View file

@ -1,10 +0,0 @@
<?php
namespace TamerLib\Enums;
final class JobType
{
public const CLOSURE = 100;
public const FUNCTION = 200;
}

View file

@ -1,9 +0,0 @@
<?php
namespace TamerLib\Enums;
final class WorkerType
{
public const SCRIPT = 10;
public const CLOSURE = 20;
}