以下是我的场景,
- 我使用 Ruby FFI 从 Ruby 调用名为“subscribe”的 ac 函数
- 子函数在while循环中无限运行
- 我需要一种方法来停止从 Ruby 订阅此订阅(需要停止无限运行的 c 函数)
红宝石
require 'ffi'
module Queue
extend FFI::Library
ffi_lib FFI::Library::LIBC
attach_function :subscribe, [ :void], :void
end
Thread.new { Queue.subscribe() }
c程序
int subscribe(){
while(true){
//Do Stuff
}
}
有什么想法吗?有没有更好的方法来管理这个?