weel 1.99.85 → 1.99.92

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 +49 -29
  3. data/weel.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa7f206a93ca278638856f8ab6b78fda00f60d3f4ef7edd4de39f3cbd815033f
4
- data.tar.gz: 3d4aca5885e568a369da106911af21203f452168d94df137f5c7c28756314cae
3
+ metadata.gz: 382652394caca0a926ca5dd00d5c9582042d8ca33bddbcc339e0db3132e6814b
4
+ data.tar.gz: 1f3b40aef98c19c0da0bc65fbd8019e730f25ad9628c9d0b75fdcb84a3f92660
5
5
  SHA512:
6
- metadata.gz: fdef4e6efd51ca5e02802ccf7ec18a2d6e0c1170235c2ed4daf2ef42d04b4890f17cc222b0721abf210a169a7bfb2458ee95ab5f4776c33c896957c93de2c725
7
- data.tar.gz: 94d63a774749ff47717a4d6d18c8f0b79a026f702a3d0640193a3d80d47a08c558603b2e4359ebd200fa084708e1a84da16d594c817b054dd346243d09195807
6
+ metadata.gz: fd87fada9619e4c8816851df18d61c560e10f608944c8fdaf4cc69d4afa4fb549a647143865052dac70f7bd1ff3b8744d1168c57cec1b14995826442de177f11
7
+ data.tar.gz: a992e55a9561d6003a60812e022cedfed1b9ebb21c549a19758d45c99ce95931b515914f401d4f9c104d9aff158e4e49c856b4f522b676e0b626aba9d15d577f
@@ -15,6 +15,7 @@
15
15
  # <http://www.gnu.org/licenses/>.
16
16
 
17
17
  require 'thread'
18
+ require 'securerandom'
18
19
 
19
20
  class WEEL
20
21
  def initialize(*args)# {{{
@@ -237,6 +238,7 @@ class WEEL
237
238
  end # }}}
238
239
 
239
240
  class HandlerWrapperBase # {{{
241
+ def self::loop_guard(lid,count); false; end
240
242
  def self::inform_state_change(arguments,newstate); end
241
243
  def self::inform_syntax_error(arguments,err,code); end
242
244
  def self::inform_handlerwrapper_error(arguments,err); end
@@ -288,7 +290,7 @@ class WEEL
288
290
  end
289
291
  def as_json(*)
290
292
  jsn = { 'position' => @position }
291
- jsn['passtrough'] = @passthrough if @passthrough
293
+ jsn['passthrough'] = @passthrough if @passthrough
292
294
  jsn
293
295
  end
294
296
  def to_s
@@ -297,6 +299,12 @@ class WEEL
297
299
  def to_json(*args)
298
300
  as_json.to_json(*args)
299
301
  end
302
+ def eql?(other)
303
+ to_s == other.to_s
304
+ end
305
+ def hash
306
+ to_s.hash
307
+ end
300
308
  end # }}}
301
309
 
302
310
  class Continue # {{{
@@ -584,15 +592,21 @@ class WEEL
584
592
  __weel_sim_stop(:loop,hw,pos,args.merge(:testing=>condition[1],:condition=>cond))
585
593
  return
586
594
  end
595
+ loop_guard = 0
596
+ loop_id = SecureRandom.uuid
587
597
  catch :escape do
588
598
  case condition[1]
589
599
  when :pre_test
590
600
  while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
601
+ loop_guard += 1
591
602
  __weel_protect_yield(&block)
603
+ sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
592
604
  end
593
605
  when :post_test
594
606
  begin
607
+ loop_guard += 1
595
608
  __weel_protect_yield(&block)
609
+ sleep 1 if @__weel_handlerwrapper::loop_guard(@__weel_handlerwrapper_args,loop_id,loop_guard)
596
610
  end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
597
611
  end
598
612
  end
@@ -622,7 +636,7 @@ class WEEL
622
636
  searchmode = __weel_is_in_search_mode(position)
623
637
  return if searchmode
624
638
  return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
625
- __weel_progress searchmode, position, true
639
+ __weel_progress position, true
626
640
  self.__weel_state = :stopping
627
641
  end #}}}
628
642
 
@@ -667,26 +681,36 @@ class WEEL
667
681
  end
668
682
  end #}}}
669
683
 
670
- def __weel_progress(searchmode, position, skip=false) #{{{
684
+ def __weel_progress(position, skip=false) #{{{
671
685
  ipc = {}
