jacknoordhuis/threaded-class-loader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jacknoordhuis/threaded-class-loader

Composer 安装命令:

composer require jacknoordhuis/threaded-class-loader

包简介

A thread safe implementation of a PSR-0, PSR-4 and classmap class loader for use with the pthreads extension.

README 文档

README

A thread safe implementation of a PSR-0, PSR-4 and classmap class loader for use with the pthreads extension!

Build Status

The core advantage of having a central thread safe class loader is that new classes can be registered to the loader, on any thread, and when PHP tries to load the class from any thread the loader is also registered on, everything will 'just work' as they shared \Threaded objects.

Installation

Composer

Via command line:

$ composer require jacknoordhuis/threaded-class-loader

Or add the package to your composer.json:

{
    "require": {
        "jacknoordhuis/threaded-class-loader": "*"
    }
}

Usage

Here is a basic example of replacing the default composer class loader:

$loader = require_once "vendor/autoload.php";
$loader = jacknoordhuis\Autoload\ThreadedClassLoader::fromComposerLoader($loader);

This example will load the composer autoloader so that our threaded loader can be loaded, then we call the helper method which conveniently handles converting composers mappings to \Threaded members. Depending on the extra arguments provided the helper method will also (by default) unregister the composer loader and register the new thread safe loader on the current thread.

You can now safely pass the $loader to a new thread and call the ThreadedClassLoader::register() method to load the classes on the new thread.

$loader = ...; //put example code from above here

class MyWorker extends \Worker {

	public $loader;

	public function __construct($loader) {
		$this->loader = $loader;
	}

	public function run() {
		$this->loader->register();

		//put your code here
	}
}

$worker = new MyWorker($loader);
$worker->start() && $worker->join();

__The content of this repo is licensed under the GNU Lesser General Public License v3. A full copy of the license is available [here](LICENSE).__

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0
  • 更新时间: 2019-01-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固