weel 1.99.94 → 1.99.99

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: 5c6ec72184bb20d41fdef30320134806cf5f450a3a141efe9bde5adf6f24c44d
4
- data.tar.gz: 2732e2b2ad2ec01d554b1b7c94c06a831d5d69ca36404c3c35ad9605cd9f444d
3
+ metadata.gz: b6d41da4a64d101b885ac475da4625fff4bb4098b9430563f3fc950f7804517e
4
+ data.tar.gz: b0714d35fa2e112b63b31e19699814607b66545eb60614d834e852d308d1ce7b
5
5
  SHA512:
6
- metadata.gz: c77da26f6558eec836f5479a0bee9b9f9a62b11fd68e6ecc2002b52f40eabd999dae7118f6ff6f1979953d94abebb33c7f4ec47650c0d78f1cd5e1b7e1cd34b9
7
- data.tar.gz: 3d8209e7eae538b910c3ac0d0c7a7f401b601aae696e956262dc5605e56832201071fbf0277468f9f8ffa95e51933fb8acc45b1b2d8da04be0c21d5998075bd2
6
+ metadata.gz: 9d79e7d56585b62912f638066fb4fee0e9a71786c10ea638819ff04189df8d335282d140d7b28734abd92e18eb8078c761e9b9e3b16666166afafcfd0c631acc
7
+ data.tar.gz: b3d67a26a4016f7711273025427da307fe989f82319221ee07a1617eefe8f0bd2e04c845acee55d1e3a84619064a31744d53cf2a43344ed09c8568ef57f6a5c3
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
 
@@ -223,6 +222,8 @@ class WEEL
223
222
  else
224
223
  if args.empty? && @__weel_values.key?(name)
225
224
  @__weel_values[name]
225
+ elsif args.empty? && @__weel_values.key?(name.to_s)
226
+ @__weel_values[name.to_s]
226
227
  elsif name.to_s[-1..-1] == "=" && args.length == 1
227
228
  temp = name.to_s[0..-2]
228
229
  @__weel_values[temp.to_sym] = args[0]
@@ -237,11 +238,11 @@ class WEEL
237
238
  end
238
239
  end # }}}
239
240
 
240
- class HandlerWrapperBase # {{{
241
+ class ConnectionWrapperBase # {{{
241
242
  def self::loop_guard(arguments,lid,count); false; end
242
243
  def self::inform_state_change(arguments,newstate); end
243
244
  def self::inform_syntax_error(arguments,err,code); end
244
- def self::inform_handlerwrapper_error(arguments,err); end
245
+ def self::inform_connectionwrapper_error(arguments,err); end
245
246
  def self::inform_position_change(arguments,ipc={}); end
246
247
 
247
248
  def initialize(arguments,position=nil,continue=nil); end
@@ -275,6 +276,7 @@ class WEEL
275
276
  def simulate(type,nesting,sequence,parent,parameters={}); end
276
277
 
277
278
  def callback(result=nil,options={}); end
279
+ def mem_guard; end
278
280
 
279
281
  def test_condition(mr,code); mr.instance_eval(code); end
280
282
  def manipulate(mr,code,result=nil,options=nil); mr.instance_eval(code); end
@@ -352,19 +354,21 @@ class WEEL
352
354
  end
353
355
  end
354
356
  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?
357
+ def self::connectionwrapper(aClassname, *args)# {{{
358
+ define_method :initialize_connectionwrapper do
359
+ self.connectionwrapper = aClassname
360
+ self.connectionwrapper_args = args unless args.empty?
359
361
  end
360
362
  end # }}}
361
363
  def self::control(flow, &block)# {{{
362
- @@__weel_control_block = block
363
364
  define_method :initialize_control do
364
- self.description = @@__weel_control_block
365
+ self.description = block
365
366
  end
366
367
  end # }}}
367
- def self::flow # {{{
368
+ def self::flow(flow_data=nil) # {{{
369
+ define_method :initialize_flow_data do
370
+ self.flow_data = flow_data
371
+ end if flow_data
368
372
  end #}}}
369
373
 
370
374
  class DSLRealization # {{{
@@ -374,14 +378,14 @@ class WEEL
374
378
  @__weel_main = nil
375
379
  @__weel_data ||= Hash.new
376
380
  @__weel_endpoints ||= Hash.new
377
- @__weel_handlerwrapper = HandlerWrapperBase
378
- @__weel_handlerwrapper_args = []
381
+ @__weel_connectionwrapper = ConnectionWrapperBase
382
+ @__weel_connectionwrapper_args = []
379
383
  @__weel_state = :ready
380
384
  @__weel_status = Status.new(0,"undefined")
381
385
  @__weel_replay = false
382
386
  @__weel_sim = -1
383
387
  end #}}}
384
- attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_handlerwrapper, :__weel_handlerwrapper_args, :__weel_replay
388
+ attr_accessor :__weel_search_positions, :__weel_positions, :__weel_main, :__weel_data, :__weel_endpoints, :__weel_connectionwrapper, :__weel_connectionwrapper_args, :__weel_replay
385
389
  attr_reader :__weel_state, :__weel_status
386
390
 
387
391
  # DSL-Constructs for atomic calls to external services (calls) and pure context manipulations (manipulate).
@@ -416,7 +420,9 @@ class WEEL
416
420
 
417
421
  __weel_protect_yield(&block)
418
422
 
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)
423
+ 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)
424
+ Thread.current[:branch_wait_count_cancel] = 0
425
+ Thread.current[:branch_wait_count_cancel_condition] = (type.is_a?(Hash) && type[:cancel] != nil && type[:cancel] == :first ) ? :first : :last
420
426
  1.upto Thread.current[:branches].size do
421
427
  Thread.current[:branch_event].wait
422
428
  end
@@ -459,11 +465,12 @@ class WEEL
459
465
  current_branch_sim_pos = branch_parent[:branch_sim_pos]
460
466
  end
461
467
 
462
- Thread.current[:branches] << Thread.new(*vars) do |*local|
468
+ branch_parent[:branches] << Thread.new(*vars) do |*local|
463
469
  Thread.current.abort_on_exception = true
464
470
  Thread.current[:branch_status] = false
465
471
  Thread.current[:branch_parent] = branch_parent
466
472
  Thread.current[:start_event] = Continue.new
473
+ Thread.current[:branch_wait_count_cancel_active] = false
467
474
 
468
475
  if __weel_sim
469
476
  Thread.current[:branch_sim_pos] = @__weel_sim += 1
@@ -479,15 +486,15 @@ class WEEL
479
486
  Thread.current[:start_event].wait unless self.__weel_state == :stopping || self.__weel_state == :stopped || self.__weel_state == :finishing
480
487
 
481
488
  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)
489
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
490
+ connectionwrapper.simulate(:parallel_branch,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos)
484
491
  end
485
492
 
486
493
  unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
487
494
  __weel_protect_yield(*local, &block)
488
495
  end
489
496
 
490
- __weel_sim_stop(:parallel_branch,handlerwrapper,current_branch_sim_pos) if __weel_sim
497
+ __weel_sim_stop(:parallel_branch,connectionwrapper,current_branch_sim_pos) if __weel_sim
491
498
 
492
499
  branch_parent[:mutex].synchronize do
493
500
  Thread.current[:branch_status] = true
@@ -502,7 +509,7 @@ class WEEL
502
509
  begin
503
510
  ipc = {}
504
511
  ipc[:unmark] = [Thread.current[:branch_position]]
505
- @__weel_handlerwrapper::inform_position_change(@__weel_handlerwrapper_args,ipc)
512
+ @__weel_connectionwrapper::inform_position_change(@__weel_connectionwrapper_args,ipc)
506
513
  end rescue nil
507
514
  Thread.current[:branch_position] = nil
508
515
  end
@@ -600,13 +607,13 @@ class WEEL
600
607
  while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
601
608
  loop_guard += 1
602
609
  __weel_protect_yield(&block)
603
- sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
610
+ sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
604
611
  end
605
612
  when :post_test
606
613
  begin
607
614
  loop_guard += 1
608
615
  __weel_protect_yield(&block)
609
- sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
616
+ sleep 1 if @__weel_connectionwrapper::loop_guard(@__weel_connectionwrapper_args,loop_id,loop_guard)
610
617
  end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
611
618
  end
612
619
  end
@@ -656,27 +663,27 @@ class WEEL
656
663
  yield(*local) if block_given?
657
664
  rescue NameError => err # don't look into it, or it will explode
658
665
  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)
666
+ @__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
667
  nil
661
668
  rescue => err
662
669
  self.__weel_state = :stopping
663
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new(err.message),nil)
670
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
664
671
  nil
665
672
  end
666
673
  end #}}}
667
674
 
668
675
  def __weel_eval_condition(condition) #{{{
669
676
  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)
677
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args unless condition.is_a?(Proc)
678
+ condition.is_a?(Proc) ? condition.call : connectionwrapper.test_condition(ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional),condition)
672
679
  rescue NameError => err # don't look into it, or it will explode
673
680
  # if you access $! here, BOOOM
674
681
  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)
682
+ @__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
683
  nil
677
684
  rescue => err
678
685
  self.__weel_state = :stopping
679
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new(err.message),nil)
686
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new(err.message),nil)
680
687
  nil
681
688
  end
682
689
  end #}}}
@@ -714,7 +721,7 @@ class WEEL
714
721
  @__weel_positions << wp
715
722
  Thread.current[:branch_position] = wp
716
723
 
717
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, ipc
724
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, ipc
718
725
  wp
719
726
  end #}}}
720
727
 
@@ -726,10 +733,10 @@ class WEEL
726
733
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
727
734
 
728
735
  Thread.current[:continue] = Continue.new
729
- handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args, position, Thread.current[:continue]
736
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args, position, Thread.current[:continue]
730
737
 
731
738
  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)
739
+ 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
740
  return
734
741
  end
735
742
 
@@ -740,34 +747,35 @@ class WEEL
740
747
 
741
748
  case type
742
749
  when :manipulate
743
- raise Signal::Stop unless handlerwrapper.vote_sync_before
750
+ raise Signal::Stop unless connectionwrapper.vote_sync_before
744
751
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
745
752
 
746
753
  if finalize.is_a?(Proc) || finalize.is_a?(String)
747
- handlerwrapper.activity_manipulate_handle(parameters)
748
- handlerwrapper.inform_activity_manipulate
754
+ connectionwrapper.activity_manipulate_handle(parameters)
755
+ connectionwrapper.inform_activity_manipulate
749
756
  if finalize.is_a?(Proc)
750
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
757
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
751
758
  mr.instance_eval(&finalize)
752
759
  elsif finalize.is_a?(String)
753
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
754
- handlerwrapper.manipulate(mr,finalize)
760
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
761
+ connectionwrapper.manipulate(mr,finalize)
755
762
  end
756
- handlerwrapper.inform_manipulate_change(
763
+ connectionwrapper.inform_manipulate_change(
757
764
  ((mr && mr.changed_status) ? @__weel_status : nil),
758
765
  ((mr && mr.changed_data.any?) ? mr.changed_data.uniq : nil),
759
766
  ((mr && mr.changed_endpoints.any?) ? mr.changed_endpoints.uniq : nil),
760
767
  @__weel_data,
761
768
  @__weel_endpoints
762
769
  )
763
- handlerwrapper.inform_activity_done
770
+ connectionwrapper.inform_activity_done
764
771
  wp.detail = :after
765
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :after => [wp]
772
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
766
773
  end
767
774
  when :call
768
775
  begin
769
776
  again = catch Signal::Again do
770
- rs = ReadStructure.new(@__weel_data,@__weel_endpoints,handlerwrapper.additional)
777
+ connectionwrapper.mem_guard
778
+ rs = ReadStructure.new(@__weel_data,@__weel_endpoints,connectionwrapper.additional)
771
779
  if prepare
772
780
  if prepare.is_a?(Proc)
773
781
  rs.instance_exec(&prepare)
@@ -775,14 +783,14 @@ class WEEL
775
783
  rs.instance_eval prepare
776
784
  end
777
785
  end
778
- params = handlerwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
779
- raise Signal::Stop unless handlerwrapper.vote_sync_before(params)
786
+ params = connectionwrapper.prepare(rs,endpoint,parameters,@__weel_replay)
787
+ raise Signal::Stop unless connectionwrapper.vote_sync_before(params)
780
788
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
781
789
 
782
- handlerwrapper.activity_handle wp.passthrough, params
783
- wp.passthrough = handlerwrapper.activity_passthrough_value
790
+ connectionwrapper.activity_handle wp.passthrough, params
791
+ wp.passthrough = connectionwrapper.activity_passthrough_value
784
792
  unless wp.passthrough.nil?
785
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :wait => [wp]
793
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :wait => [wp]
786
794
  end
787
795
  begin
788
796
  # with loop if catching Signal::Again
@@ -792,12 +800,12 @@ class WEEL
792
800
  raise waitingresult[1] if !waitingresult.nil? && waitingresult.is_a?(Array) && waitingresult.length == 2 && waitingresult[0] == WEEL::Signal::Error
793
801
 
794
802
  if Thread.current[:nolongernecessary]
795
- handlerwrapper.activity_no_longer_necessary
803
+ connectionwrapper.activity_no_longer_necessary
796
804
  raise Signal::NoLongerNecessary
797
805
  end
798
806
  if self.__weel_state == :stopping || self.__weel_state == :finishing
799
- handlerwrapper.activity_stop
800
- wp.passthrough = handlerwrapper.activity_passthrough_value
807
+ connectionwrapper.activity_stop
808
+ wp.passthrough = connectionwrapper.activity_passthrough_value
801
809
  raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
802
810
  end
803
811
 
@@ -809,26 +817,26 @@ class WEEL
809
817
  finalize
810
818
  end
811
819
  if code.is_a?(Proc) || code.is_a?(String)
812
- handlerwrapper.inform_activity_manipulate
820
+ connectionwrapper.inform_activity_manipulate
813
821
  if code.is_a?(Proc)
814
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
822
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
815
823
  ma = catch Signal::Again do
816
824
  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)
825
+ when 1; mr.instance_exec(connectionwrapper.activity_result_value,&code)
826
+ when 2; mr.instance_exec(connectionwrapper.activity_result_value,&code)
819
827
  else
820
828
  mr.instance_exec(&code)
821
829
  end
822
830
  'yes' # ma sadly will have nil when i just throw
823
831
  end
824
832
  elsif code.is_a?(String)
825
- mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,handlerwrapper.additional)
833
+ mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status,connectionwrapper.additional)
826
834
  ma = catch Signal::Again do
827
- handlerwrapper.manipulate(mr,code,handlerwrapper.activity_result_value,handlerwrapper.activity_result_options)
835
+ connectionwrapper.manipulate(mr,code,connectionwrapper.activity_result_value,connectionwrapper.activity_result_options)
828
836
  'yes' # ma sadly will have nil when i just throw
829
837
  end
830
838
  end
831
- handlerwrapper.inform_manipulate_change(
839
+ connectionwrapper.inform_manipulate_change(
832
840
  (mr.changed_status ? @__weel_status : nil),
833
841
  (mr.changed_data.any? ? mr.changed_data.uniq : nil),
834
842
  (mr.changed_endpoints.any? ? mr.changed_endpoints.uniq : nil),
@@ -838,18 +846,18 @@ class WEEL
838
846
  throw(Signal::Again, Signal::Again) if ma.nil?
839
847
  end
840
848
  end while waitingresult == Signal::Again
841
- if handlerwrapper.activity_passthrough_value.nil?
842
- handlerwrapper.inform_activity_done
849
+ if connectionwrapper.activity_passthrough_value.nil?
850
+ connectionwrapper.inform_activity_done
843
851
  wp.passthrough = nil
844
852
  wp.detail = :after
845
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :after => [wp]
853
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :after => [wp]
846
854
  end
847
855
  end
848
856
  end while again == Signal::Again
849
857
  end
850
858
  raise Signal::Proceed
851
859
  rescue Signal::SkipManipulate, Signal::Proceed
852
- if self.__weel_state != :stopping && self.__weel_state != :finishing && !handlerwrapper.vote_sync_after
860
+ if self.__weel_state != :stopping && self.__weel_state != :finishing && !connectionwrapper.vote_sync_after
853
861
  self.__weel_state = :stopping
854
862
  wp.detail = :unmark
855
863
  end
@@ -857,18 +865,37 @@ class WEEL
857
865
  @__weel_positions.delete wp
858
866
  Thread.current[:branch_position] = nil
859
867
  wp.detail = :unmark
860
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :unmark => [wp]
868
+ @__weel_connectionwrapper::inform_position_change @__weel_connectionwrapper_args, :unmark => [wp]
861
869
  rescue Signal::StopSkipManipulate, Signal::Stop
862
870
  self.__weel_state = :stopping
863
871
  rescue Signal::Skip
864
872
  nil
865
873
  rescue SyntaxError => se
866
- handlerwrapper.inform_activity_failed se
874
+ connectionwrapper.inform_activity_failed se
867
875
  self.__weel_state = :stopping
868
876
  rescue => err
869
- @__weel_handlerwrapper::inform_handlerwrapper_error @__weel_handlerwrapper_args, err
877
+ @__weel_connectionwrapper::inform_connectionwrapper_error @__weel_connectionwrapper_args, err
870
878
  self.__weel_state = :stopping
871
879
  ensure
880
+ connectionwrapper.mem_guard unless connectionwrapper.nil?
881
+ if Thread.current[:branch_parent]
882
+ Thread.current[:branch_parent][:mutex].synchronize do
883
+ if Thread.current[:branch_parent][:branch_wait_count_cancel_condition] == :first
884
+ if !Thread.current[:branch_wait_count_cancel_active]
885
+ Thread.current[:branch_wait_count_cancel_active] = true
886
+ Thread.current[:branch_parent][:branch_wait_count_cancel] += 1
887
+ end
888
+ if Thread.current[:branch_parent][:branch_wait_count_cancel] == Thread.current[:branch_parent][:branch_wait_count] && self.__weel_state != :stopping && self.__weel_state != :finishing
889
+ Thread.current[:branch_parent][:branches].each do |thread|
890
+ if thread.alive? && thread != Thread.current
891
+ thread[:nolongernecessary] = true
892
+ __weel_recursive_continue(thread)
893
+ end
894
+ end
895
+ end
896
+ end
897
+ end
898
+ end
872
899
  Thread.current[:continue].clear if Thread.current[:continue] && Thread.current[:continue].is_a?(Continue)
873
900
  end
874
901
  end # }}}
@@ -914,7 +941,7 @@ class WEEL
914
941
  position
915
942
  else
916
943
  self.__weel_state = :stopping
917
- @__weel_handlerwrapper::inform_syntax_error(@__weel_handlerwrapper_args,Exception.new("position (#{position}) not valid"),nil)
944
+ @__weel_connectionwrapper::inform_syntax_error(@__weel_connectionwrapper_args,Exception.new("position (#{position}) not valid"),nil)
918
945
  end
919
946
  end # }}}
920
947
 
@@ -943,13 +970,13 @@ class WEEL
943
970
  def __weel_sim_start(what,options={}) #{{{
944
971
  current_branch_sim_pos = Thread.current[:branch_sim_pos]
945
972
  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]
973
+ connectionwrapper = @__weel_connectionwrapper.new @__weel_connectionwrapper_args
974
+ connectionwrapper.simulate(what,:start,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
975
+ [connectionwrapper, current_branch_sim_pos]
949
976
  end #}}}
950
977
 
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)
978
+ def __weel_sim_stop(what,connectionwrapper,current_branch_sim_pos,options={}) #{{{
979
+ connectionwrapper.simulate(what,:end,Thread.current[:branch_sim_pos],current_branch_sim_pos,options)
953
980
  Thread.current[:branch_sim_pos] = current_branch_sim_pos
954
981
  end #}}}
955
982
 
@@ -957,7 +984,7 @@ class WEEL
957
984
  def __weel_finalize #{{{
958
985
  __weel_recursive_join(@__weel_main)
959
986
  @__weel_state = :stopped
960
- @__weel_handlerwrapper::inform_state_change @__weel_handlerwrapper_args, @__weel_state
987
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
961
988
  end #}}}
962
989
 
963
990
  def __weel_state=(newState)# {{{
@@ -972,7 +999,7 @@ class WEEL
972
999
  __weel_replay = false
973
1000
  end
974
1001
 
975
- @__weel_handlerwrapper::inform_state_change @__weel_handlerwrapper_args, @__weel_state
1002
+ @__weel_connectionwrapper::inform_state_change @__weel_connectionwrapper_args, @__weel_state
976
1003
  end # }}}
977
1004
 
978
1005
  end # }}}
@@ -982,27 +1009,27 @@ public
982
1009
  @dslr.__weel_positions
983
1010
  end # }}}
984
1011
 
985
- # set the handlerwrapper
986
- def handlerwrapper # {{{
987
- @dslr.__weel_handlerwrapper
1012
+ # set the connectionwrapper
1013
+ def connectionwrapper # {{{
1014
+ @dslr.__weel_connectionwrapper
988
1015
  end # }}}
989
- def handlerwrapper=(new_weel_handlerwrapper) # {{{
990
- superclass = new_weel_handlerwrapper
1016
+ def connectionwrapper=(new_weel_connectionwrapper) # {{{
1017
+ superclass = new_weel_connectionwrapper
991
1018
  while superclass
992
- check_ok = true if superclass == WEEL::HandlerWrapperBase
1019
+ check_ok = true if superclass == WEEL::ConnectionWrapperBase
993
1020
  superclass = superclass.superclass
994
1021
  end
995
- raise "Handlerwrapper is not inherited from HandlerWrapperBase" unless check_ok
996
- @dslr.__weel_handlerwrapper = new_weel_handlerwrapper
1022
+ raise "ConnectionWrapper is not inherited from ConnectionWrapperBase" unless check_ok
1023
+ @dslr.__weel_connectionwrapper = new_weel_connectionwrapper
997
1024
  end # }}}
998
1025
 
999
- # Get/Set the handlerwrapper arguments
1000
- def handlerwrapper_args # {{{
1001
- @dslr.__weel_handlerwrapper_args
1026
+ # Get/Set the connectionwrapper arguments
1027
+ def connectionwrapper_args # {{{
1028
+ @dslr.__weel_connectionwrapper_args
1002
1029
  end # }}}
1003
- def handlerwrapper_args=(args) # {{{
1030
+ def connectionwrapper_args=(args) # {{{
1004
1031
  if args.class == Array
1005
- @dslr.__weel_handlerwrapper_args = args
1032
+ @dslr.__weel_connectionwrapper_args = args
1006
1033
  end
1007
1034
  nil
1008
1035
  end # }}}
@@ -1012,7 +1039,7 @@ public
1012
1039
  @dslr.__weel_state
1013
1040
  end # }}}
1014
1041
  def state_signal # {{{
1015
- handlerwrapper::inform_state_change handlerwrapper_args, state
1042
+ connectionwrapper::inform_state_change connectionwrapper_args, state
1016
1043
  state
1017
1044
  end # }}}
1018
1045
  def abandon # {{{
@@ -1076,19 +1103,19 @@ public
1076
1103
  end
1077
1104
  rescue SyntaxError => se
1078
1105
  @dslr.__weel_state = :stopping
1079
- @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new(se.message),code)
1106
+ @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(se.message),code)
1080
1107
  rescue NameError => err # don't look into it, or it will explode
