weel 1.99.96 → 1.99.100

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: d57273f8a41035b63f07d1d3539c73460c14f66d15c127a2d03b0084ab5990ea
4
- data.tar.gz: ebcc6596ec5179ceb57166bf9cd5e174ff11cce119bda6834ef1f6faf3b15b1c
3
+ metadata.gz: 28793c76f88b8620c69d8fb847cb65d9099a222b3de4fc34a97c5abeed8a651c
4
+ data.tar.gz: ebfac22d2ad99ff23eb05412a4f64cdfa4d8de10933c72fb283e0eb537a5b2d8
5
5
  SHA512:
6
- metadata.gz: 59417172655d756d29c40a8d7fc4101baad460c53667823671fe3dd7379e9157ee6310f99029d6e08b808f134819f4e9af1a0eab6e8e5c272b6b02765ca9e8fb
7
- data.tar.gz: 4ce71748c9925987e7d2acc8188a913ed7d2c7f24d2db7e21d5f75e21065df3e270ae8311ccac58d768f147f564f4cb66177a1c26402e81f554da43d3b412787
6
+ metadata.gz: ae56427474cd09858be1be71232db8106947dfa98bce1ff47372b95ebba83c283d6db394dcbc56a5bb521d61696ea313307bb7419bf26e79a49a047f209bb7bb
7
+ data.tar.gz: 207fafcd048fe2bb72304db31dc0c23cb65f37fcce85c592dae95b2728b09816dded6f491add2b9da7d72e2373d97f85b7d93e09a25efd9af626be8b276661c7
data/lib/weel.rb CHANGED
@@ -20,13 +20,14 @@ require 'securerandom'
20
20
  class WEEL
21
21
  def initialize(*args)# {{{
22
22
  @dslr = DSLRealization.new
23
- @dslr.__weel_handlerwrapper_args = args
23
+ @dslr.__weel_connectionwrapper_args = args
24
24
 
25
25
  initialize_search if methods.include?(:initialize_search)
26
26
  initialize_data if methods.include?(:initialize_data)
27
27
  initialize_endpoints if methods.include?(:initialize_endpoints)
28
- initialize_handlerwrapper if methods.include?(:initialize_handlerwrapper)
28
+ initialize_connectionwrapper if methods.include?(:initialize_connectionwrapper)
29
29
  initialize_control if methods.include?(:initialize_control)
30
+ initialize_flow_data if methods.include?(:initialize_flow_data)
30
31
  end # }}}
31
32
 
32
33
  module Signal # {{{
@@ -43,8 +44,7 @@ class WEEL
43
44
 
44
45
  class ReadStructure # {{{
45
46
  def initialize(data,endpoints,additional)
46
- @__weel_data = data.dup
47
- @__weel_data.transform_values! do |v|
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
50
50
  else
@@ -55,8 +55,7 @@ class WEEL
55
55
  end
56
56
  end
57
57
  end
58
- @__weel_endpoints = endpoints.dup
59
- @__weel_endpoints.transform_values!{ |v| v.dup }
58
+ @__weel_endpoints = endpoints.transform_values{ |v| v.dup }
60
59
  @additional = additional
61
60
  end
62
61
 
@@ -198,8 +197,9 @@ class WEEL
198
197
  @message = message
199
198
  end
200
199
  def nudge!
201
- @nudge.clear
202
- @nudge.push(nil)
200
+ 1.upto(@nudge.num_waiting) do
201
+ @nudge.push(nil)
202
+ end
203
203
  end
204
204
  def wait_until_nudged!
205
205
  @nudge.pop
@@ -223,6 +223,8 @@ class WEEL
223
223
  else
224
224
  if args.empty? && @__weel_values.key?(name)
225
225
  @__weel_values[name]
226
+ elsif args.empty? && @__weel_values.key?(name.to_s)
227
+ @__weel_values[name.to_s]
226
228
  elsif name.to_s[-1..-1] == "=" && args.length == 1
227
229
  temp = name.to_s[0..-2]
228
230
  @__weel_values[temp.to_sym] = args[0]
@@ -237,11 +239,11 @@ class WEEL
237
239
  end
238
240
  end # }}}
239
241
 
240
- class HandlerWrapperBase # {{{
242
+ class ConnectionWrapperBase # {{{
241
243
  def self::loop_guard(arguments,lid,count); false; end
242
244
  def self::inform_state_change(arguments,newstate); end
243
245
  def self::inform_syntax_error(arguments,err,code); end
244
- def self::inform_handlerwrapper_error(arguments,err); end
246
+ def self::inform_connectionwrapper_error(arguments,err); end
245
247
  def self::inform_position_change(arguments,ipc={}); end
246
248
 
247
249
  def initialize(arguments,position=nil,continue=nil); end
@@ -275,6 +277,7 @@ class WEEL
275
277
  def simulate(type,nesting,sequence,parent,parameters={}); end
276
278
 
277
279
  def callback(result=nil,options={}); end
280
+ def mem_guard; end
278
281
 
