weel 1.99.103 → 1.99.106

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/weel.rb +83 -9
  3. data/weel.gemspec +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bc4118f9af75b1f635758821fc31af172b7f02151bc0a05902999123885754d
4
- data.tar.gz: '09c0d3b3de4f1810ed59e4debc90a8f734fa3cdf634bd623eb79a75191ece2bf'
3
+ metadata.gz: 627e4761660de50801a488a4616023f2ec16339859d5542d92a7601d7e2178de
4
+ data.tar.gz: 30752f561acbf9aebc0592d92a1796918e5d50f879b26c2bee245965ce5dd72c
5
5
  SHA512:
6
- metadata.gz: 0b0d10b86028537026755946a1dc5969ed5b9fb93b10a5a914f09f7cf3d2343f52d5f0875dc2caffa757eb62cdce0414511b0f90514ae6854b9a812583ebfa1d
7
- data.tar.gz: a3754737a7bab106885e47cfe7968ee0ed2fbc8db637f08aad6ed35dba102cb71d171618da98e1cb99c35ab23adb430f2425aa7f99a0f74b83db4d677b6fe019
6
+ metadata.gz: 2874bf3236b00980121e9560cb7e6ee2d09bbc55b56732cc9dd5693165e74042d6bd2a135e67c285ef98c0bb154cd5e982d2e4129f7fb2fc1631b74ff61a8857
7
+ data.tar.gz: c44982e0661e397a673214955acd2e9e2647e878748ee394b8d37a1a2eba6bcab3785ef2693511424d1d72f670c7f35a331ab06a33f8a3fcd72210d3c87afa65
data/lib/weel.rb CHANGED
@@ -43,7 +43,7 @@ class WEEL
43
43
  end # }}}
44
44
 
45
45
  class ReadStructure # {{{
46
- def initialize(data,endpoints,additional)
46
+ def initialize(data,endpoints,local,additional)
47
47
  @__weel_data = data.transform_values do |v|
48
48
  if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
49
49
  v.root.to_doc
@@ -56,6 +56,7 @@ class WEEL
56
56
  end
57
57
  end
58
58
  @__weel_endpoints = endpoints.transform_values{ |v| v.dup }
59
+ @__weel_local = local
59
60
  @additional = additional
60
61
  end
61
62
 
@@ -91,14 +92,18 @@ class WEEL
91
92
  def endpoints
92
93
  ReadHash.new(@__weel_endpoints)
93
94
  end
95
+ def local
96
+ @__weel_local.first
97
+ end
94
98
  end # }}}
95
99
  class ManipulateStructure # {{{
96
- def initialize(data,endpoints,status,additional)
100
+ def initialize(data,endpoints,status,local,additional)
97
101
  @__weel_data = data
98
102
  @__weel_data_orig = @__weel_data.transform_values{|val| Marshal.dump(val) } rescue nil
99
103
  @__weel_endpoints = endpoints
100
104
  @__weel_endpoints_orig = @__weel_endpoints.transform_values{|val| Marshal.dump(val) }
101
105
  @__weel_status = status
106
+ @__weel_local = local
102
107
  @changed_status = "#{status.id}-#{status.message}"
103
108
  @changed_data = []
104
109
  @touched_data = []
@@ -165,6 +170,9 @@ class WEEL
165
170
  def endpoints
166
171
  ManipulateHash.new(@__weel_endpoints,@touched_endpoints,@changed_endpoints)
167
172
  end
173
+ def local
174
+ @__weel_local.first
175
+ end
168
176
  def status
169
177
  @__weel_status
170
178
  end
@@ -263,6 +271,48 @@ class WEEL
263
271
  end
264
272
  end # }}}
265
273
 
274
+ class ReadOnlyHash # {{{
275
+ def initialize(values,sim=false)
276
+ @__weel_values = values.transform_values do |v|
277
+ if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
278
+ v.root.to_doc
279
+ else
280
+ begin
281
+ Marshal.load(Marshal.dump(v))
282
+ rescue
283
+ v.to_s rescue nil
284
+ end
285
+ end
286
+ end
287
+ @__weel_sim = sim
288
+ end
289
+
290
+ def to_json(*args)
291
+ @__weel_values.to_json(*args)
292
+ end
293
+
294
+ def method_missing(name,*args)
295
+ if @__weel_sim
296
+ "➤#{name}"
297
+ else
298
+ if args.empty? && @__weel_values.key?(name)
299
+ @__weel_values[name]
300
+ elsif args.empty? && @__weel_values.key?(name.to_s)
301
+ @__weel_values[name.to_s]
302
+ elsif name.to_s[-1..-1] == "=" && args.length == 1
303
+ temp = name.to_s[0..-2]
304
+ @__weel_values[temp.to_sym] = args[0]
305
+ elsif name.to_s == "[]=" && args.length == 2
306
+ @__weel_values[args[0]] = args[1]
307
+ elsif name.to_s == "[]" && args.length == 1
308
+ @__weel_values[args[0]]
309
+ else
310
+ nil
311
+ end
312
+ end
313
+ end
314
+ end # }}}
315
+
266
316
  class ConnectionWrapperBase # {{{
267
317
  def self::loop_guard(arguments,lid,count); false; end
268
318
  def self::inform_state_change(arguments,newstate); end
@@ -304,6 +354,7 @@ class WEEL
304
354
  def mem_guard; end
305
355
 
306
356
  def test_condition(mr,code); mr.instance_eval(code); end
357
+ def join_branches(branches); end
307
358
  def manipulate(mr,code,where,result=nil,options=nil); mr.instance_eval(code,where,1); end
308
359
  end # }}}
309
360
 
