Skip to content

Commit

Permalink
Avoiding multiple plans execution with .desire
Browse files Browse the repository at this point in the history
  • Loading branch information
cleberjamaral committed Sep 23, 2020
1 parent 0b73edd commit 59e4853
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
23 changes: 23 additions & 0 deletions src/test/jason/asl/stdlib/desire.asl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,26 @@
!go(8,12);
!assert_false(.desire(go(8,12)));
.


@[test]
+!test_desire_avoid_concurrence
<-
-+count(0);
for ( .range(I,1,100) ) {
if (not .desire(singleton_plan(_))) {
!!singleton_plan(I);
}
}
.wait(1000);
.count(register(I),C);
!assert_equals(1,C);
.

+!singleton_plan(I)
<-
.wait(100);
+register(I);
.wait(100);
.
+!singleton_plan(I).
14 changes: 6 additions & 8 deletions src/test/jason/asl/stdlib/intend.asl
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@
@[test]
+!test_intend_avoid_concurrence
<-
-+count(0);
for ( .range(I,1,100) ) {
!!singleton_plan;
!!singleton_plan(I);
}
.wait(1000);
?count(C);
.count(register(_),C);
!assert_equals(1,C);
.

+!singleton_plan :
not .intend(singleton_plan)
+!singleton_plan(I) :
not .intend(singleton_plan(_))
<-
.wait(100);
?count(C);
-+count(C+1);
+register(I);
.wait(100);
.
+!singleton_plan.
+!singleton_plan(I).

0 comments on commit 59e4853

Please sign in to comment.