279
282
  def test_condition(mr,code); mr.instance_eval(code); end
280
283
  def manipulate(mr,code,result=nil,options=nil); mr.instance_eval(code); end
@@ -352,19 +355,21 @@ class WEEL
352
355
  end
353
356
  end
354
357
  end # }}}
355
- def self::handlerwrapper(aClassname, *args)# {{{
356
- define_method :initialize_handlerwrapper do
357
- self.handlerwrapper = aClassname
358
- self.handlerwrapper_args = args unless args.empty?
358
+ def self::connectionwrapper(aClassname, *args)# {{{
359
+ define_method :initialize_connectionwrapper do
360
+ self.connectionwrapper = aClassname
361
+ self.connectionwrapper_args = args unless args.empty?
359
362
  end
360
363
  end # }}}
361
364
  def self::control(flow, &block)# {{{
362
- @@__weel_control_block = block
363
365
  define_method :initialize_control do
364
- self.description = @@__weel_control_block
366
+ self.description = block
365
367
  end
366
368
  end # }}}
367
- def self::flow # {{{
369
+ def self::flow(flow_data=nil) # {{{
370
+ define_method :initialize_flow_data do
371
+ self.flow_data = flow_data
372
+ end if flow_data
368
373
  end #}}}
369
374
 
370
375
  class DSLRealization # {{{
@@ -374,14 +379,14 @@ class WEEL
374
379
  @__weel_main = nil
375
380
  @__weel_data ||= Hash.new
376
381
  @__weel_endpoints ||= Hash.new
377
- @__weel_handlerwrapper = HandlerWrapperBase
378
- @__weel_handlerwrapper_args = []
382
+ @__weel_connectionwrapper = ConnectionWrapperBase
383
+ @__weel_connectionwrapper_args = []
379
384
  @__weel_state = :ready
380
385
  @__weel_status = Status.new(0,"undefined")
381
386
  @__weel_replay = false
382
387
  @__weel_sim = -1
383
388
  end #}}}
384
- attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_handlerwrapper, :__weel_handlerwrapper_args, :__weel_replay
389
+ attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_connectionwrapper, :__weel_connectionwrapper_args, :__weel_replay
385
390
  attr_reader :__weel_state, :__weel_status
386
391
 
387
392
  # DSL-Constructs for atomic calls to external services (calls) and pure context manipulations (manipulate).
@@ -416,7 +421,9 @@ class WEEL
416
421
 
417
422
  __weel_protect_yield(&block)
418
423
 
419
- Thread.current[:branch_wait_count] = (type.is_a?(Hash) && type.size == 1 && type[:wait] != nil && (type[:wait].is_a?(Integer) && type[:wait] > 0) ? type[:wait] : Thread.current[:branches].size)
424
+ Thread.current[:branch_wait_count] = (type.is_a?(Hash) && type[:wait] != nil && (type[:wait].is_a?(Integer) && type[:wait] > 0) ? type[:wait] : Thread.current[:branches].size)
425
+ Thread.current[:branch_wait_count_cancel] = 0
426
+ Thread.current[:branch_wait_count_cancel_condition] = (type.is_a?(Hash) && type[:cancel] != nil && type[:cancel] == :first ) ? :first : :last
420
427
  1.upto Thread.current[:branches].size do
421
428
  Thread.current[:branch_event].wait
422
429
  end
@@ -459,11 +466,12 @@ class WEEL
459
466
  current_branch_sim_pos = branch_parent[:branch_sim_pos]
460
467
  end
461
468
 
462
- Thread.current[:branches] << Thread.new(*vars) do |*local|
469
+ branch_parent[:branches] << Thread.new(*vars) do |*local|
463
470
  Thread.current.abort_on_exception = true
464
471
  Thread.current[:branch_status] = false
465
472
  Thread.current[:branch_parent] = branch_parent
466
473
  Thread.current[:start_event] = Continue.new
474
+ Thread.current[:branch_wait_count_cancel_active] = false
467
475
 
468
476
  if __weel_sim
469
477
  Thread.current[:branch_sim_pos] = @__weel_sim += 1
@@ -479,15 +487,15 @@ class WEEL
479
487
  Thread.current[:start_event].wait unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
480
488
 
481
489
  if __weel_sim
482
- handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args
483
- handlerwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
490
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
491
+ connectionwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
484
492
  end
485
493
 
486
494
  unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
487
495
  __weel_protect_yield(*local, &block)
488
496
  end
489
497
 
490
- __weel_sim_stop(:parallel_branch,handlerwrapper,current_branch_sim_pos) if __weel_sim
498
+ __weel_sim_stop(:parallel_branch,connectionwrapper,current_branch_sim_pos) if __weel_sim
491
499
 
492
500
  branch_parent[:mutex].synchronize do
493
501
  Thread.current[:branch_status] = true
@@ -502,7 +510,7 @@ class WEEL
502
510
  begin
503
511
  ipc = {}
504
512
  ipc[:unmark] = [Thread.current[:branch_position]]
