1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 13:21:16 +01:00
amp/lib/Loop/Factory.php

26 lines
477 B
PHP
Raw Normal View History

<?php
namespace Amp\Loop;
class Factory {
/**
* Creates a new loop instance and chooses the best available driver.
*
* @return Driver
*/
public function create(): Driver {
if (UvLoop::supported()) {
return new UvLoop;
}
if (EvLoop::supported()) {
return new EvLoop;
}
if (EventLoop::supported()) {
return new EventLoop;
}
return new NativeLoop;
}
}