正在显示
1 个修改的文件
包含
7 行增加
和
3 行删除
| @@ -185,7 +185,7 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | @@ -185,7 +185,7 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | ||
| 185 | 185 | ||
| 186 | // 开始同步 | 186 | // 开始同步 |
| 187 | try { | 187 | try { |
| 188 | - sync(); | 188 | + sync($worker_id); |
| 189 | }catch (\Throwable $e){ | 189 | }catch (\Throwable $e){ |
| 190 | _echo($e->getMessage()); | 190 | _echo($e->getMessage()); |
| 191 | logs( | 191 | logs( |
| @@ -210,12 +210,16 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | @@ -210,12 +210,16 @@ function create_coroutine(array &$cid,int &$isRunMaxCNum,$worker_id){ | ||
| 210 | 210 | ||
| 211 | /** | 211 | /** |
| 212 | * 开始同步, 这里是主要的业务代码 | 212 | * 开始同步, 这里是主要的业务代码 |
| 213 | + * @param int $worker_id 进程号 | ||
| 214 | + * @return int | ||
| 213 | * @author:dc | 215 | * @author:dc |
| 214 | - * @time 2023/2/13 9:42 | 216 | + * @time 2023/2/18 11:27 |
| 215 | */ | 217 | */ |
| 216 | -function sync(){ | 218 | +function sync($worker_id=0){ |
| 217 | // 需要同步的id | 219 | // 需要同步的id |
| 218 | $id = redis()->lPop('sync_email_lists'); | 220 | $id = redis()->lPop('sync_email_lists'); |
| 221 | + _echo($worker_id.': 协程('.co::getCid().'):抢到 '.$id); | ||
| 222 | + | ||
| 219 | if(!$id){ | 223 | if(!$id){ |
| 220 | co::sleep(1); | 224 | co::sleep(1); |
| 221 | return -1; | 225 | return -1; |
-
请 注册 或 登录 后发表评论