505
- @__weel_handlerwrapper::inform_position_change(@__weel_handlerwrapper_args,ipc)
513
+ @__weel_connectionwrapper::inform_position_change(@__weel_connectionwrapper_args,ipc)
506
514
  end rescue nil
507
515
  Thread.current[:branch_position] = nil
508
516
  end
@@ -600,13 +608,13 @@ class WEEL
600
608
  while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
601
609
  loop_guard += 1
602
610
  __weel_protect_yield(&block)
603
- sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
611
+ sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
604
612
  end
605
613
  when :post_test
606
614
  begin
607
615
  loop_guard += 1
608
616
  __weel_protect_yield(&block)
609
- sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
617
+ sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
610
618
  end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
611
619
  end
612
620
  end
@@ -656,27 +664,27 @@ class WEEL
656
664
  yield(*local) if block_given?
657
665
  rescue NameError => err # don't look into it, or it will explode
658
666
  self.__weel_state = :stopping
659
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new("protect_yield: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
667
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("protect_yield: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
660
668
  nil
661
669
  rescue => err
662
670
  self.__weel_state = :stopping
663
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new(err.message),nil)
671
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
664
672
  nil
665
673
  end
666
674
  end #}}}
667
675
 
668
676
  def __weel_eval_condition(condition) #{{{
669
677
  begin
670
- handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args unless condition.is_a?(Proc)
671
- condition.is_a?(Proc) ? condition.call : handlerwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional),condition)
678
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args unless condition.is_a?(Proc)
679
+ condition.is_a?(Proc) ? condition.call : connectionwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional),condition)
672
680
  rescue NameError => err # don't look into it, or it will explode
673
681
  # if you access $! here, BOOOM
674
682
  self.__weel_state = :stopping
675
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new("eval_condition: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
683
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("eval_condition: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),nil)
676
684
  nil
677
685
  rescue => err
678
686
  self.__weel_state = :stopping
679
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new(err.message),nil)
687
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
680
688
  nil
681
689
  end
682
690
  end #}}}
@@ -714,7 +722,7 @@ class WEEL
714
722
  @__weel_positions << wp
715
723
  Thread.current[:branch_position] = wp
716
724
 
717
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, ipc
725
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, ipc
718
726
  wp
719
727
  end #}}}
720
728
 
@@ -726,10 +734,10 @@ class WEEL
726
734
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
727
735
 
728
736
  Thread.current[:continue] = Continue.new
729
- handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args, position, Thread.current[:continue]
737
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args, position, Thread.current[:continue]
730
738
 
731
739
  if __weel_sim
732
- handlerwrapper.simulate(:activity,:none,@__weel_sim += 1,Thread.current[:branch_sim_pos],:position => position,:parameters => parameters,:endpoint => endpoint,:type => type,:finalize => finalize.is_a?(String) ? finalize : nil)
740
+ connectionwrapper.simulate(:activity,:none,@__weel_sim += 1,Thread.current[:branch_sim_pos],:position => position,:parameters => parameters,:endpoint => endpoint,:type => type,:finalize => finalize.is_a?(String) ? finalize : nil)
733
741
  return
734
742
  end
735
743
 
@@ -740,34 +748,35 @@ class WEEL
740
748
 
741
749
  case type
742
750
  when :manipulate
743
- raise Signal::Stop unless handlerwrapper.vote_sync_before
751
+ raise Signal::Stop unless connectionwrapper.vote_sync_before
744
752
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
745
753
 
746
754
  if finalize.is_a?(Proc) || finalize.is_a?(String)
747
- handlerwrapper.activity_manipulate_handle(parameters)
748
- handlerwrapper.inform_activity_manipulate
755
+ connectionwrapper.activity_manipulate_handle(parameters)
756
+ connectionwrapper.inform_activity_manipulate
749
757
  if finalize.is_a?(Proc)
750
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
758
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
751
759
  mr.instance_eval(&finalize)
752
760
  elsif finalize.is_a?(String)
753
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
754
- handlerwrapper.manipulate(mr,finalize)
761
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
762
+ connectionwrapper.manipulate(mr,finalize)
755
763
  end
756
- handlerwrapper.inform_manipulate_change(
764
+ connectionwrapper.inform_manipulate_change(
757
765
  ((mr && mr.changed_status) ? @__weel_status : nil),
758
766
  ((mr && mr.changed_data.any?) ? mr.changed_data.uniq : nil),
759
767
  ((mr && mr.changed_endpoints.any?) ? mr.changed_endpoints.uniq : nil),
760
768
  @__weel_data,
761
769
  @__weel_endpoints
762
770
  )
763
- handlerwrapper.inform_activity_done
771
+ connectionwrapper.inform_activity_done
764
772
  wp.detail = :after
765
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :after => [wp]
773
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
766
774
  end
767
775
  when :call
768
776
  begin
769
777
  again = catch Signal::Again do
770
- rs = ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional)
778
+ connectionwrapper.mem_guard
779
+ rs = ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional)
771
780
  if prepare
772
781
  if prepare.is_a?(Proc)
