Multithreading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tormod Fjeldskår

    Multithreading

    I need a cross-platform way to execute PHP-scripts in multiple threads.
    The only way I can think of is to exploit the webserver this way:

    1. Store the thread's code in a separate script (e.g. thread.php)
    2. Put ignore_user_abo rt(true) in this script
    3. Make a HTTP request for thread.php to the webserver
    4. Close the connection immediately
    5. Continue in my initial script

    Is this the most convenient way of solving the problem, or does anyone
    have better solutions for this problem?

    --
    Tormod Fjeldskår
    tormod@fritidsp roblemer.no

  • Chung Leong

    #2
    Re: Multithreading

    Can't think of anything better. You might want to keep the connection in
    your initial script, since Apache would send a SIG_KILL to PHP, running as
    CGI, when the connection gets dropped. Thread.php can use the connection as
    a way to communicate its progress back to the initial script. Something like
    this:

    $thread = fopen("http://localhost/thread.php", "r");
    while($s = fgets($thread, 1024)) {
    // do some reporting
    }
    // thread.php is done

    Uzytkownik "Tormod Fjeldskår" <to-fje@online.no> napisal w wiadomosci
    news:lZlzb.3351 $Y06.59986@news 4.e.nsc.no...[color=blue]
    > I need a cross-platform way to execute PHP-scripts in multiple threads.
    > The only way I can think of is to exploit the webserver this way:
    >
    > 1. Store the thread's code in a separate script (e.g. thread.php)
    > 2. Put ignore_user_abo rt(true) in this script
    > 3. Make a HTTP request for thread.php to the webserver
    > 4. Close the connection immediately
    > 5. Continue in my initial script
    >
    > Is this the most convenient way of solving the problem, or does anyone
    > have better solutions for this problem?
    >
    > --
    > Tormod Fjeldskår
    > tormod@fritidsp roblemer.no
    > http://tormod.fritidsproblemer.no/[/color]


    Comment

    Working...