aaugustyniak/semithread

模拟线程环境的Nohup接口

1.0.0 2015-01-10 13:42 UTC

This package is not auto-updated.

Last update: 2024-09-14 15:47:39 UTC


README

Build Status

简单的API,用于启动非阻塞作业。

SemiThread

目前,这个功能仅在*nix系统下工作。它是nohup exec调用的简单包装API。

如果您想在进程中发送电子邮件(例如,不附加到请求/响应周期),那么它适合您。

安装

如果您还没有安装Composer,您应该现在安装它

  1. 将包添加到您的composer.json

     "require": {
       ...
       "aaugustyniak/semithread": "1.0.0",
       ...
     }
    
  2. 安装

     $ php composer.phar install
    
  3. 然后使用

首先,您必须提供您自己的实现

  • Aaugustyniak\SemiThread\Cloneable
  • Aaugustyniak\SemiThread\SemiThread

示例在Aaugustyniak\SemiThread\ExampleImpl中提供。

		<?php 
		
		require_once "vendor/autoload.php";
		
		$payload = new StringPayload("This is Payload");
        $envelope = new ConfinedEnvelope($payload);
        $thread = new WriterThread($envelope);
        /**
         * Optional, redirect jobs output to file 
         */ 
        $thread->setOutput('/some/path/semi_threads.out');
        $thread->start();
        echo "Main process output\n";
		...