773
782
  rs.instance_exec(&prepare)
@@ -775,14 +784,14 @@ class WEEL
775
784
  rs.instance_eval prepare
776
785
  end
777
786
  end
778
- params = handlerwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
779
- raise Signal::Stop unless handlerwrapper.vote_sync_before(params)
787
+ params = connectionwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
788
+ raise Signal::Stop unless connectionwrapper.vote_sync_before(params)
780
789
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
781
790
 
782
- handlerwrapper.activity_handle wp.passthrough, params
783
- wp.passthrough = handlerwrapper.activity_passthrough_value
791
+ connectionwrapper.activity_handle wp.passthrough, params
792
+ wp.passthrough = connectionwrapper.activity_passthrough_value
784
793
  unless wp.passthrough.nil?
785
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :wait => [wp]
794
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :wait => [wp]
786
795
  end
787
796
  begin
788
797
  # with loop if catching Signal::Again
@@ -792,12 +801,12 @@ class WEEL
792
801
  raise waitingresult[1] if !waitingresult.nil? && waitingresult.is_a?(Array) && waitingresult.length == 2 && waitingresult[0] == WEEL::Signal::Error
793
802
 
794
803
  if Thread.current[:nolongernecessary]
795
- handlerwrapper.activity_no_longer_necessary
804
+ connectionwrapper.activity_no_longer_necessary
796
805
  raise Signal::NoLongerNecessary
797
806
  end
798
807
  if self.__weel_state == :stopping || self.__weel_state == :finishing
799
- handlerwrapper.activity_stop
800
- wp.passthrough = handlerwrapper.activity_passthrough_value
808
+ connectionwrapper.activity_stop
809
+ wp.passthrough = connectionwrapper.activity_passthrough_value
801
810
  raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
802
811
  end
803
812
 
@@ -809,26 +818,26 @@ class WEEL
809
818
  finalize
810
819
  end
811
820
  if code.is_a?(Proc) || code.is_a?(String)
812
- handlerwrapper.inform_activity_manipulate
821
+ connectionwrapper.inform_activity_manipulate
813
822
  if code.is_a?(Proc)
814
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
823
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
815
824
  ma = catch Signal::Again do
816
825
  case code.arity
817
- when 1; mr.instance_exec(handlerwrapper.activity_result_value,&code)
818
- when 2; mr.instance_exec(handlerwrapper.activity_result_value,&code)
826
+ when 1; mr.instance_exec(connectionwrapper.activity_result_value,&code)
827
+ when 2; mr.instance_exec(connectionwrapper.activity_result_value,&code)
819
828
  else
820
829
  mr.instance_exec(&code)
821
830
  end
822
831
  'yes' # ma sadly will have nil when i just throw
823
832
  end
824
833
  elsif code.is_a?(String)
825
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
834
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
826
835
  ma = catch Signal::Again do
827
- handlerwrapper.manipulate(mr,code,handlerwrapper.activity_result_value,handlerwrapper.activity_result_options)
836
+ connectionwrapper.manipulate(mr,code,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
828
837
  'yes' # ma sadly will have nil when i just throw
829
838
  end
830
839
  end
831
- handlerwrapper.inform_manipulate_change(
840
+ connectionwrapper.inform_manipulate_change(
832
841
  (mr.changed_status ? @__weel_status : nil),
833
842
  (mr.changed_data.any? ? mr.changed_data.uniq : nil),
834
843
  (mr.changed_endpoints.any? ? mr.changed_endpoints.uniq : nil),
@@ -838,18 +847,18 @@ class WEEL
838
847
  throw(Signal::Again, Signal::Again) if ma.nil?
839
848
  end
840
849
  end while waitingresult == Signal::Again
841
- if handlerwrapper.activity_passthrough_value.nil?
842
- handlerwrapper.inform_activity_done
850
+ if connectionwrapper.activity_passthrough_value.nil?
851
+ connectionwrapper.inform_activity_done
843
852
  wp.passthrough = nil
844
853
  wp.detail = :after
845
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :after => [wp]
854
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
846
855
  end
847
856
  end
848
857
  end while again == Signal::Again
849
858
  end
850
859
  raise Signal::Proceed
851
860
  rescue Signal::SkipManipulate, Signal::Proceed
852
- if self.__weel_state != :stopping && self.__weel_state != :finishing && !handlerwrapper.vote_sync_after
861
+ if self.__weel_state != :stopping && self.__weel_state != :finishing && !connectionwrapper.vote_sync_after
853
862
  self.__weel_state = :stopping
854
863
  wp.detail = :unmark
855
864
  end
@@ -857,18 +866,37 @@ class WEEL
857
866
  @__weel_positions.delete wp
858
867
  Thread.current[:branch_position] = nil
859
868
  wp.detail = :unmark
860
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :unmark => [wp]
869
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :unmark => [wp]
861
870
  rescue Signal::StopSkipManipulate, Signal::Stop
862
871
  self.__weel_state = :stopping
863
872
  rescue Signal::Skip
864
873
  nil
865
874
  rescue SyntaxError => se
866
- handlerwrapper.inform_activity_failed se
875
+ connectionwrapper.inform_activity_failed se
867
876
  self.__weel_state = :stopping
868
877
  rescue => err
869
- @__weel_handlerwrapper::inform_handlerwrapper_error @__weel_handlerwrapper_args, err
878
+ @__weel_connectionwrapper::inform_connectionwrapper_error @__weel_connectionwrapper_args, err
870
879
  self.__weel_state = :stopping
871
880
  ensure
881
+ connectionwrapper.mem_guard unless connectionwrapper.nil?
882
+ if Thread.current[:branch_parent]
883
+ Thread.current[:branch_parent][:mutex].synchronize do
884
+ if Thread.current[:branch_parent][:branch_wait_count_cancel_condition] == :first
885
+ if !Thread.current[:branch_wait_count_cancel_active]
886
+ Thread.current[:branch_wait_count_cancel_active] = true
887
+ Thread.current[:branch_parent][:branch_wait_count_cancel] += 1
888
+ end
889
+ if Thread.current[:branch_parent][:branch_wait_count_cancel] == Thread.current[:branch_parent][:branch_wait_count] && self.__weel_state != :stopping && self.__weel_state != :finishing
890
+ Thread.current[:branch_parent][:branches].each do |thread|
891
+ if thread.alive? && thread != Thread.current
892
+ thread[:nolongernecessary] = true
893
+ __weel_recursive_continue(thread)
894
+ end
895
+ end
896
+ end
897
+ end
898
+ end
899
+ end
872
900
  Thread.current[:continue].clear if Thread.current[:continue] && Thread.current[:continue].is_a?(Continue)
873
901
  end
874
902
  end # }}}
@@ -914,7 +942,7 @@ class WEEL
914
942
  position
915
943
  else
916
944
  self.__weel_state = :stopping
917
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new("position (#{position}) not valid"),nil)
945
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("position (#{position}) not valid"),nil)
918
946
  end
919
947
  end # }}}
920
948
 
@@ -943,13 +971,13 @@ class WEEL
943
971
  def __weel_sim_start(what,options={}) #{{{
944
972
  current_branch_sim_pos = Thread.current[:branch_sim_pos]
945
973
  Thread.current[:branch_sim_pos] = @__weel_sim += 1
946
- handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args
947
- handlerwrapper.simulate(what,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
948
- [handlerwrapper, current_branch_sim_pos]
974
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
975
+ connectionwrapper.simulate(what,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
976
+ [connectionwrapper, current_branch_sim_pos]
949
977
  end #}}}
950
978
 
951
- def __weel_sim_stop(what,handlerwrapper,current_branch_sim_pos,options={}) #{{{
952
- handlerwrapper.simulate(what,:end,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
979
+ def __weel_sim_stop(what,connectionwrapper,current_branch_sim_pos,options={}) #{{{
980
+ connectionwrapper.simulate(what,:end,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
953
981
  Thread.current[:branch_sim_pos] = current_branch_sim_pos
954
982
  end #}}}
955
983
 
@@ -957,7 +985,7 @@ class WEEL
957
985
  def __weel_finalize #{{{
958
986
  __weel_recursive_join(@__weel_main)
959
987
  @__weel_state = :stopped
960
- @__weel_handlerwrapper::inform_state_change @__weel_handlerwrapper_args, @__weel_state
988
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
961
989
  end #}}}
962
990
 
963
991
  def __weel_state=(newState)# {{{
@@ -972,7 +1000,7 @@ class WEEL
972
1000
  __weel_replay = false
973
1001
  end
974
1002
 
975
- @__weel_handlerwrapper::inform_state_change @__weel_handlerwrapper_args, @__weel_state
1003
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
976
1004
  end # }}}
977
1005
 
978
1006
  end # }}}
@@ -982,27 +1010,27 @@ public
982
1010
  @dslr.__weel_positions
983
1011
  end # }}}
984
1012
 
985
- # set the handlerwrapper
986
- def handlerwrapper # {{{
987
- @dslr.__weel_handlerwrapper
1013
+ # set the connectionwrapper
1014
+ def connectionwrapper # {{{
1015
+ @dslr.__weel_connectionwrapper
988
1016
  end # }}}
989
- def handlerwrapper=(new_weel_handlerwrapper) # {{{
990
- superclass = new_weel_handlerwrapper
1017
+ def connectionwrapper=(new_weel_connectionwrapper) # {{{
1018
+ superclass = new_weel_connectionwrapper
991
1019
  while superclass
992
- check_ok = true if superclass == WEEL::HandlerWrapperBase
1020
+ check_ok = true if superclass == WEEL::ConnectionWrapperBase
993
1021
  superclass = superclass.superclass
994
1022
  end
995
- raise "Handlerwrapper is not inherited from HandlerWrapperBase" unless check_ok
996
- @dslr.__weel_handlerwrapper = new_weel_handlerwrapper
1023
+ raise "ConnectionWrapper is not inherited from ConnectionWrapperBase" unless check_ok
1024
+ @dslr.__weel_connectionwrapper = new_weel_connectionwrapper
997
1025
  end # }}}
998
1026
 
999
- # Get/Set the handlerwrapper arguments
1000
- def handlerwrapper_args # {{{
1001
- @dslr.__weel_handlerwrapper_args
1027
+ # Get/Set the connectionwrapper arguments
1028
+ def connectionwrapper_args # {{{
1029
+ @dslr.__weel_connectionwrapper_args
1002
1030
  end # }}}
1003
- def handlerwrapper_args=(args) # {{{
1031
+ def connectionwrapper_args=(args) # {{{
1004
1032
  if args.class == Array
1005
- @dslr.__weel_handlerwrapper_args = args
1033
+ @dslr.__weel_connectionwrapper_args = args
1006
1034
  end
1007
1035
  nil
1008
1036
  end # }}}
@@ -1012,7 +1040,7 @@ public
1012
1040
  @dslr.__weel_state
1013
1041
  end # }}}
1014
1042
  def state_signal # {{{
1015
- handlerwrapper::inform_state_change handlerwrapper_args, state
1043
+ connectionwrapper::inform_state_change connectionwrapper_args, state
1016
1044
  state
1017
1045
  end # }}}
1018
1046
  def abandon # {{{
@@ -1076,19 +1104,19 @@ public
1076
1104
  end
1077
1105
  rescue SyntaxError => se
1078
1106
  @dslr.__weel_state = :stopping
1079
- @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new(se.message),code)
1107
+ @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(se.message),code)
1080
1108
  rescue NameError => err # don't look into it, or it will explode
1081
1109
  @dslr.__weel_state = :stopping
1082
- @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new("main: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),code)
1110
+ @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new("main: `#{err.name}` is not a thing that can be used. Maybe it is meant to be a string and you forgot quotes?"),code)
1083
1111
  rescue => err
1084
1112
  @dslr.__weel_state = :stopping
1085
- @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new(err.message),code)
1113
+ @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(err.message),code)
1086
1114
  end
1087
1115
  if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
1088
1116
  ipc = { :unmark => [] }
1089
1117
  @dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp }
