Skip to content

Commit 626aa46

Browse files
committed
Merge pull request #317 from ruby-concurrency/internal-reorg-struct
Structs are now at the top-level Concurrent namespace.
2 parents 0e05809 + d75de89 commit 626aa46

File tree

11 files changed

+170
-169
lines changed

11 files changed

+170
-169
lines changed

lib/concurrent.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,21 @@
99
require 'concurrent/errors'
1010
require 'concurrent/executors'
1111
require 'concurrent/utilities'
12-
require 'concurrent/struct'
1312

1413
require 'concurrent/atomic/atomic_reference'
1514
require 'concurrent/atom'
1615
require 'concurrent/async'
1716
require 'concurrent/dataflow'
1817
require 'concurrent/delay'
1918
require 'concurrent/future'
19+
require 'concurrent/immutable_struct'
2020
require 'concurrent/ivar'
2121
require 'concurrent/maybe'
22+
require 'concurrent/mutable_struct'
2223
require 'concurrent/mvar'
2324
require 'concurrent/promise'
2425
require 'concurrent/scheduled_task'
26+
require 'concurrent/settable_struct'
2527
require 'concurrent/timer_task'
2628
require 'concurrent/tvar'
2729

lib/concurrent/struct/immutable_struct.rb renamed to lib/concurrent/immutable_struct.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'concurrent/struct/abstract_struct'
1+
require 'concurrent/synchronization/abstract_struct'
22
require 'concurrent/synchronization'
33

44
module Concurrent
@@ -7,7 +7,7 @@ module Concurrent
77
#
88
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
99
module ImmutableStruct
10-
include AbstractStruct
10+
include Synchronization::AbstractStruct
1111

1212
# @!macro struct_values
1313
def values
@@ -80,7 +80,7 @@ def self.new(*args, &block)
8080
FACTORY = Class.new(Synchronization::Object) do
8181
def define_struct(name, members, &block)
8282
synchronize do
83-
AbstractStruct.define_struct_class(ImmutableStruct, Synchronization::Object, name, members, &block)
83+
Synchronization::AbstractStruct.define_struct_class(ImmutableStruct, Synchronization::Object, name, members, &block)
8484
end
8585
end
8686
end.new

lib/concurrent/struct/mutable_struct.rb renamed to lib/concurrent/mutable_struct.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'concurrent/struct/abstract_struct'
1+
require 'concurrent/synchronization/abstract_struct'
22
require 'concurrent/synchronization'
33

44
module Concurrent
@@ -8,7 +8,7 @@ module Concurrent
88
#
99
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
1010
module MutableStruct
11-
include AbstractStruct
11+
include Synchronization::AbstractStruct
1212

1313
# @!macro [new] struct_new
1414
#
@@ -88,7 +88,7 @@ def inspect
8888
# @yieldparam [Object] selfvalue the value of the member in `self`
8989
# @yieldparam [Object] othervalue the value of the member in `other`
9090
#
91-
# @return [AbstractStruct] a new struct with the new values
91+
# @return [Synchronization::AbstractStruct] a new struct with the new values
9292
#
9393
# @raise [ArgumentError] of given a member that is not defined in the struct
9494
def merge(other, &block)
@@ -209,7 +209,7 @@ def self.new(*args, &block)
209209
FACTORY = Class.new(Synchronization::Object) do
210210
def define_struct(name, members, &block)
211211
synchronize do
212-
clazz = AbstractStruct.define_struct_class(MutableStruct, Synchronization::Object, name, members, &block)
212+
clazz = Synchronization::AbstractStruct.define_struct_class(MutableStruct, Synchronization::Object, name, members, &block)
213213
members.each_with_index do |member, index|
214214
clazz.send(:define_method, member) do
215215
synchronize { @values[index] }

lib/concurrent/struct/settable_struct.rb renamed to lib/concurrent/settable_struct.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'concurrent/struct/abstract_struct'
1+
require 'concurrent/synchronization/abstract_struct'
22
require 'concurrent/errors'
33
require 'concurrent/synchronization'
44

@@ -12,7 +12,7 @@ module Concurrent
1212
# @see http://ruby-doc.org/core-2.2.0/Struct.html Ruby standard library `Struct`
1313
# @see http://en.wikipedia.org/wiki/Final_(Java) Java `final` keyword
1414
module SettableStruct
15-
include AbstractStruct
15+
include Synchronization::AbstractStruct
1616

1717
# @!macro struct_values
1818
def values
@@ -104,7 +104,7 @@ def self.new(*args, &block)
104104
FACTORY = Class.new(Synchronization::Object) do
105105
def define_struct(name, members, &block)
106106
synchronize do
107-
clazz = AbstractStruct.define_struct_class(SettableStruct, Synchronization::Object, name, members, &block)
107+
clazz = Synchronization::AbstractStruct.define_struct_class(SettableStruct, Synchronization::Object, name, members, &block)
108108
members.each_with_index do |member, index|
109109
clazz.send(:define_method, member) do
110110
synchronize { @values[index] }

lib/concurrent/struct.rb

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/concurrent/struct/abstract_struct.rb

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)