GithubHelp home page GithubHelp logo

Comments (6)

krakjoe avatar krakjoe commented on August 15, 2024

snapshots waiting for testing @ http://pthreads.org/snapshots

from pthreads.

chibisuke avatar chibisuke commented on August 15, 2024

Thx for trying to fix this, unfortunately the fix seams to be incomplete in 2e4f64b

The following example still fails in the same way.

<?php
class Work extends Stackable {
public function run(){

}
}

class Test extends Thread {
public function run(){
$test = new Work();
$this->test = $test;
print_r($this->test);
var_dump($this->test);
$stream = fopen("d:\\test.txt", "w+");
var_dump($stream);
$this->stream = $stream;
fwrite($this->stream, "test");
fwrite($this->stream, "test");
fwrite($this->stream, "test");
var_dump($this->stream);
}
}

$test =new Test();
$test->start();
?>

from pthreads.

krakjoe avatar krakjoe commented on August 15, 2024

:)

from pthreads.

torstahl avatar torstahl commented on August 15, 2024

Helllo

i have the same Problem on php5-5.4.20 with pthreads 2.0.10

class Joy {
public $device = '/tmp/test.txt';
public $stream;

public function __construct()
{
}

public function open()
{
    $this->stream = fopen($this->device,'rb');
    stream_set_blocking ($this->stream,0);
    var_dump($this->stream);
} // end function open

public function read()
{
    var_dump($this->stream);
    echo $line = stream_get_contents($this->stream,8)."\n";
}

/**
 *
 */
public function close()
{
    fclose($this->stream);
} // end function close

}

class Test extends Thread {

private $xr;

public function run()
{
    // works
    $joystick = new Joy();
    $joystick->open();
    $joystick->read();
    $joystick->close();

    // don't work
    $this->xr = new Joy();
    $this->xr->open();
    $this->xr->read();
    $this->xr->close();

}
}

$test =new Test();
$test->start();

stream is NULL when using this.

Best Regards
Torsten

from pthreads.

rdlowrey avatar rdlowrey commented on August 15, 2024

In passing I noticed the examples here are messing with blocking flags on filesystem resources. As a public service announcement:

Setting non-blocking mode on a filesystem resource will have no effect. It's a waste of time whether or not you're using pthreads.

Here's a good read on the subject:

http://www.remlab.net/op/nonblock.shtml

from pthreads.

torstahl avatar torstahl commented on August 15, 2024

Hello
i use this to read from a joystick device /dev/input/js0
so for the report the stream_set_blocking is not necessary.

BR/Torsten

from pthreads.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.