1090
1118
  @dslr.__weel_positions.clear
1091
- @dslr.__weel_handlerwrapper::inform_position_change(@dslr.__weel_handlerwrapper_args,ipc)
1119
+ @dslr.__weel_connectionwrapper::inform_position_change(@dslr.__weel_connectionwrapper_args,ipc)
1092
1120
  @dslr.__weel_state = :finished
1093
1121
  end
1094
1122
  if @dslr.__weel_state == :simulating
@@ -1121,7 +1149,7 @@ public
1121
1149
  rescue => e
1122
1150
  puts e.message
1123
1151
  puts e.backtrace
1124
- handlerwrapper::inform_handlerwrapper_error handlerwrapper_args, e
1152
+ connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e
1125
1153
  end
1126
1154
  end
1127
1155
  end # }}}
@@ -1,13 +1,13 @@
1
1
  # Apache License, Version 2.0
2
- #
2
+ #
3
3
  # Copyright (c) 2013 Juergen Mangler
4
- #
4
+ #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
7
7
  # You may obtain a copy of the License at
8
- #
8
+ #
9
9
  # http://www.apache.org/licenses/LICENSE-2.0
10
- #
10
+ #
11
11
  # Unless required by applicable law or agreed to in writing, software
12
12
  # distributed under the License is distributed on an "AS IS" BASIS,
13
13
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,18 +15,18 @@
15
15
  # limitations under the License.
16
16
 
17
17
  ######
18
- # ADVENTURE Simulation Trace Generator Handler Wrapper
18
+ # ADVENTURE Simulation Trace Generator Connection Wrapper
19
19
  ######
20
20
 
21
21
  module TraceBasics #{{{
22
22
  def <<(item)
23
23
  @elements << item
24
- item.parent = self
24
+ item.parent = self
25
25
  end
26
26
  def each
27
27
  @elements.each do |ele|
28
28
  yield ele
29
- end
29
+ end
30
30
  end
31
31
  end #}}}
32
32
 
@@ -42,11 +42,11 @@ class Trace #{{{
42
42
  end
43
43
  def recursive_get_container(container,tid)
44
44
  return container if container.respond_to?(:tid) and container.tid == tid
45
- container.each do |ele|
45
+ container.each do |ele|
46
46
  if ele.kind_of?(TraceContainer)
47
- ret = recursive_get_container(ele,tid)
47
+ ret = recursive_get_container(ele,tid)
48
48
  return ret unless ret.nil?
49
- end
49
+ end
50
50
  end
51
51
  nil
52
52
  end
@@ -79,7 +79,7 @@ class Trace #{{{
79
79
  tmp = recursive_generate_list(ele,options)
80
80
  add_traces(traces,tmp)
81
81
  options[:otherwise] = true
82
- end
82
+ end
83
83
  end
84
84
  traces
85
85
  end