1081
1108
  @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)
1109
+ @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
1110
  rescue => err
1084
1111
  @dslr.__weel_state = :stopping
1085
- @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new(err.message),code)
1112
+ @dslr.__weel_connectionwrapper::inform_syntax_error(@dslr.__weel_connectionwrapper_args,Exception.new(err.message),code)
1086
1113
  end
1087
1114
  if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
1088
1115
  ipc = { :unmark => [] }
1089
1116
  @dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp }
1090
1117
  @dslr.__weel_positions.clear
1091
- @dslr.__weel_handlerwrapper::inform_position_change(@dslr.__weel_handlerwrapper_args,ipc)
1118
+ @dslr.__weel_connectionwrapper::inform_position_change(@dslr.__weel_connectionwrapper_args,ipc)
1092
1119
  @dslr.__weel_state = :finished
1093
1120
  end
1094
1121
  if @dslr.__weel_state == :simulating
@@ -1104,8 +1131,12 @@ public
1104
1131
  # Stop the workflow execution
1105
1132
  def stop # {{{
1106
1133
  Thread.new do
1107
- @dslr.__weel_state = :stopping
1108
- @dslr.__weel_main.join if @dslr.__weel_main
1134
+ if @dslr.__weel_state == :running
1135
+ @dslr.__weel_state = :stopping
1136
+ @dslr.__weel_main.join if @dslr.__weel_main
1137
+ elsif @dslr.__weel_state == :ready || @dslr.__weel_state == :stopped
1138
+ @dslr.__weel_state = :stopped
1139
+ end
1109
1140
  end
1110
1141
  end # }}}
1111
1142
  # Start the workflow execution
@@ -1117,7 +1148,7 @@ public
1117
1148
  rescue => e
1118
1149
  puts e.message
1119
1150
  puts e.backtrace
1120
- handlerwrapper::inform_handlerwrapper_error handlerwrapper_args, e
1151
+ connectionwrapper::inform_connectionwrapper_error connectionwrapper_args, e
1121
1152
  end
1122
1153
  end
1123
1154
  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.94"
3
+ s.version = "1.99.99"
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.94
4
+ version: 1.99.99
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-09-29 00:00:00.000000000 Z
12
+ date: 2021-05-19 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,17 +101,17 @@ 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.1.4
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
109
  - test/test
111
110
  - test/ContinueTest.rb
112
111
  - test/TestWorkflow.rb
113
112
  - test/TestMixin.rb
114
- - test/SimHandlerWrapper.rb
113
+ - test/TestConnectionWrapper.rb
114
+ - test/SimConnectionWrapper.rb
115
115
  - test/README
116
116
  - test/wfp_iteration/tc_structuredloop.rb
117
117
  - test/wfp_adv_branching/tc_structured_partial_join.rb