简体   繁体   English

HHVM:pthreads PHP类

[英]HHVM: pthreads PHP classes

The installation of pthreads in PHP (for the use of Threaded, Thread, Worker, Pool, etc) is quite "complex" and that's not very pratical when you use packages of your Linux ditribution that doesn't have ZTS enabled (you have to download PHP sources and compile them — auxiliary question : why ZTS isn't activated by default?). 在PHP中安装pthreads(用于使用Threaded,Thread,Worker,Pool等)非常“复杂”,当你使用没有启用ZTS的Linux ditribution软件包时,这不是很实用(你必须下载PHP源代码并编译它们 - 辅助问题:为什么默认情况下不激活ZTS?)。

Few days ago I tested HHVM for the first time and the performance is just... impressive. 几天前我第一次测试了HHVM,性能只是......令人印象深刻。 I'm writing a kind of server in PHP and I need threads. 我正在用PHP编写一种服务器,我需要线程。 I thought that HHVM support them natively. 我认为HHVM原生支持它们。 That's not the case (unknown class). 事实并非如此(未知类)。

I can find documentation on pthreads on HHVM documentation, but that's the official PHP docs. 我可以在HHVM文档上找到有关pthreads的文档,但那是官方的PHP文档。 I read somewhere on the Internet that HHVM doesn't support Threads. 我在互联网上的某处读到HHVM不支持Threads。

So... if threads are supported in HHVM, how to install pthreads on HHVM? 那么......如果HHVM支持线程,如何在HHVM上安装pthread? What about ZTS? ZTS怎么样?

ZTS is a prerequisite of pthreads. ZTS是pthreads的先决条件。

ZTS is not used as the default because ZTS mode has some overhead associated with it. ZTS不用作默认值,因为ZTS模式有一些与之相关的开销。

The HHVM documentation is just a clone of the php-doc repository, restyled, with some additional sections added for HHVM, this is why the pthreads documentation shows up in HHVM docs. HHVM文档只是php-doc存储库的一个副本,已经重新设计,并为HHVM添加了一些额外的部分,这就是为什么pthreads文档出现在HHVM文档中的原因。

HHVM does not and will not support pthreads, or at least, I won't be supporting it, and I wrote pthreads. HHVM不会也不会支持pthread,或者至少,我不会支持它,我写了pthreads。

HHVM does support concurrency through asynchronous programming, arguably this fits the use case of writing a server better than parallelism: http://docs.hhvm.com/manual/en/hack.async.php HHVM确实通过异步编程支持并发,可以说这适合编写服务器比并行性更好的用例: http//docs.hhvm.com/manual/en/hack.async.php

I have no idea how good that is, the documentation calls it "basic support". 我不知道它有多好,文档称之为“基本支持”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM