weel 1.99.56 → 1.99.61

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 +70 -51
  3. data/weel.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4cdf62385cfec6d6ef0af98c8a76d8d52259796
4
- data.tar.gz: 26fc6450ac38515a53833be35da736019fab71f2
3
+ metadata.gz: c55c3d411a1eab0c4cd80b803dbbcf358fbafb63
4
+ data.tar.gz: 313ba40f324c648a521f8909afac4ad63406e294
5
5
  SHA512:
6
- metadata.gz: 30efad55aea47e8d445c9bd079e539f2f8474d76647dff7f952f874296c03298f62b9cacf4ff619fb6766a6622d959ea6e80c69481835de2565523bf18be1973
7
- data.tar.gz: 6d5d7c4d9475c6c8e4b3e9e8ca6b55db3d4149a0de3fd45e15dd843d6c6186ba83ff421be2ac7b433c6090df31e3bb6a2b4b527c08e07377f7896cea84b8dab8
6
+ metadata.gz: cdc858221117b9535568b76d19e9c710007cfa687b6b9c0f12b12169b0e8e4861281dc6bfa4afe64e0a1574d7c7c4b0f6f7997384b33411eb3ccf977921e4fe2
7
+ data.tar.gz: 80c42fca246256ebc96c9a2533087ae1e72cdcefdb96ff06b872a78c71fabb9035ac2399c1b514146e69863b76110ac4863edb8d5a1284610333df517e60657c
@@ -56,7 +56,6 @@ class WEEL
56
56
  class SkipManipulate < Exception; end
57
57
  class StopSkipManipulate < Exception; end
58
58
  class Stop < Exception; end
59
- class StopAfter < Exception; end
60
59
  class Proceed < Exception; end
61
60
  class NoLongerNecessary < Exception; end
62
61
  class Again < Exception; end
@@ -212,6 +211,7 @@ class WEEL
212
211
  def initialize(arguments,endpoint=nil,position=nil,continue=nil); end
213
212
 
214
213
  def activity_handle(passthrough, parameters); end
214
+ def activity_manipulate_handle(parameters); end
215
215
 
216
216
  def activity_result_value; end
217
217
  def activity_result_status; end
@@ -335,15 +335,20 @@ class WEEL
335
335
  def call(position, endpoint, parameters: {}, finalize: nil, update: nil, &finalizeblk)
336
336
  __weel_activity(position,:call,endpoint,parameters,finalize||finalizeblk,update)
337
337
  end
338
- def manipulate(position, script=nil, &scriptblk)
339
- __weel_activity(position,:manipulate,nil,{},script||scriptblk)
338
+ # when two params, second param always script
339
+ # when block and two params, parameters stays
340
+ def manipulate(position, parameters=nil, script=nil, &scriptblk)
341
+ if scriptblk.nil? && script.nil? && !parameters.nil?
342
+ script, parameters = parameters, nil
343
+ end
344
+ __weel_activity(position,:manipulate,nil,parameters||{},script||scriptblk)
340
345
  end
341
346
 
342
347
  # Parallel DSL-Construct
343
348
  # Defines Workflow paths that can be executed parallel.
344
349
  # May contain multiple branches (parallel_branch)
345
350
  def parallel(type=nil)# {{{
346
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
351
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
347
352
 
348
353
  Thread.current[:branches] = []
349
354
  Thread.current[:branch_finished_count] = 0
@@ -372,7 +377,7 @@ class WEEL
372
377
 
373
378
  __weel_sim_stop(:parallel,hw,pos) if __weel_sim
374
379
 
375
- unless self.__weel_state == :stopping || self.__weel_state == :stopped
380
+ unless self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
376
381
  # first set all to no_longer_neccessary
377
382
  Thread.current[:branches].each do |thread|
378
383
  if thread.alive?
@@ -389,7 +394,7 @@ class WEEL
389
394
 
390
395
  # Defines a branch of a parallel-Construct
391
396
  def parallel_branch(*vars)# {{{
392
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
397
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
393
398
  branch_parent = Thread.current
394
399
 
395
400
  if __weel_sim
@@ -428,11 +433,11 @@ class WEEL
428
433
  branch_parent[:mutex].synchronize do
429
434
  Thread.current[:branch_status] = true
430
435
  branch_parent[:branch_finished_count] += 1
431
- if branch_parent[:branch_finished_count] == branch_parent[:branch_wait_count] && self.__weel_state != :stopping
436
+ if branch_parent[:branch_finished_count] == branch_parent[:branch_wait_count] && self.__weel_state != :stopping && self.__weel_state != :finishing
432
437
  branch_parent[:branch_event].continue
433
438
  end
434
439
  end
435
- if self.__weel_state != :stopping && self.__weel_state != :stopped
440
+ if self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
436
441
  if Thread.current[:branch_position]
437
442
  @__weel_positions.delete Thread.current[:branch_position]
438
443
  begin
@@ -450,7 +455,7 @@ class WEEL
450
455
  # Defines a choice in the Workflow path.
451
456
  # May contain multiple execution alternatives
452
457
  def choose(mode=:inclusive) # {{{
453
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
458
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
454
459
  Thread.current[:alternative_executed] ||= []
455
460
  Thread.current[:alternative_mode] ||= []
456
461
  Thread.current[:alternative_executed] << false
@@ -467,7 +472,7 @@ class WEEL
467
472
  # Block is executed if condition == true or
468
473
  # searchmode is active (to find the starting position)
469
474
  def alternative(condition,args={})# {{{
470
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
475
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
471
476
  hw, pos = __weel_sim_start(:alternative,args.merge(:mode => Thread.current[:alternative_mode].last, :condition => ((condition.is_a?(String) || condition.is_a?(Proc)) ? condition : nil))) if __weel_sim
472
477
  Thread.current[:mutex] ||= Mutex.new
473
478
  Thread.current[:mutex].synchronize do
@@ -481,7 +486,7 @@ class WEEL
481
486
  __weel_sim_stop(:alternative,hw,pos,args.merge(:mode => Thread.current[:alternative_mode].last, :condition => ((condition.is_a?(String) || condition.is_a?(Proc)) ? condition : nil))) if __weel_sim
482
487
  end # }}}
483
488
  def otherwise(args={}) # {{{
