fibers

Implementing a synchronization barrier in Ruby

喜欢而已 提交于 2019-11-30 13:27:21
I'm trying to "replicate" the behaviour of CUDA's __synchtreads() function in Ruby. Specifically, I have a set of N threads that need to execute some code, then all wait on each other at mid-point in execution before continuing with the rest of their business. For example: x = 0 a = Thread.new do x = 1 syncthreads() end b = Thread.new do syncthreads() # x should have been changed raise if x == 0 end [a,b].each { |t| t.join } What tools do I need to use to accomplish this? I tried using a global hash, and then sleeping until all the threads have set a flag indicating they're done with the first

Implementing a synchronization barrier in Ruby

雨燕双飞 提交于 2019-11-29 19:05:59
问题 I'm trying to "replicate" the behaviour of CUDA's __synchtreads() function in Ruby. Specifically, I have a set of N threads that need to execute some code, then all wait on each other at mid-point in execution before continuing with the rest of their business. For example: x = 0 a = Thread.new do x = 1 syncthreads() end b = Thread.new do syncthreads() # x should have been changed raise if x == 0 end [a,b].each { |t| t.join } What tools do I need to use to accomplish this? I tried using a

Which would be better for concurrent tasks on node.js? Fibers? Web-workers? or Threads?

一曲冷凌霜 提交于 2019-11-26 16:47:06
I stumbled over node.js sometime ago and like it a lot. But soon I found out that it lacked badly the ability to perform CPU-intensive tasks. So, I started googling and got these answers to solve the problem: Fibers, Webworkers and Threads (thread-a-gogo). Now which one to use is a confusion and one of them definitely needs to be used - afterall what's the purpose of having a server which is just good at IO and nothing else? Suggestions needed! UPDATE: I was thinking of a way off-late; just needing suggestions over it. Now, what I thought of was this: Let's have some threads (using thread_a

Which would be better for concurrent tasks on node.js? Fibers? Web-workers? or Threads?

Deadly 提交于 2019-11-26 04:56:48
问题 I stumbled over node.js sometime ago and like it a lot. But soon I found out that it lacked badly the ability to perform CPU-intensive tasks. So, I started googling and got these answers to solve the problem: Fibers, Webworkers and Threads (thread-a-gogo). Now which one to use is a confusion and one of them definitely needs to be used - afterall what\'s the purpose of having a server which is just good at IO and nothing else? Suggestions needed! UPDATE: I was thinking of a way off-late; just