Skip to content

Commit e2ffdb5

Browse files
committed
Updated YARD to support Markdown.
1 parent 7f05c78 commit e2ffdb5

27 files changed

+263
-262
lines changed

.yardopts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--protected --private --embed-mixins --output-dir ./doc --markup markdown

lib/concurrent/actor_context.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ module Concurrent
1515
#
1616
# The actor framework in this library is heavily influenced by the Akka toolkit,
1717
# with additional inspiration from Erlang and Scala. Unlike many of the abstractions
18-
# in this library, +ActorContext+ takes an *object-oriented* approach to asynchronous
18+
# in this library, `ActorContext` takes an *object-oriented* approach to asynchronous
1919
# concurrency, rather than a *functional programming* approach.
2020
#
21-
# Creating an actor class is achieved by including the +ActorContext+ module
22-
# within a standard Ruby class. One +ActorContext+ is mixed in, however, everything
23-
# changes. Objects of the class can no longer be instanced with the +#new+ method.
24-
# Instead, the various factor methods, such as +#spawn+, must be used. These factory
21+
# Creating an actor class is achieved by including the `ActorContext` module
22+
# within a standard Ruby class. One `ActorContext` is mixed in, however, everything
23+
# changes. Objects of the class can no longer be instanced with the `#new` method.
24+
# Instead, the various factor methods, such as `#spawn`, must be used. These factory
2525
# methods do not return direct references to the actor object. Instead they return
26-
# objects of one of the +ActorRef+ subclasses. The +ActorRef+ objects encapsulate
26+
# objects of one of the `ActorRef` subclasses. The `ActorRef` objects encapsulate
2727
# actor objects. This encapsulation is necessary to prevent synchronous method calls
2828
# froom being made against the actors. It also allows the messaging and lifecycle
29-
# behavior to be implemented within the +ActorRef+ subclasses, allowing for better
29+
# behavior to be implemented within the `ActorRef` subclasses, allowing for better
3030
# separation of responsibility.
3131
#
3232
# @see Concurrent::ActorRef
@@ -36,19 +36,19 @@ module Concurrent
3636
# @see http://www.scala-lang.org/api/current/index.html#scala.actors.Actor
3737
module ActorContext
3838

39-
# Callback method called by the +ActorRef+ which encapsulates the actor instance.
39+
# Callback method called by the `ActorRef` which encapsulates the actor instance.
4040
def on_start
4141
end
4242

43-
# Callback method called by the +ActorRef+ which encapsulates the actor instance.
43+
# Callback method called by the `ActorRef` which encapsulates the actor instance.
4444
def on_reset
4545
end
4646

47-
# Callback method called by the +ActorRef+ which encapsulates the actor instance.
47+
# Callback method called by the `ActorRef` which encapsulates the actor instance.
4848
def on_shutdown
4949
end
5050

51-
# Callback method called by the +ActorRef+ which encapsulates the actor instance.
51+
# Callback method called by the `ActorRef` which encapsulates the actor instance.
5252
#
5353
# @param [Time] time the date/time at which the error occurred
5454
# @param [Array] message the message that caused the error
@@ -65,9 +65,9 @@ class << base
6565
# Should the thread ever die it will be restarted the next time a message is post.
6666
#
6767
# @param [Hash] opts the options defining actor behavior
68-
# @option opts [Array] :args (+nil+) arguments to be passed to the actor constructor
68+
# @option opts [Array] :args (`nil`) arguments to be passed to the actor constructor
6969
#
70-
# @return [SimpleActorRef] the +ActorRef+ encapsulating the actor
70+
# @return [SimpleActorRef] the `ActorRef` encapsulating the actor
7171
def spawn(opts = {})
7272
args = opts.fetch(:args, [])
7373
Concurrent::SimpleActorRef.new(self.new(*args), opts)

lib/concurrent/actor_ref.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Concurrent
44

5-
# Base class for classes that encapsulate +ActorContext+ objects.
5+
# Base class for classes that encapsulate `ActorContext` objects.
66
#
77
# @see Concurrent::ActorContext
88
module ActorRef
@@ -20,8 +20,8 @@ module ActorRef
2020
#
2121
# @yield a callback operation to be performed when the operation is complete.
2222
# @yieldparam [Time] time the date/time at which the error occurred
23-
# @yieldparam [Object] result the result of message processing or +nil+ on error
24-
# @yieldparam [Exception] exception the exception object that was raised or +nil+ on success
23+
# @yieldparam [Object] result the result of message processing or `nil` on error
24+
# @yieldparam [Exception] exception the exception object that was raised or `nil` on success
2525
#
2626
# @return [IVar] a future that will eventually contain the result of message processing
2727

@@ -39,21 +39,21 @@ module ActorRef
3939