484
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
489
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
485
490
  hw, pos = __weel_sim_start(:otherwise,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
486
491
  __weel_protect_yield(&Proc.new) if __weel_is_in_search_mode || __weel_sim || !Thread.current[:alternative_executed].last
487
492
  __weel_sim_stop(:otherwise,hw,pos,args.merge(:mode => Thread.current[:alternative_mode].last)) if __weel_sim
@@ -506,7 +511,7 @@ class WEEL
506
511
  unless condition.is_a?(Array) && (condition[0].is_a?(Proc) || condition[0].is_a?(String)) && [:pre_test,:post_test].include?(condition[1]) && args.is_a?(Hash)
507
512
  raise "condition must be called pre_test{} or post_test{}"
508
513
  end
509
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
514
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
510
515
  if __weel_is_in_search_mode
511
516
  catch :escape do
512
517
  __weel_protect_yield(&Proc.new)
@@ -525,13 +530,13 @@ class WEEL
525
530
  catch :escape do
526
531
  case condition[1]
527
532
  when :pre_test
528
- while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped
533
+ while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
529
534
  __weel_protect_yield(&Proc.new)
530
535
  end
531
536
  when :post_test
532
537
  begin
533
538
  __weel_protect_yield(&Proc.new)
534
- end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped
539
+ end while __weel_eval_condition(condition[0]) && self.__weel_state != :stopping && self.__weel_state != :stopped && self.__weel_state != :finishing
535
540
  end
536
541
  end
537
542
  end # }}}
@@ -546,7 +551,20 @@ class WEEL
546
551
  [code || blk, :post_test]
547
552
  end # }}}
548
553
 
549
- def escape; throw :escape; end
554
+ def escape
555
+ return if __weel_is_in_search_mode
556
+ throw :escape
557
+ end
558
+ def terminate
559
+ return if __weel_is_in_search_mode
560
+ self.__weel_state = :finishing
561
+ end
562
+ def stop(position)
563
+ searchmode = __weel_is_in_search_mode(position)
564
+ return if searchmode
565
+ __weel_progress searchmode, position, true
566
+ self.__weel_state = :stopping
567
+ end
550
568
 
551
569
  def status # {{{
552
570
  @__weel_status
@@ -589,12 +607,39 @@ class WEEL
589
607
  end
590
608
  end
591
609
 
610
+ def __weel_progress(searchmode, position, skip=false)
611
+ ipc = {}
612
+ if searchmode == :after
613
+ wp = WEEL::Position.new(position, :after, nil)
614
+ ipc[:after] = [wp.position]
615
+ else
616
+ if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
617
+ @__weel_positions.delete Thread.current[:branch_parent][:branch_position]
618
+ ipc[:unmark] ||= []
619
+ ipc[:unmark] << Thread.current[:branch_parent][:branch_position].position rescue nil
620
+ Thread.current[:branch_parent][:branch_position] = nil
621
+ end
622
+ if Thread.current[:branch_position]
623
+ @__weel_positions.delete Thread.current[:branch_position]
624
+ ipc[:unmark] ||= []
625
+ ipc[:unmark] << Thread.current[:branch_position].position rescue nil
626
+ end
627
+ wp = WEEL::Position.new(position, skip ? :after : :at, nil)
628
+ ipc[skip ? :after : :at] = [wp.position]
629
+ end
630
+ @__weel_positions << wp
631
+ Thread.current[:branch_position] = wp
632
+
633
+ @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, ipc
634
+ wp
635
+ end
636
+
592
637
  def __weel_activity(position, type, endpoints, parameters, finalize, update=nil)# {{{
593
638
  position = __weel_position_test position
594
639
  begin
595
640
  searchmode = __weel_is_in_search_mode(position)
596
641
  return if searchmode == true
597
- return if self.__weel_state == :stopping || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
642
+ return if self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped || Thread.current[:nolongernecessary]
598
643
 
599
644
  Thread.current[:continue] = Continue.new
600
645
  handlerwrapper = @__weel_handlerwrapper.new @__weel_handlerwrapper_args, endpoints.is_a?(Array) ? endpoints.map{ |ep| @__weel_endpoints[ep] }.compact : @__weel_endpoints[endpoints], position, Thread.current[:continue]
@@ -604,29 +649,7 @@ class WEEL
604
649
  return
605
650
  end
606
651
 
607
- ipc = {}
608
- if searchmode == :after
609
- wp = WEEL::Position.new(position, :after, nil)
610
- ipc[:after] = [wp.position]
611
- else
612
- if Thread.current[:branch_parent] && Thread.current[:branch_parent][:branch_position]
613
- @__weel_positions.delete Thread.current[:branch_parent][:branch_position]
614
- ipc[:unmark] ||= []
615
- ipc[:unmark] << Thread.current[:branch_parent][:branch_position].position rescue nil
616
- Thread.current[:branch_parent][:branch_position] = nil
617
- end
618
- if Thread.current[:branch_position]
619
- @__weel_positions.delete Thread.current[:branch_position]
620
- ipc[:unmark] ||= []
621
- ipc[:unmark] << Thread.current[:branch_position].position rescue nil
622
- end
623
- wp = WEEL::Position.new(position, :at, nil)
624
- ipc[:at] = [wp.position]
625
- end
626
- @__weel_positions << wp
627
- Thread.current[:branch_position] = wp
628
-
629
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, ipc
652
+ wp = __weel_progress searchmode, position
630
653
 
631
654
  # searchmode position is after, jump directly to vote_sync_after
632
655
  raise Signal::Proceed if searchmode == :after
@@ -634,9 +657,10 @@ class WEEL
634
657
  case type
635
658
  when :manipulate
636
659
  raise Signal::Stop unless handlerwrapper.vote_sync_before
637
- raise Signal::Skip if self.__weel_state == :stopping
660
+ raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
638
661
 
639
662
  if finalize.is_a?(Proc) || finalize.is_a?(String)
663
+ handlerwrapper.activity_manipulate_handle(parameters)
640
664
  handlerwrapper.inform_activity_manipulate
641
665
  if finalize.is_a?(Proc)
642
666
  mr = ManipulateStructure.new(@__weel_data,@__weel_endpoints,@__weel_status)
@@ -679,7 +703,7 @@ class WEEL
679
703
  raise("invalid parameters")
680
704
  end
681
705
  raise Signal::Stop unless handlerwrapper.vote_sync_before(params)
682
- raise Signal::Skip if self.__weel_state == :stopping
706
+ raise Signal::Skip if self.__weel_state == :stopping || self.__weel_state == :finishing
683
707
 
684
708
  passthrough = @__weel_search_positions[position] ? @__weel_search_positions[position].passthrough : nil
685
709
  handlerwrapper.activity_handle passthrough, params
@@ -687,14 +711,14 @@ class WEEL
687
711
  # with loop if catching Signal::Again
688
712
  # handshake call and wait until it finished
689
713
  waitingresult = nil
690
- waitingresult = Thread.current[:continue].wait unless Thread.current[:nolongernecessary] || self.__weel_state == :stopping || self.__weel_state == :stopped
714
+ waitingresult = Thread.current[:continue].wait unless Thread.current[:nolongernecessary] || self.__weel_state == :stopping || self.__weel_state == :finishing || self.__weel_state == :stopped
691
715
  raise waitingresult[1] if !waitingresult.nil? && waitingresult.is_a?(Array) && waitingresult.length == 2 && waitingresult[0] == WEEL::Signal::Error
692
716
 
693
717
  if Thread.current[:nolongernecessary]
694
718
  handlerwrapper.activity_no_longer_necessary
695
719
  raise Signal::NoLongerNecessary
696
720
  end
697
- if self.__weel_state == :stopping
721
+ if self.__weel_state == :stopping || self.__weel_state == :finishing
698
722
  handlerwrapper.activity_stop
699
723
  wp.passthrough = handlerwrapper.activity_passthrough_value
700
724
  raise Signal::Proceed
@@ -732,13 +756,8 @@ class WEEL
732
756
  end
733
757
  end
734
758
  raise Signal::Proceed
735
- rescue Signal::StopAfter
736
- handlerwrapper.inform_activity_done
737
- wp.detail = :after
738
- @__weel_handlerwrapper::inform_position_change @__weel_handlerwrapper_args, :after => [wp.position]
739
- self.__weel_state = :stopping
740
759
  rescue Signal::SkipManipulate, Signal::Proceed
741
- if self.__weel_state != :stopping && !handlerwrapper.vote_sync_after
760
+ if self.__weel_state != :stopping && self.__weel_state != :finishing && !handlerwrapper.vote_sync_after
742
761
  self.__weel_state = :stopping
743
762
  wp.detail = :unmark
744
763
  end
@@ -853,7 +872,7 @@ class WEEL
853
872
  @__weel_positions = Array.new if newState == :running
854
873
  @__weel_state = newState
855
874
 
856
- if newState == :stopping
875
+ if newState == :stopping || newState == :finishing
857
876
  __weel_recursive_continue(@__weel_main)
858
877
  end
859
878
 
@@ -966,7 +985,7 @@ public
966
985
  @dslr.__weel_state = :stopping
967
986
  @dslr.__weel_handlerwrapper::inform_syntax_error(@dslr.__weel_handlerwrapper_args,Exception.new(err.message),code)
968
987
  end
969
- if @dslr.__weel_state == :running
988
+ if @dslr.__weel_state == :running || @dslr.__weel_state == :finishing
970
989
  @dslr.__weel_state = :finished
971
990
  ipc = { :unmark => [] }
972
991
  @dslr.__weel_positions.each{ |wp| ipc[:unmark] << wp.position }
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "weel"
3
- s.version = "1.99.56"
3
+ s.version = "1.99.61"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0"
6
6
  s.summary = "Preliminary release of the 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.56
4
+ version: 1.99.61
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: 2018-03-20 00:00:00.000000000 Z
12
+ date: 2018-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit