Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
clean-and-itasks
iTasks-SDK
Commits
8aedd474
Commit
8aedd474
authored
Aug 02, 2018
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewrite sequence in terms of foreverStIf to not leak memory
parent
4842d549
Pipeline
#13111
failed with stage
in 2 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
Libraries/iTasks/WF/Combinators/Common.dcl
Libraries/iTasks/WF/Combinators/Common.dcl
+1
-2
Libraries/iTasks/WF/Combinators/Common.icl
Libraries/iTasks/WF/Combinators/Common.icl
+11
-5
No files found.
Libraries/iTasks/WF/Combinators/Common.dcl
View file @
8aedd474
...
...
@@ -147,13 +147,12 @@ justdo :: !(Task (Maybe a)) -> Task a | iTask a
/**
* Execute the list of tasks one after another.
*
* @param Label: A label for tracing
* @param Tasks: The list of tasks to be executed sequentially
* @return The combined task
*
* @gin-icon sequence
*/
sequence
::
!
String
![
Task
a
]
->
Task
[
a
]
|
iTask
a
sequence
::
![
Task
a
]
->
Task
[
a
]
|
iTask
a
/**
* Repeats a task until a given predicate holds. The predicate is tested as soon as the
...
...
Libraries/iTasks/WF/Combinators/Common.icl
View file @
8aedd474
...
...
@@ -90,11 +90,17 @@ justdo task
Just
x
=
return
x
Nothing
=
throw
(
"The task returned nothing."
)
sequence
::
!
String
![
Task
a
]
->
Task
[
a
]
|
iTask
a
sequence
_
tasks
=
seqTasks
tasks
where
seqTasks
[]
=
return
[]
seqTasks
[
t
:
ts
]
=
t
>>-
\
a
->
seqTasks
ts
>>-
\
as
->
return
[
a
:
as
]
sequence
::
![
Task
a
]
->
Task
[
a
]
|
iTask
a
sequence
tasks
=
foreverStIf
//Continue while there are tasks left
(
not
o
isEmpty
o
snd
)
//Initial state, empty accumulator, all tasks
([],
tasks
)
//Run the first task and add it to the accumulator
(\(
acc
,
[
todo
:
todos
])->
todo
>>-
\
t
->
treturn
([
t
:
acc
],
todos
))
//When done, just return the accumulator
@
fst
foreverStIf
::
(
a
->
Bool
)
a
!(
a
->
Task
a
)
->
Task
a
|
iTask
a
foreverStIf
pred
st
t
=
parallel
[(
Embedded
,
par
st
Nothing
)]
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment