非协程特性独立扩展 (swoole_async)

4.3版本开始我们逐渐开始移除与协程无关的模块,包括异步客户端、消息队列等。

考虑到Swoole-1.x版本目前依然有大量用户使用,因此移除模块会转到另外一个混杂扩展(swoole_async)中进行维护。

模块列表

  • 异步文件IO,如swoole_async_read
  • 异步Http/WebSocket客户端
  • 异步Redis客户端
  • 异步MySQL客户端
  • swoole_msgqueue
  • swoole_memory_pool
  • swoole_ringqueue
  • swoole_mmap
  • swoole_channel

扩展编译

git clone https://github.com/swoole/async-ext.git
cd async-src
phpize
./confiugre
make -j 4
sudo make install
  • 编译将生成swoole_async.so新扩展
  • 此扩展依赖swoole.so扩展,必须先加载swoole.so再加载swoole_async.so

配置文件

修改php.ini加载扩展。

extension=swoole.so
extension=swoole_async.so

可以通过php -m看到swooleswoole_async两个扩展。



  • 斯内克

    make的时候 有6个error /home/wangzilong/async-ext/swoole_async.cc:186:25: error: ‘swoole_async’ was not declared in this scope SW_INIT_CLASS_ENTRY(swoole_async, "Swoole\Async", "swoole_async", NULL, swoole_async_methods); ^ /home/wangzilong/async-ext/swoole_async.cc:186:98: error: ‘SW_INIT_CLASS_ENTRY’ was not declared in this scope SW_INIT_CLASS_ENTRY(swoole_async, "Swoole\Async", "swoole_async", NULL, swoole_async_methods); ^ /home/wangzilong/async-ext/swoole_async.cc:187:99: error: ‘SW_SET_CLASS_SERIALIZABLE’ was not declared in this scope SW_SET_CLASS_SERIALIZABLE(swoole_async, zend_class_serialize_deny, zend_class_unserialize_deny); ^ /home/wangzilong/async-ext/swoole_async.cc:188:63: error: ‘SW_SET_CLASS_CLONEABLE’ was not declared in this scope SW_SET_CLASS_CLONEABLE(swoole_async, zend_class_clone_deny); ^ /home/wangzilong/async-ext/swoole_async.cc:189:85: error: ‘SW_SET_CLASS_UNSET_PROPERTY_HANDLER’ was not declared in this scope SW_SET_CLASS_UNSET_PROPERTY_HANDLER(swoole_async, zend_class_unset_property_deny);

    看不懂啊

  • 斯内克

    make的时候 有6个error /home/wangzilong/async-ext/swoole_async.cc:186:25: error: ‘swoole_async’ was not declared in this scope SW_INIT_CLASS_ENTRY(swoole_async, "Swoole\Async", "swoole_async", NULL, swoole_async_methods); ^ /home/wangzilong/async-ext/swoole_async.cc:186:98: error: ‘SW_INIT_CLASS_ENTRY’ was not declared in this scope SW_INIT_CLASS_ENTRY(swoole_async, "Swoole\Async", "swoole_async", NULL, swoole_async_methods); ^ /home/wangzilong/async-ext/swoole_async.cc:187:99: error: ‘SW_SET_CLASS_SERIALIZABLE’ was not declared in this scope SW_SET_CLASS_SERIALIZABLE(swoole_async, zend_class_serialize_deny, zend_class_unserialize_deny); ^ /home/wangzilong/async-ext/swoole_async.cc:188:63: error: ‘SW_SET_CLASS_CLONEABLE’ was not declared in this scope SW_SET_CLASS_CLONEABLE(swoole_async, zend_class_clone_deny); ^ /home/wangzilong/async-ext/swoole_async.cc:189:85: error: ‘SW_SET_CLASS_UNSET_PROPERTY_HANDLER’ was not declared in this scope SW_SET_CLASS_UNSET_PROPERTY_HANDLER(swoole_async, zend_class_unset_property_deny);

    看不懂啊

  • 丶蓬蒿人

    我去 一堆error 一堆warning 还是用4.2吧

  • 逝水无痕

    64位这样编译 CFLAGS="-O3 -fPIC" ./configure