Skip to content

Instantly share code, notes, and snippets.

View romainneutron's full-sized avatar

Romain Neutron romainneutron

View GitHub Profile
@clue
clue / StreamUnblock.php
Last active December 10, 2015 13:08
extend base React\Stream\Stream class by checking stream meta data for remaining stream buffer before reading from blocking streams
<?php
// extend base Stream class by checking stream meta data for remaining stream buffer before reading from blocking streams
// heavily inspired by: https://github.com/clue/Worker/commit/8c6d7a4e733f0ee5aa431ffda1d4929229ae2336
class StreamUnblock extends \React\Stream\Stream
{
public function handleData($stream)
{
// check stream meta data for remaining buffer
// yes, the manual explicitly says this value SHOULD NOT be used,
@avalanche123
avalanche123 / timeout.php
Created July 10, 2012 19:12
timeouts in php
<?php
class TimeoutException extends RuntimeException {}
class Timeout
{
private $active;
public function set($seconds)
{