@@ -437,6 +488,8 @@ class WEEL
437
488
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
438
489
 
439
490
  Thread.current[:branches] = []
491
+ Thread.current[:branch_traces] = {}
492
+ Thread.current[:branch_traces_ids] = 0
440
493
  Thread.current[:branch_finished_count] = 0
441
494
  Thread.current[:branch_event] = Continue.new
442
495
  Thread.current[:mutex] = Mutex.new
@@ -465,6 +518,9 @@ class WEEL
465
518
 
466
519
  __weel_sim_stop(:parallel,hw,pos) if __weel_sim
467
520
 
521
+ cw = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
522
+ cw.join_branches(Thread.current[:branch_traces])
523
+
468
524
  unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
469
525
  # first set all to no_longer_neccessary
470
526
  Thread.current[:branches].each do |thread|
@@ -495,7 +551,12 @@ class WEEL
495
551
  Thread.current[:branch_status] = false
496
552
  Thread.current[:branch_parent] = branch_parent
497
553
  Thread.current[:start_event] = Continue.new
554
+ Thread.current[:local] = local
498
555
  Thread.current[:branch_wait_count_cancel_active] = false
556
+ branch_parent[:mutex].synchronize do
557
+ Thread.current[:branch_traces_id] = branch_parent[:branch_traces_ids]
558
+ branch_parent[:branch_traces_ids] += 1
559
+ end
499
560
 
500
561
  if __weel_sim
501
562
  Thread.current[:branch_sim_pos] = @__weel_sim += 1
@@ -668,6 +729,13 @@ class WEEL
668
729
  searchmode = __weel_is_in_search_mode(position)
669
730
  return if searchmode
670
731
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
732
+
733
+ # gather traces in threads to point to join
734
+ if Thread.current[:branch_parent] && Thread.current[:branch_traces_id]
735
+ Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] ||= []
736
+ Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] << position
737
+ end
738
+
671
739
  __weel_progress position, true
672
740
  self.__weel_state = :stopping
673
741
  end #}}}
@@ -676,7 +744,7 @@ class WEEL
676
744
  @__weel_status
677
745
  end # }}}
678
746
  def data # {{{
679
- ReadHash.new(@__weel_data,__weel_sim)
747
+ ReadOnlyHash.new(@__weel_data,__weel_sim)
680
748
  end # }}}
681
749
  def endpoints # {{{
682
750
  ReadHash.new(@__weel_endpoints)
@@ -700,7 +768,7 @@ class WEEL
700
768
  def __weel_eval_condition(condition) #{{{
701
769
  begin
702
770
  connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args unless condition.is_a?(Proc)
703
- condition.is_a?(Proc) ? condition.call : connectionwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional),condition)
771
+ condition.is_a?(Proc) ? condition.call : connectionwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,Thread.current[:local],connectionwrapper.additional),condition)
704
772
  rescue NameError => err # don't look into it, or it will explode
705
773
  # if you access $! here, BOOOM
706
774
  self.__weel_state = :stopping
@@ -765,6 +833,12 @@ class WEEL
765
833
  return
766
834
  end
767
835
 
836
+ # gather traces in threads to point to join
837
+ if Thread.current[:branch_parent] && Thread.current[:branch_traces_id]
838
+ Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] ||= []
839
+ Thread.current[:branch_parent][:branch_traces][Thread.current[:branch_traces_id]] << position
840
+ end
841
+
768
842
  wp = __weel_progress position
769
843
 
770
844
  # searchmode position is after, jump directly to vote_sync_after
@@ -779,10 +853,10 @@ class WEEL
779
853
  connectionwrapper.activity_manipulate_handle(parameters)
780
854
  connectionwrapper.inform_activity_manipulate
781
855
  if finalize.is_a?(Proc)
782
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
856
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional)
783
857
  mr.instance_eval(&finalize)
784
858
  elsif finalize.is_a?(String)
785
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
859
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional)
786
860
  connectionwrapper.manipulate(mr,finalize,'Activity ' + position.to_s)
787
861
  end
788
862
  connectionwrapper.inform_manipulate_change(
@@ -800,7 +874,7 @@ class WEEL
800
874
  begin
801
875
  again = catch Signal::Again do
802
876
  connectionwrapper.mem_guard
803
- rs = ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional)
877
+ rs = ReadStructure.new(@__weel_data,@__weel_endpoints,Thread.current[:local],connectionwrapper.additional)
804
878
  if prepare
805
879
  if prepare.is_a?(Proc)
806
880
  rs.instance_exec(&prepare)
@@ -844,7 +918,7 @@ class WEEL
844
918
  if code.is_a?(Proc) || code.is_a?(String)
845
919
  connectionwrapper.inform_activity_manipulate
846
920
  if code.is_a?(Proc)
847
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
921
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional)
848
922
  ma = catch Signal::Again do
849
923
  case code.arity
850
924
  when 1; mr.instance_exec(connectionwrapper.activity_result_value,&code)
@@ -855,7 +929,7 @@ class WEEL
855
929
  'yes' # ma sadly will have nil when i just throw
856
930
  end
857
931
  elsif code.is_a?(String)
858
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
932
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,Thread.current[:local],connectionwrapper.additional)
859
933
  ma = catch Signal::Again do
860
934
  connectionwrapper.manipulate(mr,code,'Activity ' + position.to_s,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
861
935
  'yes' # ma sadly will have nil when i just throw
data/weel.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.103"
3
+ s.version = "1.99.106"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Workflow Execution Engine Library (WEEL)"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.103
4
+ version: 1.99.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-07 00:00:00.000000000 Z
12
+ date: 2023-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.3.7
104
+ rubygems_version: 3.3.26
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Workflow Execution Engine Library (WEEL)