@@ -137,7 +137,7 @@ class TraceChoose < TraceContainer
137
137
  def initialize(tid,mode)
138
138
  super tid
139
139
  @mode = mode
140
- end
140
+ end
141
141
  end
142
142
  class TraceAlternative < TraceContainer; end
143
143
  class TraceOtherwise < TraceContainer; end
@@ -145,10 +145,10 @@ class TraceOtherwise < TraceContainer; end
145
145
  class PlainTrace
146
146
  def initialize
147
147
  @container
148
- end
148
+ end
149
149
  end
150
150
 
151
- class SimHandlerWrapper < WEEL::HandlerWrapperBase
151
+ class SimConnectionWrapper < WEEL::ConnectionWrapperBase
152
152
  def initialize(args,endpoint=nil,position=nil,continue=nil)
153
153
  @__myhandler_stopped = false
154
154
  @__myhandler_position = position
@@ -172,19 +172,19 @@ class SimHandlerWrapper < WEEL::HandlerWrapperBase
172
172
  clast = $trace.get_container(parent)
173
173
  until clast.kind_of?(TraceParallel)
174
174
  clast = clast.parent
175
- end
175
+ end
176
176
  clast << TraceParallelBranch.new(tid,parent)
177
177
  else
178
178
  clast = $trace.get_container(tid)
179
179
  clast.close! if clast.open?
180
- end
180
+ end
181
181
  when :choose
182
182
  simulate_add_to_container($trace,nesting,parent,tid) { TraceChoose.new(tid,parameters[:mode]) }
183
183
  when :alternative
184
184
  simulate_add_to_container($trace,nesting,parent,tid) { TraceAlternative.new(tid) }
185
185
  when :otherwise
186
186
  simulate_add_to_container($trace,nesting,parent,tid) { TraceOtherwise.new(tid) }
187
- end
187
+ end
188
188
  end
189
189
 
190
190
  private
@@ -196,7 +196,7 @@ class SimHandlerWrapper < WEEL::HandlerWrapperBase
196
196
  else
197
197
  clast = trace.get_container(tid)
198
198
  clast.close! if clast.open?
199
- end
199
+ end
200
200
  end #}}}
201
201
 
202
202
  end
@@ -1,4 +1,4 @@
1
- class TestHandlerWrapper < WEEL::HandlerWrapperBase
1
+ class TestConnectionWrapper < WEEL::ConnectionWrapperBase
2
2
  def self::inform_state_change(arguments,newstate)
3
3
  $long_track += "---> STATE #{newstate}\n"
4
4
  $short_track << "|#{newstate}|"
@@ -8,7 +8,7 @@ class TestHandlerWrapper < WEEL::HandlerWrapperBase
8
8
  $short_track << "E"
9
9
  raise(err)
10
10
  end
11
- def self::inform_handlerwrapper_error(arguments,err)
11
+ def self::inform_connectionwrapper_error(arguments,err)
12
12
  $long_track += "HW ERROR: #{err}\n"
13
13
  $short_track << "E"
14
14
  end
data/test/TestWorkflow.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  require File.expand_path(::File.dirname(__FILE__) + '/../lib/weel')
2
2
  require File.expand_path(::File.dirname(__FILE__) + '/TestMixin')
3
- require File.expand_path(::File.dirname(__FILE__) + '/TestHandlerWrapper')
3
+ require File.expand_path(::File.dirname(__FILE__) + '/TestConnectionWrapper')
4
4
 
5
5
  class TestWorkflow < WEEL
6
- handlerwrapper TestHandlerWrapper
6
+ connectionwrapper TestConnectionWrapper
7
7
 
8
8
  endpoint :endpoint1 => 'http://www.heise.de'
9
9
  endpoint :stop => 'stop it'
@@ -6,14 +6,14 @@ class TestCaseHandler < Test::Unit::TestCase
6
6
 
7
7
  def test_handler
8
8
  assert_raise RuntimeError do
9
- @wf.handlerwrapper = String
9
+ @wf.connectionwrapper = String
10
10
  end
11
11
  assert_nothing_raised do
12
- @wf.handlerwrapper = TestHandlerWrapper
12
+ @wf.connectionwrapper = TestConnectionWrapper
13
13
  end
14
14
  end
15
15
  def test_handlerargs
16
- @wf.handlerwrapper_args = ["1", "2"]
17
- assert(@wf.handlerwrapper_args.is_a?(Array), "Handler arguments is not an array, it is a #{@wf.handlerwrapper_args.inspect}")
16
+ @wf.connectionwrapper_args = ["1", "2"]
17
+ assert(@wf.connectionwrapper_args.is_a?(Array), "Handler arguments is not an array, it is a #{@wf.connectionwrapper_args.inspect}")
18
18
  end
19
19
  end
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.96"
3
+ s.version = "1.99.100"
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,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.99.96
4
+ version: 1.99.100
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
8
8
  - Gerhard Stuermer
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-10-01 00:00:00.000000000 Z
12
+ date: 2022-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
@@ -45,8 +45,8 @@ files:
45
45
  - lib/weel.rb
