开发者

Two loops simultaneously?

开发者 https://www.devze.com 2023-02-21 21:23 出处:网络
How would I run two loop do ... end simultaneously in Ruby? One would be for CLI interface and the other would开发者_如何转开发 be for background processing.Sounds like you want two threads.You can us

How would I run two loop do ... end simultaneously in Ruby? One would be for CLI interface and the other would开发者_如何转开发 be for background processing.


Sounds like you want two threads.


You can use yield to create co-routines

Generators like Ruby's can be 'abused' to create coroutines. I don't speak Ruby but I could outline the concept in C# or Python.

It also appears like something was added in Ruby 1.9 to make this easier

Cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消