Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-libraries
Commits
dd71a9b2
Commit
dd71a9b2
authored
Apr 15, 2008
by
Rinus Plasmeijer
Browse files
*** empty log message ***
parent
371e446f
Changes
4
Hide whitespace changes
Inline
Side-by-side
libraries/iTasks/iTasks.dcl
View file @
dd71a9b2
...
...
@@ -20,8 +20,10 @@ derive write Void, Wid, TCl
// iTask types
::
Task
a
:==
*
TSt
->
*(!
a
,!*
TSt
)
// an iTask is state stransition
::
*
TSt
// TSt is abstract task state
::
LabeledTask
a
:==
!(!
TaskLabel
,!
Task
a
)
// a Task with a label used for labeling buttons, pull down menu, and the like
::
TCl
a
=
TCl
!.(
Task
a
)
// task closure, container for a task used for higher order tasks (task which deliver a task)
::
*
TSt
// TSt is abstract task state
::
TaskLabel
:==
!
String
// label name
::
UserId
:==
!
Int
// a user id of an iTask user must be a unique integer value
...
...
@@ -35,7 +37,7 @@ derive write Void, Wid, TCl
// general types
::
HtmlCode
:==
[
BodyTag
]
// most programmers will only write bodytags
::
HtmlCode
:==
!
[
BodyTag
]
// most programmers will only write bodytags
::
Void
=
Void
// for tasks returning non interesting results, won't show up in editors either
...
...
@@ -201,7 +203,6 @@ closureTask :: The task is executed as usual, but a receiver closure is returne
Handy for passing a result to several interested parties.
closureLZTask :: Same, but now the original task will not be done unless someone is asking for the result somewhere.
*/
::
TCl
a
=
TCl
.(
Task
a
)
(-!>)
infix
4
::
(
Task
stop
)
(
Task
a
)
->
Task
(
Maybe
stop
,
TCl
a
)
|
iCreateAndPrint
stop
&
iCreateAndPrint
a
channel
::
String
(
Task
a
)
->
Task
(
TCl
a
,
TCl
a
)
|
iCreateAndPrint
a
...
...
libraries/iTasks/iTasks.icl
View file @
dd71a9b2
...
...
@@ -81,10 +81,10 @@ derive write Void, Options, Lifespan, Mode, StorageFormat, GarbageCollect, Glob
,
testModeOn
::
!
Bool
}
::
Wid
a
=
Wid
WorkflowName
// id of workflow process
::
WorflowProcess
=
ActiveWorkflow
!
WorkflowLabel
!(
TCl
Dynamic
)
|
SuspendedWorkflow
!
WorkflowLabel
!(
TCl
Dynamic
)
|
FinishedWorkflow
!
WorkflowLabel
!
Dynamic
!(
TCl
Dynamic
)
|
DeletedWorkflow
!
WorkflowLabel
::
WorflowProcess
=
ActiveWorkflow
!(!
UserId
,
!
WorkflowLabel
)
!(
TCl
Dynamic
)
|
SuspendedWorkflow
!(!
UserId
,
!
WorkflowLabel
)
!(
TCl
Dynamic
)
|
FinishedWorkflow
!(!
UserId
,
!
WorkflowLabel
)
!
Dynamic
!(
TCl
Dynamic
)
|
DeletedWorkflow
!(!
UserId
,
!
WorkflowLabel
)
// Initial values
...
...
@@ -335,8 +335,8 @@ startTstTask thisUser multiuser (userchanged,multiuserform) {traceOn, threadStor
iTaskInfo
++
if
(
doTrace
&&
traceOn
)
iTaskTraceInfo
[
[[
BodyTag
taskname
,
Br
]
<||>
mainbuts
]
<=>
[
BodyTag
subbuts
,
Br
,
Br
,
BodyTag
seltask
]
[
leftright
taskname
subbuts
,
Hr
[]
,
mainbuts
<=>
seltask
]
)]
]
...
...
@@ -355,6 +355,11 @@ where
// # world = if testModeOn deleteAllStateFiles id world
// = (Void,{hst & world = world})
leftright
left
right
=
Table
[
Tbl_Width
(
Percent
100
)]
[
Tr
[]
[
Td
[]
left
,
Td
[
Td_Align
Aln_Right
]
right
]
]
nilTable
tst
=
([],
tst
)
...
...
@@ -401,7 +406,7 @@ where
#
(
subtasksnames
,
tcode
)
=
unzipsubtasks
(
subtasks
!!
mainSelected
)
#
((
taskSelected
,
subButtons
,
chosenTask
),
hst
)
=
mkTaskButtons
False
(
"User "
<+++
thisUser
<+++
"subtask"
<+++
mainSelected
)
thisUser
[]
initialOptions
subtasksnames
hst
#
subButtons
=
if
(
length
sub
Button
s
>
1
)
subButtons
[]
#
subButtons
=
if
(
length
sub
tasksname
s
>
1
)
subButtons
[]
=
(
threadcode
,[
showMainLabel
chosenMain
,
showTrace
" / "
,
showLabel
chosenTask
],
mainButtons
,
subButtons
,
tcode
!!
taskSelected
,
hst
)
where
unziptasks
[]
=
([],[])
...
...
@@ -659,12 +664,12 @@ where
#
(
wfls
,
hst
)
=
workflowProcessStore
id
hst
// read workflow process administration
#
processid
=
length
wfls
+
1
// process id currently given by length list, used as offset in list
#
wfl
=
mkdyntask
options
processid
task
// convert user task in a dynamic task
#
nwfls
=
wfls
++
[
if
active
ActiveWorkflow
SuspendedWorkflow
label
wfl
]
// turn task into a dynamic task
#
nwfls
=
wfls
++
[
if
active
ActiveWorkflow
SuspendedWorkflow
(
userid
,
label
)
wfl
]
// turn task into a dynamic task
#
(
wfls
,
hst
)
=
workflowProcessStore
(\_
->
nwfls
)
hst
// write workflow process administration
=
(
Wid
(
processid
,
label
),{
tst
&
hst
=
hst
,
activated
=
True
})
mkdyntask
options
processid
task
=
TCl
(\
tst
->
convertTask
processid
label
task
{
tst
&
tasknr
=
[
processid
-
1
],
activated
=
True
,
options
=
options
,
workflowName
=
(
processid
,
label
)})
{
tst
&
tasknr
=
[
processid
-
1
],
activated
=
active
,
userId
=
userid
,
options
=
options
,
workflowName
=
(
processid
,
label
)})
convertTask
processid
label
task
tst
#
(
a
,
tst
=:{
hst
,
activated
})
=
newTask
label
(
assignTaskTo
False
userid
(
"main"
,
task
))
tst
//newTask label task tst
...
...
@@ -672,7 +677,7 @@ where
|
not
activated
=
(
dyn
,
tst
)
// not finished, return
#
(
wfls
,
hst
)
=
workflowProcessStore
id
hst
// read workflow process administration
#
wfls
=
case
(
wfls
!!(
processid
-
1
))
of
// update process administration
(
ActiveWorkflow
_
entry
)
->
updateAt
(
processid
-
1
)
(
FinishedWorkflow
label
dyn
entry
)
wfls
(
ActiveWorkflow
_
entry
)
->
updateAt
(
processid
-
1
)
(
FinishedWorkflow
(
userid
,
label
)
dyn
entry
)
wfls
_
->
wfls
#
(
wfls
,
hst
)
=
workflowProcessStore
(\_
->
wfls
)
hst
// write workflow process administration
=
(
dyn
,{
tst
&
hst
=
hst
})
...
...
@@ -692,7 +697,7 @@ deleteWorkflow (Wid (processid,label)) = newTask ("delete " +++ label) deleteWor
where
deleteWorkflow`
tst
=:{
hst
}
#
(
wfls
,
hst
)
=
workflowProcessStore
id
hst
// read workflow process administration
#
nwfls
=
updateAt
(
processid
-
1
)
(
DeletedWorkflow
label
)
wfls
// delete entry in table
#
nwfls
=
updateAt
(
processid
-
1
)
(
DeletedWorkflow
(
-1
,
label
)
)
wfls
// delete entry in table
#
(
wfls
,
hst
)
=
workflowProcessStore
(\_
->
nwfls
)
hst
// update workflow process administration
#
tst
=
deleteSubTasksAndThreads
[
processid
]
{
tst
&
hst
=
hst
}
// delete all iTask storage of this process ...
=
(
True
,{
tst
&
activated
=
True
})
// if everything is fine it should always succeed
...
...
@@ -744,17 +749,17 @@ showWorkflows alldone hst
where
mkTable
[]
=
[]
mkTable
wfls
=
[
showLabel
(
"Workflow Process Table:"
),
STable
[]
(
[
[
showTrace
"Id:"
,
showTrace
"Name:"
,
showTrace
"Status:"
]
,
[
Txt
"0"
,
Txt
defaultWorkflowName
,
if
alldone
(
Txt
"Finished"
)
(
Txt
"Active"
)]
STable
[]
(
[
[
showTrace
"
Workflow
Id:"
,
showTrace
"
User Id:"
,
showTrace
"Task
Name:"
,
showTrace
"Status:"
]
,
[
Txt
"0"
,
Txt
"0"
,
Txt
defaultWorkflowName
,
if
alldone
(
Txt
"Finished"
)
(
Txt
"Active"
)]
:
[[
Txt
(
toString
i
)]
++
showStatus
wfl
\\
wfl
<-
wfls
&
i
<-
[
1
..]]
]
),
Hr
[]
]
showStatus
(
ActiveWorkflow
label
dyntask
)
=
[
Txt
label
,
Txt
"Active"
]
showStatus
(
SuspendedWorkflow
label
dyntask
)
=
[
Txt
label
,
Txt
"Suspended"
]
showStatus
(
FinishedWorkflow
label
dyn
dyntask
)
=
[
Txt
label
,
Txt
"Finished"
]
showStatus
(
DeletedWorkflow
label
)
=
[
Txt
label
,
Txt
"Deleted"
]
showStatus
(
ActiveWorkflow
(
userid
,
label
)
dyntask
)
=
[
Txt
(
toString
userid
),
Txt
label
,
Txt
"Active"
]
showStatus
(
SuspendedWorkflow
(
userid
,
label
)
dyntask
)
=
[
Txt
(
toString
userid
),
Txt
label
,
Txt
"Suspended"
]
showStatus
(
FinishedWorkflow
(
userid
,
label
)
dyn
dyntask
)
=
[
Txt
(
toString
userid
),
Txt
label
,
Txt
"Finished"
]
showStatus
(
DeletedWorkflow
(
userid
,
label
)
)
=
[
Txt
(
toString
userid
),
Txt
label
,
Txt
"Deleted"
]
// ******************************************************************************************************
// Thread Creation and Deletion
...
...
libraries/iTasks/iTasks2.dcl
View file @
dd71a9b2
...
...
@@ -71,14 +71,12 @@ mchoiceAndTasks3 :: !HtmlCode ![((!Bool,!ChoiceUpdate,!HtmlCode),LabeledTask a)]
(-&&-) :: do both iTasks in any order (interleaved), task completed when both done
orTasks :: do all iTasks in any order (interleaved), task completed as soon as any subtask is done
andTasks :: do all iTasks in any order (interleaved), task completed when all done
multiAndTask :: start a new instance of the task on demand and do them in any order, task never completes /* not optimized yet */
andTasks_mu :: assign task to indicated users, task completed when all done
*/
(-||-)
infixr
3
::
!(
Task
a
)
!(
Task
a
)
->
Task
a
|
iData
a
(-&&-)
infixr
4
::
!(
Task
a
)
!(
Task
b
)
->
Task
(
a
,
b
)
|
iData
a
&
iData
b
orTasks
::
![
LabeledTask
a
]
->
(
Task
a
)
|
iData
a
andTasks
::
![
LabeledTask
a
]
->
Task
[
a
]
|
iData
a
multiAndTask
::
!(
LabeledTask
a
)
->
Task
Void
|
iData
a
andTasks_mu
::
!
String
![(
Int
,
Task
a
)]
->
Task
[
a
]
|
iData
a
/* convenient combinators for tasks that maybe return a result:
...
...
libraries/iTasks/iTasks2.icl
View file @
dd71a9b2
...
...
@@ -153,16 +153,6 @@ where
noNothing
[
RIGHT
Nothing
:
xs
]
=
True
noNothing
[
x
:
xs
]
=
noNothing
xs
multiAndTask
::
!(
LabeledTask
a
)
->
Task
Void
|
iData
a
multiAndTask
(
label
,
task
)
=
taskId
*=>
\
id
->
addNewTask`
id
0
where
addNewTask`
id
cnt
=
id
@:>
(
"New "
<+++
label
,
editTask
(
"Start "
<+++
label
)
Void
)
=>>
\_
->
(
addNewTask`
id
(
inc
cnt
)
-&&-
(
id
@:>
(
label
<+++
" "
<+++
cnt
,
task
))
#>>
return_V
Void
)
andTasks_mu
::
!
String
![(
Int
,
Task
a
)]
->
(
Task
[
a
])
|
iData
a
andTasks_mu
label
tasks
=
newTask
"andTasks_mu"
(
domu_andTasks
tasks
)
where
...
...
Write
Preview
Supports
Markdown
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