RakLib: split PthreadsChannelWriter into two implementations

this gains a very small performance improvement by avoiding unnecessary !== null checks on every packet written in either direction. It's insignificant for sure, but I just found this code in an old stash, so what the heck.
This commit is contained in:
Dylan K. Taylor
2021-07-22 18:52:58 +01:00
parent 5c609cc1c1
commit 832a156fc7
3 changed files with 44 additions and 8 deletions

View File

@ -23,18 +23,12 @@ use raklib\server\ipc\InterThreadChannelWriter;
final class PthreadsChannelWriter implements InterThreadChannelWriter{
/** @var \Threaded */
private $buffer;
/** @var SleeperNotifier|null */
private $notifier;
public function __construct(\Threaded $buffer, ?SleeperNotifier $notifier = null){
public function __construct(\Threaded $buffer){
$this->buffer = $buffer;
$this->notifier = $notifier;
}
public function write(string $str) : void{
$this->buffer[] = $str;
if($this->notifier !== null){
$this->notifier->wakeupSleeper();
}
}
}