4040
# @!method running?()
4141
# Is the actor running and processing messages?
42-
# @return [Boolean] +true+ if running else +false+
42+
# @return [Boolean] `true` if running else `false`
4343

4444
# @!method shutdown?()
4545
# Is the actor shutdown and no longer processing messages?
46-
# @return [Boolean] +true+ if shutdown else +false+
46+
# @return [Boolean] `true` if shutdown else `false`
4747

4848
# @!method shutdown()
4949
# Shutdown the actor, gracefully exit all threads, and stop processing messages.
50-
# @return [Boolean] +true+ if shutdown is successful else +false+
50+
# @return [Boolean] `true` if shutdown is successful else `false`
5151

5252
# @!method join(limit = nil)
5353
# Suspend the current thread until the actor has been shutdown
5454
# @param [Integer] limit the maximum number of seconds to block waiting for the
55-
# actor to shutdown. Block indefinitely when +nil+ or not given
56-
# @return [Boolean] +true+ if the actor shutdown before the limit expired else +false+
55+
# actor to shutdown. Block indefinitely when `nil` or not given
56+
# @return [Boolean] `true` if the actor shutdown before the limit expired else `false`
5757
# @see http://www.ruby-doc.org/core-2.1.1/Thread.html#method-i-join
5858

5959
def <<(message)

lib/concurrent/agent.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
module Concurrent
99

1010
# An agent is a single atomic value that represents an identity. The current value
11-
# of the agent can be requested at any time (#deref). Each agent has a work queue and operates on
12-
# the global thread pool. Consumers can #post code blocks to the agent. The code block (function)
11+
# of the agent can be requested at any time (`#deref`). Each agent has a work queue and operates on
12+
# the global thread pool. Consumers can `#post` code blocks to the agent. The code block (function)
1313
# will receive the current value of the agent as its sole parameter. The return value of the block
1414
# will become the new value of the agent. Agents support two error handling modes: fail and continue.
1515
# A good example of an agent is a shared incrementing counter, such as the score in a video game.
@@ -50,15 +50,15 @@ class Agent
5050
#
5151
# @option opts [Fixnum] :timeout (TIMEOUT) maximum number of seconds before an update is cancelled
5252
#
53-
# @option opts [Boolean] :operation (false) when +true+ will execute the future on the global
54-
# operation pool (for long-running operations), when +false+ will execute the future on the
53+
# @option opts [Boolean] :operation (false) when `true` will execute the future on the global
54+
# operation pool (for long-running operations), when `false` will execute the future on the
5555
# global task pool (for short-running tasks)
5656
# @option opts [object] :executor when provided will run all operations on
5757
# this executor rather than the global thread pool (overrides :operation)
5858
#
59-
# @option opts [String] :dup_on_deref (false) call +#dup+ before returning the data
60-
# @option opts [String] :freeze_on_deref (false) call +#freeze+ before returning the data
61-
# @option opts [String] :copy_on_deref (nil) call the given +Proc+ passing the internal value and
59+
# @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
60+
# @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
61+
# @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
6262
# returning the value returned from the proc
6363
def initialize(initial, opts = {})
6464
@value = initial
@@ -73,9 +73,9 @@ def initialize(initial, opts = {})
7373

7474
# Specifies a block operation to be performed when an update operation raises
7575
# an exception. Rescue blocks will be checked in order they were added. The first
76-
# block for which the raised exception "is-a" subclass of the given +clazz+ will
77-
# be called. If no +clazz+ is given the block will match any caught exception.
78-
# This behavior is intended to be identical to Ruby's +begin/rescue/end+ behavior.
76+
# block for which the raised exception "is-a" subclass of the given `clazz` will
77+
# be called. If no `clazz` is given the block will match any caught exception.
78+
# This behavior is intended to be identical to Ruby's `begin/rescue/end` behavior.
7979
# Any number of rescue handlers can be added. If no rescue handlers are added then
8080
# caught exceptions will be suppressed.
8181
#

lib/concurrent/async.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ module Concurrent
1717
# Stateful, mutable objects must be managed carefully when used asynchronously.
1818
# But Ruby is an object-oriented language so designing with objects and classes
1919
# plays to Ruby's strengths and is often more natural to many Ruby programmers.
20-
# The +Async+ module is a way to mix simple yet powerful asynchronous capabilities
20+
# The `Async` module is a way to mix simple yet powerful asynchronous capabilities
2121
# into any plain old Ruby object or class. These capabilities provide a reasonable
2222
# level of thread safe guarantees when used correctly.
2323
#
2424
# When this module is mixed into a class or object it provides to new methods:
25-
# +async+ and +await+. These methods are thread safe with respect to the enclosing
25+
# `async` and `await`. These methods are thread safe with respect to the enclosing
2626
# object. The former method allows methods to be called asynchronously by posting
2727
# to the global thread pool. The latter allows a method to be called synchronously
2828
# on the current thread but does so safely with respect to any pending asynchronous
29-
# method calls. Both methods return an +Obligation+ which can be inspected for
30-
# the result of the method call. Calling a method with +async+ will return a
31-
# +:pending+ +Obligation+ whereas +await+ will return a +:complete+ +Obligation+.
29+
# method calls. Both methods return an `Obligation` which can be inspected for
30+
# the result of the method call. Calling a method with `async` will return a
31+
# `:pending` `Obligation` whereas `await` will return a `:complete` `Obligation`.
3232
#
33-
# Very loosely based on the +async+ and +await+ keywords in C#.
33+
# Very loosely based on the `async` and `await` keywords in C#.
3434
#
3535
# @example Defining an asynchronous class
3636
# class Echo
@@ -64,9 +64,9 @@ module Concurrent
6464
# @note Thread safe guarantees can only be made when asynchronous method calls
6565
# are not mixed with synchronous method calls. Use only synchronous calls
6666
# when the object is used exclusively on a single thread. Use only
67-
# +async+ and +await+ when the object is shared between threads. Once you
68-
# call a method using +async+, you should no longer call any methods
69-
# directly on the object. Use +async+ and +await+ exclusively from then on.
67+
# `async` and `await` when the object is shared between threads. Once you
68+
# call a method using `async`, you should no longer call any methods
69+
# directly on the object. Use `async` and `await` exclusively from then on.
7070
# With careful programming it is possible to switch back and forth but it's
7171
# also very easy to create race conditions and break your application.
7272
# Basically, it's "async all the way down."
@@ -83,14 +83,14 @@ module Async
8383
# @param [Symbol] method the method to check the object for
8484
# @param [Array] args zero or more arguments for the arity check
8585
#
86-
# @raise [NameError] the object does not respond to +method+ method
87-
# @raise [ArgumentError] the given +args+ do not match the arity of +method+
86+
# @raise [NameError] the object does not respond to `method` method
87+
# @raise [ArgumentError] the given `args` do not match the arity of `method`
8888
#
8989
# @note This check is imperfect because of the way Ruby reports the arity of
9090
# methods with a variable number of arguments. It is possible to determine
9191
# if too few arguments are given but impossible to determine if too many
9292
# arguments are given. This check may also fail to recognize dynamic behavior
93-
# of the object, such as methods simulated with +method_missing+.
93+
# of the object, such as methods simulated with `method_missing`.
9494
#
9595
# @see http://www.ruby-doc.org/core-2.1.1/Method.html#method-i-arity Method#arity
9696
# @see http://ruby-doc.org/core-2.1.0/Object.html#method-i-respond_to-3F Object#respond_to?
@@ -112,8 +112,8 @@ def validate_argc(obj, method, *args)
112112
# @!visibility private
113113
class AwaitDelegator # :nodoc:
114114

115-
# Create a new delegator object wrapping the given +delegate+ and
116-
# protecting it with the given +mutex+.
115+
# Create a new delegator object wrapping the given `delegate` and
116+
# protecting it with the given `mutex`.
117117
#
118118
# @param [Object] delegate the object to wrap and delegate method calls to
119119
# @param [Mutex] mutex the mutex lock to use when delegating method calls
@@ -124,15 +124,15 @@ def initialize(delegate, mutex)
124124

125125
# Delegates method calls to the wrapped object. For performance,
126126
# dynamically defines the given method on the delegator so that
127-
# all future calls to +method+ will not be directed here.
127+
# all future calls to `method` will not be directed here.
128128
#
129129
# @param [Symbol] method the method being called
130130
# @param [Array] args zero or more arguments to the method
131131
#
132132
# @return [IVar] the result of the method call
133133
#
134-
# @raise [NameError] the object does not respond to +method+ method
135-
# @raise [ArgumentError] the given +args+ do not match the arity of +method+
134+
# @raise [NameError] the object does not respond to `method` method
135+
# @raise [ArgumentError] the given `args` do not match the arity of `method`
136136
def method_missing(method, *args, &block)
137137
super unless @delegate.respond_to?(method)
138138
Async::validate_argc(@delegate, method, *args)
@@ -166,8 +166,8 @@ def method_missing(method, *args, &block)
166166
# @!visibility private
167167
class AsyncDelegator # :nodoc:
168168

169-
# Create a new delegator object wrapping the given +delegate+ and
170-
# protecting it with the given +mutex+.
169+
# Create a new delegator object wrapping the given `delegate` and
170+
# protecting it with the given `mutex`.
171171
#
172172
# @param [Object] delegate the object to wrap and delegate method calls to
173173
# @param [Mutex] mutex the mutex lock to use when delegating method calls
@@ -179,15 +179,15 @@ def initialize(delegate, executor, mutex)
179179

180180
# Delegates method calls to the wrapped object. For performance,
181181
# dynamically defines the given method on the delegator so that
182-
# all future calls to +method+ will not be directed here.
182+
# all future calls to `method` will not be directed here.
183183
#
184184
# @param [Symbol] method the method being called
185185
# @param [Array] args zero or more arguments to the method
186186
#
187187
# @return [IVar] the result of the method call
188188
#
189-
# @raise [NameError] the object does not respond to +method+ method
190-
# @raise [ArgumentError] the given +args+ do not match the arity of +method+
189+
# @raise [NameError] the object does not respond to `method` method
190+
# @raise [ArgumentError] the given `args` do not match the arity of `method`
191191
def method_missing(method, *args, &block)
192192
super unless @delegate.respond_to?(method)
193193
Async::validate_argc(@delegate, method, *args)
@@ -214,29 +214,29 @@ def method_missing(method, *args, &block)
214214

215215
# Causes the chained method call to be performed asynchronously on the
216216
# global thread pool. The method called by this method will return a
217-
# +Future+ object in the +:pending+ state and the method call will have
217+
# `Future` object in the `:pending` state and the method call will have
218218
# been scheduled on the global thread pool. The final disposition of the
219-
# method call can be obtained by inspecting the returned +Future+.
219+
# method call can be obtained by inspecting the returned `Future`.
220220
#
221221
# Before scheduling the method on the global thread pool a best-effort
222222
# attempt will be made to validate that the method exists on the object
223223
# and that the given arguments match the arity of the requested function.
224224
# Due to the dynamic nature of Ruby and limitations of its reflection
225225
# library, some edge cases will be missed. For more information see
226-
# the documentation for the +validate_argc+ method.
226+
# the documentation for the `validate_argc` method.
227227
#
228228
# @note The method call is guaranteed to be thread safe with respect to
229229
# all other method calls against the same object that are called with
230-
# either +async+ or +await+. The mutable nature of Ruby references
230+
# either `async` or `await`. The mutable nature of Ruby references
231231
# (and object orientation in general) prevent any other thread safety
232232
# guarantees. Do NOT mix non-protected method calls with protected
233233
# method call. Use ONLY protected method calls when sharing the object
234234
# between threads.
235235
#
236236
# @return [Concurrent::Future] the pending result of the asynchronous operation
237237
#
238-
# @raise [NameError] the object does not respond to +method+ method
239-
# @raise [ArgumentError] the given +args+ do not match the arity of +method+
238+
# @raise [NameError] the object does not respond to `method` method
239+
# @raise [ArgumentError] the given `args` do not match the arity of `method`
240240
#
241241
# @see Concurrent::Future
242242
def async
@@ -246,29 +246,29 @@ def async
246246

247247
# Causes the chained method call to be performed synchronously on the
248248
# current thread. The method called by this method will return an
249-
# +IVar+ object in either the +:fulfilled+ or +rejected+ state and the
249+
# `IVar` object in either the `:fulfilled` or `rejected` state and the
250250
# method call will have completed. The final disposition of the
251-
# method call can be obtained by inspecting the returned +IVar+.
251+
# method call can be obtained by inspecting the returned `IVar`.
252252
#
253253
# Before scheduling the method on the global thread pool a best-effort
254254
# attempt will be made to validate that the method exists on the object
255255
# and that the given arguments match the arity of the requested function.
256256
# Due to the dynamic nature of Ruby and limitations of its reflection
257257
# library, some edge cases will be missed. For more information see
258-
# the documentation for the +validate_argc+ method.
258+
# the documentation for the `validate_argc` method.
259259
#
260260
# @note The method call is guaranteed to be thread safe with respect to
261261
# all other method calls against the same object that are called with
262-
# either +async+ or +await+. The mutable nature of Ruby references
262+
# either `async` or `await`. The mutable nature of Ruby references
263263
# (and object orientation in general) prevent any other thread safety
264264
# guarantees. Do NOT mix non-protected method calls with protected
265265
# method call. Use ONLY protected method calls when sharing the object
266266
# between threads.
267267
#
268268
# @return [Concurrent::IVar] the completed result of the synchronous operation
269269
#
270-
# @raise [NameError] the object does not respond to +method+ method
271-
# @raise [ArgumentError] the given +args+ do not match the arity of +method+
270+
# @raise [NameError] the object does not respond to `method` method
271+
# @raise [ArgumentError] the given `args` do not match the arity of `method`
272272
#
273273
# @see Concurrent::IVar
274274
def await

0 commit comments

Comments
 (0)