672
- if searchmode == :after
673
- wp = WEEL::Position.new(position, :after, nil)
674
- ipc[:after] = [wp]
686
+ branch = Thread.current
687
+ if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
688
+ @__weel_positions.delete Thread.current[:branch_parent][:branch_position]
689
+ ipc[:unmark] ||= []
690
+ ipc[:unmark] << Thread.current[:branch_parent][:branch_position] rescue nil
691
+ Thread.current[:branch_parent][:branch_position] = nil
692
+ end
693
+ if Thread.current[:branch_position]
694
+ @__weel_positions.delete Thread.current[:branch_position]
695
+ ipc[:unmark] ||= []
696
+ ipc[:unmark] << Thread.current[:branch_position] rescue nil
697
+ end
698
+ wp = if branch[:branch_search_now] == true
699
+ branch[:branch_search_now] = false
700
+ WEEL::Position.new(position, skip ? :after : :at, @__weel_search_positions[position].passthrough)
675
701
  else
676
- if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
677
- @__weel_positions.delete Thread.current[:branch_parent][:branch_position]
678
- ipc[:unmark] ||= []
679
- ipc[:unmark] << Thread.current[:branch_parent][:branch_position] rescue nil
680
- Thread.current[:branch_parent][:branch_position] = nil
681
- end
682
- if Thread.current[:branch_position]
683
- @__weel_positions.delete Thread.current[:branch_position]
684
- ipc[:unmark] ||= []
685
- ipc[:unmark] << Thread.current[:branch_position] rescue nil
686
- end
687
- wp = WEEL::Position.new(position, skip ? :after : :at, nil)
688
- ipc[skip ? :after : :at] = [wp]
702
+ WEEL::Position.new(position, skip ? :after : :at)
703
+ end
704
+ ipc[skip ? :after : :at] = [wp]
705
+
706
+ @__weel_search_positions.delete(position)
707
+ @__weel_search_positions.each do |k,ele| # some may still be in active search but lets unmark them for good measure
708
+ ipc[:unmark] ||= []
709
+ ipc[:unmark] << ele
710
+ true
689
711
  end
712
+ ipc[:unmark].uniq! if ipc[:unmark]
713
+
690
714
  @__weel_positions << wp
691
715
  Thread.current[:branch_position] = wp
692
716
 
@@ -709,7 +733,7 @@ class WEEL
709
733
  return
710
734
  end
711
735
 
712
- wp = __weel_progress searchmode, position
736
+ wp = __weel_progress position
713
737
 
714
738
  # searchmode position is after, jump directly to vote_sync_after
715
739
  raise Signal::Proceed if searchmode == :after
@@ -755,13 +779,7 @@ class WEEL
755
779
  raise Signal::Stop unless handlerwrapper.vote_sync_before(params)
756
780
  raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
757
781
 
758
- if @__weel_search_positions[position]
759
- passthrough = @__weel_search_positions[position].passthrough
760
- @__weel_search_positions[position].passthrough = nil
761
- else
762
- passthrough = nil
763
- end
764
- handlerwrapper.activity_handle passthrough, params
782
+ handlerwrapper.activity_handle wp.passthrough, params
765
783
  wp.passthrough = handlerwrapper.activity_passthrough_value
766
784
  unless wp.passthrough.nil?
767
785
  @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :wait => [wp]
@@ -780,7 +798,7 @@ class WEEL
780
798
  if self.__weel_state == :stopping || self.__weel_state == :finishing
781
799
  handlerwrapper.activity_stop
782
800
  wp.passthrough = handlerwrapper.activity_passthrough_value
783
- raise Signal::Proceed
801
+ raise Signal::Proceed if wp.passthrough # if stop, but no passthrough, let manipulate happen and then stop
784
802
  end
785
803
 
786
804
  code = if waitingresult == WEEL::Signal::Again
@@ -906,11 +924,13 @@ class WEEL
906
924
 
907
925
  if position && @__weel_search_positions.include?(position) # matching searchpos => start execution from here
908
926
  branch[:branch_search] = false # execute all activities in THIS branch (thread) after this point
927
+ branch[:branch_search_now] = true # just now did we switch the search mode
909
928
  while branch.key?(:branch_parent) # also all parent branches should execute activities after this point, additional branches spawned by parent branches should still be in search mode
910
929
  branch = branch[:branch_parent]
911
930
  branch[:branch_search] = false
931
+ branch[:branch_search_now] = true # just now did we switch the search mode
912
932
  end
913
- @__weel_search_positions[position].detail == :after ? :after : false
933
+ @__weel_search_positions[position].detail == :after
914
934
  else
915
935
  branch[:branch_search] = true
916
936
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.85"
3
+ s.version = "1.99.92"
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.85
4
+ version: 1.99.92
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: 2020-06-19 00:00:00.000000000 Z
12
+ date: 2020-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit