dbg_tags 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dbg_tags.rb +38 -25
- data/spec/01_tag_spec.rb +38 -16
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a8e0401ca437e4c46fe63c0fa1aeb0a952e0bb26bb9470b72cf630201cc9e0fd
|
|
4
|
+
data.tar.gz: a148a7f14a0a8eeac1109f00ec9a8f0b768f391c2c218f1fc03fa3b61c8abed2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82fa4fd016e062e9901d306dc44597ddf6eaad44201721ea874228e59114eb371e4322d3799c6e1aab1fda467534490f32109fb26ff0aa09db48368e485ae3be
|
|
7
|
+
data.tar.gz: cb6d061257ee53ddb4962468aa03dd507499a4aebe400483818210b729c04c4af0eca967617fe8d594deead9500aef05ae068a7e379c38c8728b29ddc0113e9c
|
data/lib/dbg_tags.rb
CHANGED
|
@@ -190,28 +190,38 @@ module Tag
|
|
|
190
190
|
private # class methods of Tag
|
|
191
191
|
|
|
192
192
|
# @param value [Bool] Value to set
|
|
193
|
-
# Primarily for rspec stuff. Use {
|
|
194
|
-
def
|
|
195
|
-
@
|
|
196
|
-
end # Tag::
|
|
193
|
+
# Primarily for rspec stuff. Use {disable_thread_local_state} instead
|
|
194
|
+
def no_thread_local_state= value
|
|
195
|
+
@no_thread_local_state = value
|
|
196
|
+
end # Tag::no_thread_local_state=
|
|
197
197
|
|
|
198
198
|
public # class methods of Tag
|
|
199
199
|
|
|
200
200
|
# @return [Bool,nil] True if we should store global state inside the Tag class itself.
|
|
201
|
-
attr :
|
|
202
|
-
alias
|
|
201
|
+
attr :no_thread_local_state
|
|
202
|
+
alias no_thread_local_state? no_thread_local_state
|
|
203
|
+
|
|
204
|
+
# DEPRECATED
|
|
205
|
+
alias no_fiber_local_state? no_thread_local_state? # for B.C.
|
|
203
206
|
|
|
204
207
|
# @return [Bool] True (the default) if we should store global state
|
|
205
|
-
# in each
|
|
206
|
-
def
|
|
208
|
+
# in each thread of the application.
|
|
209
|
+
def use_thread_local_state?; !no_thread_local_state? end
|
|
210
|
+
|
|
211
|
+
# DEPRECATED
|
|
212
|
+
alias use_fiber_local_state? use_thread_local_state? # for B.C.
|
|
207
213
|
|
|
208
|
-
# @return [GlobalState] Either
|
|
214
|
+
# @return [GlobalState] Either thread local data (default) or truly global.
|
|
209
215
|
def global_state
|
|
210
|
-
if @
|
|
211
|
-
# at least for performance
|
|
216
|
+
if @no_thread_local_state
|
|
212
217
|
@global_state ||= GlobalState.new
|
|
213
218
|
else
|
|
214
|
-
Thread.current
|
|
219
|
+
ct = Thread.current
|
|
220
|
+
unless state = ct.thread_variable_get(:dbg_tags_global_state)
|
|
221
|
+
state = GlobalState.new
|
|
222
|
+
ct.thread_variable_set :dbg_tags_global_state, state
|
|
223
|
+
end
|
|
224
|
+
state
|
|
215
225
|
end
|
|
216
226
|
end # Tag::global_state
|
|
217
227
|
|
|
@@ -295,20 +305,23 @@ module Tag
|
|
|
295
305
|
# @return [bool] Reflects explicit enable calls only. The :all feature is IGNORED
|
|
296
306
|
def enabled? feature; (global_state.enabled[feature] || NONE) > NONE; end
|
|
297
307
|
|
|
298
|
-
# shortcut for
|
|
299
|
-
# By default
|
|
300
|
-
# 'enabling' of tags in some
|
|
301
|
-
#
|
|
302
|
-
#
|
|
303
|
-
#
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
#
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
# shortcut for
|
|
308
|
+
# shortcut for no_thread_local_state = true
|
|
309
|
+
# By default thread local state is enabled and this means that
|
|
310
|
+
# 'enabling' of tags in some thread does effect in others.
|
|
311
|
+
# So: when using threads leave this enabled, as it will cause race conditions
|
|
312
|
+
# otherwise.
|
|
313
|
+
# When not using threads, it is more efficient to disable it.
|
|
314
|
+
def disable_thread_local_state; self.no_thread_local_state = true end
|
|
315
|
+
|
|
316
|
+
# DEPRECATED
|
|
317
|
+
alias disable_fiber_local_state disable_thread_local_state # for B.C.
|
|
318
|
+
|
|
319
|
+
# shortcut for no_thread_local_state := false
|
|
310
320
|
# For rspec use mostly.
|
|
311
|
-
def
|
|
321
|
+
def enable_thread_local_state; self.no_thread_local_state = false end
|
|
322
|
+
|
|
323
|
+
# DEPRECATED
|
|
324
|
+
alias enable_fiber_local_state enable_thread_local_state # for B.C.
|
|
312
325
|
|
|
313
326
|
end # singleton class Tag
|
|
314
327
|
end # module Tag
|
data/spec/01_tag_spec.rb
CHANGED
|
@@ -255,7 +255,7 @@ describe 'tag' do
|
|
|
255
255
|
end # context 'Nested levels'
|
|
256
256
|
|
|
257
257
|
it 'has thread local data to prevent mix ups (tag_300)' do
|
|
258
|
-
Tag.
|
|
258
|
+
Tag.enable_thread_local_state # NOTE enabled by default, but other examples may botch it
|
|
259
259
|
t1 = Thread.new do
|
|
260
260
|
Tag.enable threads: :trc do
|
|
261
261
|
Tag.trc(:threads) {
|
|
@@ -275,7 +275,7 @@ describe 'tag' do
|
|
|
275
275
|
end # it
|
|
276
276
|
|
|
277
277
|
it 'each thread has a private tag system (tag_301)' do
|
|
278
|
-
Tag.
|
|
278
|
+
Tag.enable_thread_local_state # NOTE enabled by default, but other examples may botch it
|
|
279
279
|
executed = false
|
|
280
280
|
Tag.enable threads: :trc do
|
|
281
281
|
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
@@ -297,12 +297,12 @@ describe 'tag' do
|
|
|
297
297
|
expect(executed).to be true
|
|
298
298
|
end # it
|
|
299
299
|
|
|
300
|
-
it 'each
|
|
301
|
-
Tag.
|
|
300
|
+
it 'each thread has a private tag system (tag_302)' do
|
|
301
|
+
Tag.enable_thread_local_state # NOTE enabled by default, but other examples may botch it
|
|
302
302
|
executed = false
|
|
303
303
|
Tag.enable threads: :trc do
|
|
304
304
|
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
305
|
-
t1 =
|
|
305
|
+
t1 = Thread.new do
|
|
306
306
|
expect(Tag.enabled).to eq({})
|
|
307
307
|
Tag.enable threads: :log do
|
|
308
308
|
expect(Tag.enabled).to eq({threads: Tag::LOG})
|
|
@@ -313,14 +313,14 @@ describe 'tag' do
|
|
|
313
313
|
}
|
|
314
314
|
end
|
|
315
315
|
end
|
|
316
|
-
t1.
|
|
316
|
+
t1.join
|
|
317
317
|
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
318
318
|
end
|
|
319
319
|
expect(executed).to be true
|
|
320
320
|
end # it
|
|
321
321
|
|
|
322
|
-
it '
|
|
323
|
-
Tag.
|
|
322
|
+
it 'Fibers share the tag state (tag_303)' do
|
|
323
|
+
Tag.enable_thread_local_state # NOTE enabled by default, but other examples may botch it
|
|
324
324
|
executed = false
|
|
325
325
|
Tag.enable threads: :trc do
|
|
326
326
|
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
@@ -337,17 +337,39 @@ describe 'tag' do
|
|
|
337
337
|
end
|
|
338
338
|
t1.resume
|
|
339
339
|
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
340
|
+
end
|
|
341
|
+
expect(executed).to be true
|
|
342
|
+
end # it
|
|
343
|
+
|
|
344
|
+
it 'allows to disable thread local state (tag_305)' do
|
|
345
|
+
Tag.disable_thread_local_state
|
|
346
|
+
executed = false
|
|
347
|
+
Tag.enable threads: :trc do
|
|
348
|
+
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
349
|
+
t1 = Thread.new do
|
|
350
|
+
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
351
|
+
Tag.enable threads: :log do
|
|
352
|
+
expect(Tag.enabled).to eq({threads: Tag::LOG})
|
|
353
|
+
Tag.log(:threads) {
|
|
354
|
+
expect(Tag.inside?).to be true
|
|
355
|
+
executed = true
|
|
356
|
+
nil
|
|
357
|
+
}
|
|
358
|
+
end
|
|
359
|
+
end
|
|
360
|
+
t1.join
|
|
361
|
+
expect(Tag.enabled).to eq({threads: Tag::TRC})
|
|
340
362
|
expect(executed).to be true
|
|
341
363
|
end
|
|
342
364
|
end # it
|
|
343
365
|
|
|
344
|
-
it 'does allow restore_state to transfer state
|
|
345
|
-
Tag.
|
|
366
|
+
it 'does allow restore_state to transfer state into a Thread (tag_310)' do
|
|
367
|
+
Tag.enable_thread_local_state
|
|
346
368
|
did_something = false
|
|
347
369
|
Tag.enable example: :dtl, fiber: :trc do
|
|
348
370
|
state = Tag.state # same as Tag.enabled
|
|
349
371
|
expect(state).to eq({example: Tag::DTL, fiber: Tag::TRC})
|
|
350
|
-
t1 =
|
|
372
|
+
t1 = Thread.new do
|
|
351
373
|
expect(Tag.state).to eq({})
|
|
352
374
|
Tag.enable foo: :trc
|
|
353
375
|
Tag.restore_state state do
|
|
@@ -355,18 +377,18 @@ describe 'tag' do
|
|
|
355
377
|
did_something = true
|
|
356
378
|
end
|
|
357
379
|
end
|
|
358
|
-
t1.
|
|
380
|
+
t1.join
|
|
359
381
|
expect(Tag.state).to eq({example: Tag::DTL, fiber: Tag::TRC})
|
|
360
382
|
end # enable
|
|
361
383
|
expect(did_something).to be true
|
|
362
384
|
end # it
|
|
363
385
|
|
|
364
|
-
it 'does allow a nil-state to transfer
|
|
365
|
-
Tag.
|
|
386
|
+
it 'does allow a nil-state to transfer into a Thread (tag_311)' do
|
|
387
|
+
Tag.enable_thread_local_state
|
|
366
388
|
did_something = false
|
|
367
389
|
state = Tag.state
|
|
368
390
|
expect(state).to eq({})
|
|
369
|
-
t1 =
|
|
391
|
+
t1 = Thread.new do
|
|
370
392
|
expect(Tag.state).to eq({})
|
|
371
393
|
Tag.enable foo: :trc
|
|
372
394
|
Tag.restore_state state do
|
|
@@ -374,7 +396,7 @@ describe 'tag' do
|
|
|
374
396
|
did_something = true
|
|
375
397
|
end
|
|
376
398
|
end
|
|
377
|
-
t1.
|
|
399
|
+
t1.join
|
|
378
400
|
expect(Tag.state).to eq({})
|
|
379
401
|
expect(did_something).to be true
|
|
380
402
|
end # it
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dbg_tags
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eugene Brazwick
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -66,7 +66,7 @@ homepage: https://github.com/Eugene-Brazwick/dbg_tags
|
|
|
66
66
|
licenses:
|
|
67
67
|
- GPL-3.0
|
|
68
68
|
metadata: {}
|
|
69
|
-
post_install_message:
|
|
69
|
+
post_install_message:
|
|
70
70
|
rdoc_options: []
|
|
71
71
|
require_paths:
|
|
72
72
|
- lib
|
|
@@ -81,8 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
83
|
requirements: []
|
|
84
|
-
rubygems_version: 3.
|
|
85
|
-
signing_key:
|
|
84
|
+
rubygems_version: 3.4.20
|
|
85
|
+
signing_key:
|
|
86
86
|
specification_version: 4
|
|
87
87
|
summary: a versatile dynamic debug tracing system
|
|
88
88
|
test_files:
|