messages on the WebSocket connections. Type of messages and amount of messages depend on the application. If we want to send a big message in split chunk. Number of chunks may be 10 thousands. Can we create threads per messages? They will spent huge amount of memory.
queue = Queue.new async_func do |r| # --- in sub thread --- queue.push r # --- in sub thread --- end # Wait to `queue.push` from other threads. result = queue.pop # Resume next code when `queue.push` is called. expect(result).not_to eq('expected answer') end