Replies: 3 comments
-
Some follow-up info from compiling. With --enable-thread-context during compile it throws "thread context cannot be used with ZTS". Removing ZTS then throws "swoole thread must be used with ZTS". PHP 8.3.7 and latest from swoole-src on latest Fedora. UPDATE: The only combo that worked was with ZTS and without thread-context. However strangeness continues:
Produces:
When trying to the use Swoole\Timer, it appears it's either the timer or a websocket stream, but not both concurrently. So far separate threads and even processes don't really work when trying to calc on the combined data. About the only thing I haven't tried is sockets/TCP server to fire off calcs. Thanks, Hans |
Beta Was this translation helpful? Give feedback.
-
Try using Swoole\Table to share data. |
Beta Was this translation helpful? Give feedback.
-
Hi - I've been using queues to avoid data sync but I'll take another look at tables. Though maybe the issue a little deeper - from the example
Results in:
This is a build of the latest swoole/php releases.
Any thoughts much appreciated, best, Hans And strace tail-end
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I have a few async things running: websocket stream, local event trigger (clock based), and calculations based on those.
Calculations are often kicked off on a time basis, so I've been working with Timer. However, it seems that it's finicky when it comes to running concurrently with other things. I've tried:
And various combinations of the above. Ideally I need the websocket/calculation processing to happen concurrently, with the timer performing a callback on said data. I've tried channels, shared variables, various combinations, yet the general problem is that I can't share a variable between the timer and main thread (or spawned coroutine or thread) while having both run concurrently.
It seems that either the timer runs, or the websocket stream runs, but not both, and not in a way that I can bounce data around (like reset counters on a timed basis).
Any thoughts/rules for where to place timers, ie. what they can't run alongside of concurrently? Ideally, I'd like to have a channel coming off the websocket (or thread queue) and be able to add timers as needed, such as:
timer::tick(100,function() use ($cnt) { $cnt = 0; });
while( $t = $chan->pop() )
{
if( $t[0] === 'P' )
++$cnt;
}
Thank you!
Hans
Beta Was this translation helpful? Give feedback.
All reactions