• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jdantonio / concurrent-ruby / #698

19 May 2014 09:15AM UTC coverage: 92.507% (-5.0%) from 97.516%
#698

push

mighe
Changed every mutex.lock - mutex.unlock pair to ensure mutex release even with errors
closes #79

64 of 64 new or added lines in 12 files covered. (100.0%)

129 existing lines in 11 files now uncovered.

2358 of 2549 relevant lines covered (92.51%)

601.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/lib/concurrent/executor/thread_pool_executor.rb
1
require 'concurrent/executor/ruby_thread_pool_executor'
1✔
2

3
module Concurrent
1✔
4

5
  if RUBY_PLATFORM == 'java'
1✔
UNCOV
6
    require 'concurrent/executor/java_thread_pool_executor'
×
7
    # @!macro [attach] thread_pool_executor
8
    #
9
    #   An abstraction composed of one or more threads and a task queue. Tasks
10
    #   (blocks or `proc` objects) are submit to the pool and added to the queue.
11
    #   The threads in the pool remove the tasks and execute them in the order
12
    #   they were received. When there are more tasks queued than there are
13
    #   threads to execute them the pool will create new threads, up to the
14
    #   configured maximum. Similarly, threads that are idle for too long will
15
    #   be garbage collected, down to the configured minimum options. Should a
16
    #   thread crash it, too, will be garbage collected.
17
    #
18
    #   `ThreadPoolExecutor` is based on the Java class of the same name. From
19
    #   the official Java documentationa;
20
    #
21
    #   > Thread pools address two different problems: they usually provide
22
    #   > improved performance when executing large numbers of asynchronous tasks,
23
    #   > due to reduced per-task invocation overhead, and they provide a means
24
    #   > of bounding and managing the resources, including threads, consumed
25
    #   > when executing a collection of tasks. Each ThreadPoolExecutor also
26
    #   > maintains some basic statistics, such as the number of completed tasks.
27
    #   >
28
    #   > To be useful across a wide range of contexts, this class provides many
29
    #   > adjustable parameters and extensibility hooks. However, programmers are
30
    #   > urged to use the more convenient Executors factory methods
31
    #   > [CachedThreadPool] (unbounded thread pool, with automatic thread reclamation),
32
    #   > [FixedThreadPool] (fixed size thread pool) and [SingleThreadExecutor] (single
33
    #   > background thread), that preconfigure settings for the most common usage
34
    #   > scenarios.
35
    #
36
    #   Thread pools support several configuration options:
37
    #
38
    #   * `max_threads`: The maximum number of threads that may be created in the pool.
39
    #   * `min_threads`: The minimum number of threads that may be retained in the pool.
40
    #   * `idletime`: The number of seconds that a thread may be idle before being reclaimed.
41
    #   * `max_queue`: The maximum number of tasks that may be waiting in the work queue at
42
    #     any one time. When the queue size reaches `max_queue` subsequent tasks will be
43
    #     rejected in accordance with the configured `overflow_policy`.
44
    #   * `overflow_policy`: The policy defining how rejected tasks are handled.    #
45
    #
46
    #   Three overflow policies are supported:
47
    #
48
    #   * `:abort`: Raise a `RejectedExecutionError` exception and discard the task.
49
    #   * `:discard`: Silently discard the task and return `nil` as the task result.
50
    #   * `:caller_runs`: Execute the task on the calling thread.
51
    #
52
    #   @note When running on the JVM (JRuby) this class will inherit from `JavaThreadPoolExecutor`.
53
    #     On all other platforms it will inherit from `RubyThreadPoolExecutor`.
54
    #
55
    #   @see Concurrent::RubyThreadPoolExecutor
56
    #   @see Concurrent::JavaThreadPoolExecutor
57
    #
58
    #   @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
59
    #   @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
60
    #   @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html
UNCOV
61
    class ThreadPoolExecutor < JavaThreadPoolExecutor
×
62
    end
63
  else
64
    # @!macro thread_pool_executor
65
    class ThreadPoolExecutor < RubyThreadPoolExecutor
1✔
66
    end
67
  end
68
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc