isomorfeus-ferret 0.13.3 → 0.13.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 958c051fa7f771e25ee1fb29c47aad9ab1cd7a570750f73450ae582474ef6fb5
4
- data.tar.gz: beba6b22ba7493f324be38997fee4f4a56efc896281fcbb2f3521ebef6795029
3
+ metadata.gz: 19cfca9e5508c89a931678c23a5b0b32d8759d0d1839ac0ecf0b043d93cd1ddf
4
+ data.tar.gz: 5999edb4c8ce46718264abdfac47cdd2bcc0f8e0ddf46a0af69bfba1ec024a1c
5
5
  SHA512:
6
- metadata.gz: 98bef5c79e3d4e8854d6a4cb68e2cb796c6f27bbaf1c7b7669ab895e8656d12d033651f8d8b29ac8d7504b46dba7567aa52f2ac297285ff2c6c62e52c48d0019
7
- data.tar.gz: 165497f356ab32cdc6250b3eada43d9ec36d61ee992114bffa9c38372c7894455caeb95aa789cf025c2538c7f9e1eddafe87e66b58536424a4c8e116a123af88
6
+ metadata.gz: e8ab5a9574a3b610b4d554a94ecbdf3252a77d7947f81fdd21bdd0c87ed6bd0940f4842091f0bec793b4e061fe218706d0e16ef64ab19d85ca48d825a1867beb
7
+ data.tar.gz: 474d0d57a321f3eaf47e372f76c7102592b85c7d0bf2e8506e7e3baf6ad3cbba2b5628296b5a3cf50b9bdba3031a2712225234143343cb9dbf80bc3781d00faa
data/LICENSE CHANGED
@@ -139,32 +139,6 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
139
139
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
140
140
 
141
141
 
142
- lib/isomorfeus/ferret/monitor.rb originally taken from the gem 'monitor':
143
-
144
- Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
145
-
146
- Redistribution and use in source and binary forms, with or without
147
- modification, are permitted provided that the following conditions
148
- are met:
149
-
150
- 1. Redistributions of source code must retain the above copyright notice,
151
- this list of conditions and the following disclaimer.
152
- 2. Redistributions in binary form must reproduce the above copyright notice,
153
- this list of conditions and the following disclaimer in the documentation
154
- and/or other materials provided with the distribution.
155
-
156
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
157
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
158
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
159
- DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
160
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
161
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
162
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
163
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
164
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
165
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
166
-
167
-
168
142
  The following licenses apply to files, which are distributed within the repo
169
143
  but not distributed with the gem and not used at runtime:
170
144
 
@@ -4,7 +4,7 @@ module Isomorfeus
4
4
  # This is a simplified interface to the index. See the TUTORIAL for more
5
5
  # information on how to use this class.
6
6
  class Index
7
- include Isomorfeus::Ferret::MonitorMixin
7
+ include MonitorMixin
8
8
  include Isomorfeus::Ferret::Store
9
9
  include Isomorfeus::Ferret::Search
10
10
 
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Ferret
3
- VERSION = '0.13.3'
3
+ VERSION = '0.13.4'
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require 'isomorfeus_ferret_ext'
2
2
  require 'isomorfeus/ferret/version'
3
3
  require 'isomorfeus/ferret/field_symbol'
4
4
  require 'isomorfeus/ferret/stdlib_patches'
5
- require 'isomorfeus/ferret/monitor'
5
+ require 'monitor'
6
6
  require 'isomorfeus/ferret/index/field_infos'
7
7
  require 'isomorfeus/ferret/index/index'
8
8
  require 'isomorfeus/ferret/document'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-ferret
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3
4
+ version: 0.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
@@ -360,7 +360,6 @@ files:
360
360
  - lib/isomorfeus/ferret/field_symbol.rb
361
361
  - lib/isomorfeus/ferret/index/field_infos.rb
362
362
  - lib/isomorfeus/ferret/index/index.rb
363
- - lib/isomorfeus/ferret/monitor.rb
364
363
  - lib/isomorfeus/ferret/stdlib_patches.rb
365
364
  - lib/isomorfeus/ferret/version.rb
366
365
  homepage: https://isomorfeus.com
@@ -1,323 +0,0 @@
1
- # frozen_string_literal: false
2
- # = monitor.rb
3
- #
4
- # Copyright (C) 2001 Shugo Maeda <shugo@ruby-lang.org>
5
- #
6
- # This library is distributed under the terms of the Ruby license.
7
- # You can freely distribute/modify this library.
8
- #
9
-
10
- #
11
- # In concurrent programming, a monitor is an object or module intended to be
12
- # used safely by more than one thread. The defining characteristic of a
13
- # monitor is that its methods are executed with mutual exclusion. That is, at
14
- # each point in time, at most one thread may be executing any of its methods.
15
- # This mutual exclusion greatly simplifies reasoning about the implementation
16
- # of monitors compared to reasoning about parallel code that updates a data
17
- # structure.
18
- #
19
- # You can read more about the general principles on the Wikipedia page for
20
- # Monitors[http://en.wikipedia.org/wiki/Monitor_%28synchronization%29]
21
- #
22
- # == Examples
23
- #
24
- # === Simple object.extend
25
- #
26
- # require 'monitor.rb'
27
- #
28
- # buf = []
29
- # buf.extend(MonitorMixin)
30
- # empty_cond = buf.new_cond
31
- #
32
- # # consumer
33
- # Thread.start do
34
- # loop do
35
- # buf.synchronize do
36
- # empty_cond.wait_while { buf.empty? }
37
- # print buf.shift
38
- # end
39
- # end
40
- # end
41
- #
42
- # # producer
43
- # while line = ARGF.gets
44
- # buf.synchronize do
45
- # buf.push(line)
46
- # empty_cond.signal
47
- # end
48
- # end
49
- #
50
- # The consumer thread waits for the producer thread to push a line to buf
51
- # while <tt>buf.empty?</tt>. The producer thread (main thread) reads a
52
- # line from ARGF and pushes it into buf then calls <tt>empty_cond.signal</tt>
53
- # to notify the consumer thread of new data.
54
- #
55
- # === Simple Class include
56
- #
57
- # require 'monitor'
58
- #
59
- # class SynchronizedArray < Array
60
- #
61
- # include MonitorMixin
62
- #
63
- # def initialize(*args)
64
- # super(*args)
65
- # end
66
- #
67
- # alias :old_shift :shift
68
- # alias :old_unshift :unshift
69
- #
70
- # def shift(n=1)
71
- # self.synchronize do
72
- # self.old_shift(n)
73
- # end
74
- # end
75
- #
76
- # def unshift(item)
77
- # self.synchronize do
78
- # self.old_unshift(item)
79
- # end
80
- # end
81
- #
82
- # # other methods ...
83
- # end
84
- #
85
- # +SynchronizedArray+ implements an Array with synchronized access to items.
86
- # This Class is implemented as subclass of Array which includes the
87
- # MonitorMixin module.
88
- #
89
- module Isomorfeus
90
- module Ferret
91
- module MonitorMixin
92
- #
93
- # FIXME: This isn't documented in Nutshell.
94
- #
95
- # Since MonitorMixin.new_cond returns a ConditionVariable, and the example
96
- # above calls while_wait and signal, this class should be documented.
97
- #
98
- class ConditionVariable
99
- class Timeout < Exception; end
100
-
101
- #
102
- # Releases the lock held in the associated monitor and waits; reacquires the lock on wakeup.
103
- #
104
- # If +timeout+ is given, this method returns after +timeout+ seconds passed,
105
- # even if no other thread doesn't signal.
106
- #
107
- def wait(timeout = nil)
108
- Thread.handle_interrupt(Exception => :never) do
109
- @monitor.__send__(:mon_check_owner)
110
- count = @monitor.__send__(:mon_exit_for_cond)
111
- begin
112
- Thread.handle_interrupt(Exception => :immediate) do
113
- @cond.wait(@monitor.instance_variable_get(:@mon_mutex), timeout)
114
- end
115
- return true
116
- ensure
117
- @monitor.__send__(:mon_enter_for_cond, count)
118
- end
119
- end
120
- end
121
-
122
- #
123
- # Calls wait repeatedly while the given block yields a truthy value.
124
- #
125
- def wait_while
126
- while yield
127
- wait
128
- end
129
- end
130
-
131
- #
132
- # Calls wait repeatedly until the given block yields a truthy value.
133
- #
134
- def wait_until
135
- until yield
136
- wait
137
- end
138
- end
139
-
140
- #
141
- # Wakes up the first thread in line waiting for this lock.
142
- #
143
- def signal
144
- @monitor.__send__(:mon_check_owner)
145
- @cond.signal
146
- end
147
-
148
- #
149
- # Wakes up all threads waiting for this lock.
150
- #
151
- def broadcast
152
- @monitor.__send__(:mon_check_owner)
153
- @cond.broadcast
154
- end
155
-
156
- private
157
-
158
- def initialize(monitor)
159
- @monitor = monitor
160
- @cond = Thread::ConditionVariable.new
161
- end
162
- end
163
-
164
- def self.extend_object(obj)
165
- super(obj)
166
- obj.__send__(:mon_initialize)
167
- end
168
-
169
- #
170
- # Attempts to enter exclusive section. Returns +false+ if lock fails.
171
- #
172
- def mon_try_enter
173
- if @mon_owner != Thread.current
174
- unless @mon_mutex.try_lock
175
- return false
176
- end
177
- @mon_owner = Thread.current
178
- @mon_count = 0
179
- end
180
- @mon_count += 1
181
- return true
182
- end
183
- # For backward compatibility
184
- alias try_mon_enter mon_try_enter
185
-
186
- #
187
- # Enters exclusive section.
188
- #
189
- def mon_enter
190
- if @mon_owner != Thread.current
191
- @mon_mutex.lock
192
- @mon_owner = Thread.current
193
- @mon_count = 0
194
- end
195
- @mon_count += 1
196
- end
197
-
198
- #
199
- # Leaves exclusive section.
200
- #
201
- def mon_exit
202
- mon_check_owner
203
- @mon_count -=1
204
- if @mon_count == 0
205
- @mon_owner = nil
206
- @mon_mutex.unlock
207
- end
208
- end
209
-
210
- #
211
- # Returns true if this monitor is locked by any thread
212
- #
213
- def mon_locked?
214
- @mon_mutex.locked?
215
- end
216
-
217
- #
218
- # Returns true if this monitor is locked by current thread.
219
- #
220
- def mon_owned?
221
- @mon_mutex.locked? && @mon_owner == Thread.current
222
- end
223
-
224
- #
225
- # Enters exclusive section and executes the block. Leaves the exclusive
226
- # section automatically when the block exits. See example under
227
- # +MonitorMixin+.
228
- #
229
- def mon_synchronize
230
- # Prevent interrupt on handling interrupts; for example timeout errors
231
- # it may break locking state.
232
- Thread.handle_interrupt(Exception => :never){ mon_enter }
233
- begin
234
- yield
235
- ensure
236
- Thread.handle_interrupt(Exception => :never){ mon_exit }
237
- end
238
- end
239
- alias synchronize mon_synchronize
240
-
241
- #
242
- # Creates a new MonitorMixin::ConditionVariable associated with the
243
- # receiver.
244
- #
245
- def new_cond
246
- return ConditionVariable.new(self)
247
- end
248
-
249
- private
250
-
251
- # Use <tt>extend MonitorMixin</tt> or <tt>include MonitorMixin</tt> instead
252
- # of this constructor. Have look at the examples above to understand how to
253
- # use this module.
254
- def initialize(*args)
255
- super
256
- mon_initialize
257
- end
258
-
259
- # Initializes the MonitorMixin after being included in a class or when an
260
- # object has been extended with the MonitorMixin
261
- def mon_initialize
262
- if defined?(@mon_mutex) && @mon_mutex_owner_object_id == object_id
263
- raise ThreadError, "already initialized"
264
- end
265
- @mon_mutex = Thread::Mutex.new
266
- @mon_mutex_owner_object_id = object_id
267
- @mon_owner = nil
268
- @mon_count = 0
269
- end
270
-
271
- def mon_check_owner
272
- if @mon_owner != Thread.current
273
- raise ThreadError, "current thread not owner"
274
- end
275
- end
276
-
277
- def mon_enter_for_cond(count)
278
- @mon_owner = Thread.current
279
- @mon_count = count
280
- end
281
-
282
- def mon_exit_for_cond
283
- count = @mon_count
284
- @mon_owner = nil
285
- @mon_count = 0
286
- return count
287
- end
288
- end
289
-
290
- # Use the Monitor class when you want to have a lock object for blocks with
291
- # mutual exclusion.
292
- #
293
- # require 'monitor'
294
- #
295
- # lock = Monitor.new
296
- # lock.synchronize do
297
- # # exclusive access
298
- # end
299
- #
300
- class Monitor
301
- include MonitorMixin
302
- alias try_enter try_mon_enter
303
- alias enter mon_enter
304
- alias exit mon_exit
305
- end
306
- end
307
- end
308
-
309
- # Documentation comments:
310
- # - All documentation comes from Nutshell.
311
- # - MonitorMixin.new_cond appears in the example, but is not documented in
312
- # Nutshell.
313
- # - All the internals (internal modules Accessible and Initializable, class
314
- # ConditionVariable) appear in RDoc. It might be good to hide them, by
315
- # making them private, or marking them :nodoc:, etc.
316
- # - RDoc doesn't recognise aliases, so we have mon_synchronize documented, but
317
- # not synchronize.
318
- # - mon_owner is in Nutshell, but appears as an accessor in a separate module
319
- # here, so is hard/impossible to RDoc. Some other useful accessors
320
- # (mon_count and some queue stuff) are also in this module, and don't appear
321
- # directly in the RDoc output.
322
- # - in short, it may be worth changing the code layout in this file to make the
323
- # documentation easier