Skip to content

Commit 36d6ad7

Browse files
committed
Maybe uses synchronization layer.
1 parent 6cfac83 commit 36d6ad7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/concurrent/maybe.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'concurrent/synchronization'
2+
13
module Concurrent
24

35
# A `Maybe` encapsulates an optional value. A `Maybe` either contains a value
@@ -99,8 +101,9 @@ module Concurrent
99101
#
100102
# @see https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html Haskell Data.Maybe
101103
# @see https://github.com/purescript/purescript-maybe/blob/master/docs/Data.Maybe.md PureScript Data.Maybe
102-
class Maybe
104+
class Maybe < Synchronization::Object
103105
include Comparable
106+
safe_initialization!
104107

105108
# Indicates that the given attribute has not been set.
106109
# When `Just` the {#nothing} getter will return `NONE`.
@@ -168,15 +171,15 @@ def self.nothing(error = '')
168171
end
169172

170173
# Is this `Maybe` a `Just` (successfully fulfilled with a value)?
171-
#
174+
#
172175
# @return [Boolean] True if `Just` or false if `Nothing`.
173176
def just?
174177
! nothing?
175178
end
176179
alias :fulfilled? :just?
177180

178181
# Is this `Maybe` a `nothing` (rejected with an exception upon fulfillment)?
179-
#
182+
#
180183
# @return [Boolean] True if `Nothing` or false if `Just`.
181184
def nothing?
182185
@nothing != NONE

0 commit comments

Comments
 (0)