46
46
  - test/ContinueTest.rb
47
47
  - test/README
48
- - test/SimHandlerWrapper.rb
49
- - test/TestHandlerWrapper.rb
48
+ - test/SimConnectionWrapper.rb
49
+ - test/TestConnectionWrapper.rb
50
50
  - test/TestMixin.rb
51
51
  - test/TestWorkflow.rb
52
52
  - test/basic/tc_choose.rb
@@ -86,7 +86,7 @@ homepage: http://cpee.org/
86
86
  licenses:
87
87
  - LGPL-3.0
88
88
  metadata: {}
89
- post_install_message:
89
+ post_install_message:
90
90
  rdoc_options: []
91
91
  require_paths:
92
92
  - lib
@@ -101,46 +101,46 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.1.2
105
- signing_key:
104
+ rubygems_version: 3.2.22
105
+ signing_key:
106
106
  specification_version: 4
107
107
  summary: Workflow Execution Engine Library (WEEL)
108
108
  test_files:
109
- - test/TestHandlerWrapper.rb
110
- - test/test
111
109
  - test/ContinueTest.rb
112
- - test/TestWorkflow.rb
113
- - test/TestMixin.rb
114
- - test/SimHandlerWrapper.rb
115
110
  - test/README
116
- - test/wfp_iteration/tc_structuredloop.rb
117
- - test/wfp_adv_branching/tc_structured_partial_join.rb
118
- - test/wfp_adv_branching/tc_threadmerge.rb
119
- - test/wfp_adv_branching/tc_threadsplit.rb
120
- - test/wfp_adv_branching/tc_multichoice_structuredsynchronizingmerge.rb
121
- - test/wfp_adv_branching/tc_localsynchronizingmerge.rb
111
+ - test/SimConnectionWrapper.rb
112
+ - test/TestConnectionWrapper.rb
113
+ - test/TestMixin.rb
114
+ - test/TestWorkflow.rb
115
+ - test/test
116
+ - test/basic/tc_choose.rb
117
+ - test/basic/tc_codereplace.rb
118
+ - test/basic/tc_data.rb
119
+ - test/basic/tc_endpoint.rb
120
+ - test/basic/tc_handler.rb
121
+ - test/basic/tc_parallel.rb
122
+ - test/basic/tc_search.rb
123
+ - test/basic/tc_state.rb
124
+ - test/basic/tc_wf_control.rb
125
+ - test/complex/tc_generalsynchonizingmerge_loopsearch.rb
126
+ - test/complex/tc_parallel_stop.rb
127
+ - test/complexsearch/tc_search.rb
128
+ - test/exec/tc_again.rb
129
+ - test/exec/tc_exec.rb
130
+ - test/speed/tc_speed1.rb
131
+ - test/speed/tc_speed2.rb
122
132
  - test/wfp_adv_branching/tc_generalizedjoin.rb
123
133
  - test/wfp_adv_branching/tc_generalsynchronizingmerge.rb
134
+ - test/wfp_adv_branching/tc_localsynchronizingmerge.rb
135
+ - test/wfp_adv_branching/tc_multichoice_structuredsynchronizingmerge.rb
124
136
  - test/wfp_adv_branching/tc_multimerge.rb
125
137
  - test/wfp_adv_branching/tc_structured_discriminator.rb
126
- - test/wfp_state_based/tc_deferredchoice.rb
127
- - test/wfp_state_based/tc_interleavedparallelrouting.rb
128
- - test/speed/tc_speed1.rb
129
- - test/speed/tc_speed2.rb
130
- - test/exec/tc_again.rb
131
- - test/exec/tc_exec.rb
132
- - test/wfp_basic/tc_parallelsplit_synchronization.rb
138
+ - test/wfp_adv_branching/tc_structured_partial_join.rb
139
+ - test/wfp_adv_branching/tc_threadmerge.rb
140
+ - test/wfp_adv_branching/tc_threadsplit.rb
133
141
  - test/wfp_basic/tc_exclusivechoice_simplemerge.rb
142
+ - test/wfp_basic/tc_parallelsplit_synchronization.rb
134
143
  - test/wfp_basic/tc_sequence.rb
135
- - test/complex/tc_generalsynchonizingmerge_loopsearch.rb
136
- - test/complex/tc_parallel_stop.rb
137
- - test/basic/tc_state.rb
138
- - test/basic/tc_endpoint.rb
139
- - test/basic/tc_data.rb
140
- - test/basic/tc_choose.rb
141
- - test/basic/tc_search.rb
142
- - test/basic/tc_handler.rb
143
- - test/basic/tc_codereplace.rb
144
- - test/basic/tc_wf_control.rb
145
- - test/basic/tc_parallel.rb
146
- - test/complexsearch/tc_search.rb
144
+ - test/wfp_iteration/tc_structuredloop.rb
145
+ - test/wfp_state_based/tc_deferredchoice.rb
146
+ - test/wfp_state_based/tc_interleavedparallelrouting.rb