push
2186 of 2818 relevant lines covered (77.57%)
527.3 hits per line
| 1 |
module Concurrent |
1✔ |
| 2 |
|
|
| 3 |
class PerThreadExecutor |
1✔ |
| 4 |
include Executor
|
1✔ |
| 5 |
|
|
| 6 |
def self.post(*args) |
1✔ |
| 7 |
raise ArgumentError.new('no block given') unless block_given? |
1,365✔ |
| 8 |
Thread.new(*args) do |
1,365✔ |
| 9 |
Thread.current.abort_on_exception = false |
1,331✔ |
| 10 |
yield(*args)
|
1,331✔ |
| 11 |
end
|
|
| 12 |
return true |
1,365✔ |
| 13 |
end
|
|
| 14 |
|
|
| 15 |
def post(*args, &task) |
1✔ |
| 16 |
return PerThreadExecutor.post(*args, &task) |
1,365✔ |
| 17 |
end
|
|
| 18 |
|
|
| 19 |
def <<(task) |
1✔ |
| 20 |
PerThreadExecutor.post(&task)
|
× |
| 21 |
return self |
× |
| 22 |
end
|
|
| 23 |
end
|
|
| 24 |
end
|