Skip to content

Commit 0210f7a

Browse files
committed
fix success vs succeed naming
1 parent 3d2d4c2 commit 0210f7a

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

lib/concurrent/actor/behaviour/sets_results.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def initialize(core, subsequent, core_options, error_strategy)
1313
def on_envelope(envelope)
1414
result = pass envelope
1515
if result != MESSAGE_PROCESSED && !envelope.future.nil?
16-
envelope.future.success result
16+
envelope.future.succeed result
1717
log(DEBUG) { "finished processing of #{envelope.message.inspect}"}
1818
end
1919
nil

lib/concurrent/actor/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def ns_initialize(opts, &block)
197197
schedule_execution do
198198
begin
199199
build_context
200-
initialized.success reference if initialized
200+
initialized.succeed reference if initialized
201201
log DEBUG, 'spawned'
202202
rescue => ex
203203
log ERROR, ex

lib/concurrent/edge/promises.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def completable_future
6666
end
6767

6868
# Creates completable future, user is responsible for completing the future once by
69-
# {Promises::CompletableFuture#complete}, {Promises::CompletableFuture#success},
69+
# {Promises::CompletableFuture#complete}, {Promises::CompletableFuture#succeed},
7070
# or {Promises::CompletableFuture#fail}
7171
#
7272
# @!macro promises.param.default_executor
@@ -95,7 +95,7 @@ def future_on(default_executor, *args, &task)
9595
ImmediateEventPromise.new(default_executor).future.then(*args, &task)
9696
end
9797

98-
# Creates completed future with will be either success with the given value or failed with
98+
# Creates completed future with will be either success with the given value or failure with
9999
# the given reason.
100100
#
101101
# @!macro promises.param.default_executor
@@ -108,7 +108,7 @@ def completed_future(success, value, reason, default_executor = :io)
108108
#
109109
# @!macro promises.param.default_executor
110110
# @return [Future]
111-
def succeeded_future(value, default_executor = :io)
111+
def successful_future(value, default_executor = :io)
112112
completed_future true, value, nil, default_executor
113113
end
114114

@@ -821,7 +821,7 @@ def failed?(state = internal_state)
821821

822822
# @!macro [new] promises.warn.nil
823823
# @note Make sure returned `nil` is not confused with timeout, no value when failed,
824-
# no reason when success, etc.
824+
# no reason when successful, etc.
825825
# Use more exact methods if needed, like {#wait}, {#value!}, {#result}, etc.
826826

827827
# @!macro [new] promises.method.value
@@ -831,7 +831,7 @@ def failed?(state = internal_state)
831831
# @!macro promises.warn.blocks
832832
# @!macro promises.warn.nil
833833
# @!macro promises.param.timeout
834-
# @return [Object, nil] the value of the Future when success, nil on timeout or failure.
834+
# @return [Object, nil] the value of the Future when successful, nil on timeout or failure.
835835
def value(timeout = nil)
836836
touch
837837
internal_state.value if wait_until_complete timeout
@@ -854,7 +854,7 @@ def reason(timeout = nil)
854854
#
855855
# @!macro promises.warn.blocks
856856
# @!macro promises.param.timeout
857-
# @return [Array(Boolean, Object, Exception), nil] triplet of success, value, reason, or nil
857+
# @return [Array(Boolean, Object, Exception), nil] triplet of success?, value, reason, or nil
858858
# on timeout.
859859
def result(timeout = nil)
860860
touch
@@ -870,7 +870,7 @@ def wait!(timeout = nil)
870870
end
871871

872872
# @!macro promises.method.value
873-
# @return [Object, nil] the value of the Future when success, nil on timeout.
873+
# @return [Object, nil] the value of the Future when successful, nil on timeout.
874874
# @raise [Exception] {#reason} on failure
875875
def value!(timeout = nil)
876876
touch
@@ -1173,8 +1173,8 @@ def complete(success, value, reason, raise_on_reassign = true)
11731173
# which triggers all dependent futures.
11741174
#
11751175
# @!macro promise.param.raise_on_reassign
1176-
def success(value, raise_on_reassign = true)
1177-
promise.success(value, raise_on_reassign)
1176+
def succeed(value, raise_on_reassign = true)
1177+
promise.succeed(value, raise_on_reassign)
11781178
end
11791179

11801180
# Makes the future failed with `reason`,
@@ -1278,7 +1278,7 @@ def initialize(default_executor)
12781278
super CompletableFuture.new(self, default_executor)
12791279
end
12801280

1281-
def success(value, raise_on_reassign)
1281+
def succeed(value, raise_on_reassign)
12821282
complete_with Success.new(value), raise_on_reassign
12831283
end
12841284

@@ -1325,7 +1325,7 @@ def on_done(future)
13251325
end
13261326

13271327
def touch
1328-
# TODO (pitr-ch 13-Jun-2016): track if it has lazy parent if it's needed avoids CASes!
1328+
# TODO (pitr-ch 13-Jun-2016): on construction pass down references of delays to be touched, avoids extra casses
13291329
blocked_by.each(&:touch)
13301330
end
13311331

@@ -1964,7 +1964,7 @@ class Throttle < Synchronization::Object
19641964
def initialize(max)
19651965
super()
19661966
self.can_run = max
1967-
# TODO (pitr-ch 10-Jun-2016): lockfree gueue is needed
1967+
# TODO (pitr-ch 10-Jun-2016): lock-free queue is needed
19681968
@Queue = Queue.new
19691969
end
19701970

spec/concurrent/promises_spec.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
it 'future' do
1919
b = completable_future
2020
a = completable_future.chain_completable(b)
21-
a.success :val
21+
a.succeed :val
2222
expect(b).to be_completed
2323
expect(b.value).to eq :val
2424
end
@@ -29,15 +29,15 @@
2929
future = future { 1 + 1 }
3030
expect(future.value!).to eq 2
3131

32-
future = succeeded_future(1).then { |v| v + 1 }
32+
future = successful_future(1).then { |v| v + 1 }
3333
expect(future.value!).to eq 2
3434
end
3535

3636
it 'executes with args' do
3737
future = future(1, 2, &:+)
3838
expect(future.value!).to eq 3
3939

40-
future = succeeded_future(1).then(1) { |v, a| v + 1 }
40+
future = successful_future(1).then(1) { |v, a| v + 1 }
4141
expect(future.value!).to eq 2
4242
end
4343
end
@@ -51,9 +51,9 @@ def behaves_as_delay(delay, value)
5151

5252
specify do
5353
behaves_as_delay delay { 1 + 1 }, 2
54-
behaves_as_delay succeeded_future(1).delay.then { |v| v + 1 }, 2
54+
behaves_as_delay successful_future(1).delay.then { |v| v + 1 }, 2
5555
behaves_as_delay delay(1) { |a| a + 1 }, 2
56-
behaves_as_delay succeeded_future(1).delay.then { |v| v + 1 }, 2
56+
behaves_as_delay successful_future(1).delay.then { |v| v + 1 }, 2
5757
end
5858
end
5959

@@ -118,7 +118,7 @@ def behaves_as_delay(delay, value)
118118
one = completable_future.then(&:succ)
119119
join = zip_futures(completable_future).then { |v| v }
120120
expect(one.completed?).to be false
121-
completable_future.success 0
121+
completable_future.succeed 0
122122
expect(one.value!).to eq 1
123123
expect(join.wait!.completed?).to be true
124124
expect(join.value!).to eq 0
@@ -134,7 +134,7 @@ def behaves_as_delay(delay, value)
134134
any1 = any_complete_future(f1, f2)
135135
any2 = f2 | f3
136136

137-
f1.success 1
137+
f1.succeed 1
138138
f2.fail StandardError.new
139139

140140
expect(any1.value!).to eq 1
@@ -150,7 +150,7 @@ def behaves_as_delay(delay, value)
150150
any = any_successful_future(f1, f2)
151151

152152
f1.fail StandardError.new
153-
f2.success :value
153+
f2.succeed :value
154154

155155
expect(any.value!).to eq :value
156156
end
@@ -229,15 +229,15 @@ def behaves_as_delay(delay, value)
229229

230230
describe '.each' do
231231
specify do
232-
expect(succeeded_future(nil).each.map(&:inspect)).to eq ['nil']
233-
expect(succeeded_future(1).each.map(&:inspect)).to eq ['1']
234-
expect(succeeded_future([1, 2]).each.map(&:inspect)).to eq ['1', '2']
232+
expect(successful_future(nil).each.map(&:inspect)).to eq ['nil']
233+
expect(successful_future(1).each.map(&:inspect)).to eq ['1']
234+
expect(successful_future([1, 2]).each.map(&:inspect)).to eq ['1', '2']
235235
end
236236
end
237237

238238
describe '.zip_events' do
239239
it 'waits for all and returns event' do
240-
a = succeeded_future 1
240+
a = successful_future 1
241241
b = failed_future :any
242242
c = completable_event.complete
243243

0 commit comments

Comments
 (0)