You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Concurrency might be made to improve speed of the execution (This is rather called parallelism) or to improve readability of programs.
These are two very different goals.
When I search to improve speed of the execution, I might want to transform (pseudo-code):
but not when I search to improve readability of the program.
Conversely, when I search to improve readability of the program, I might want to transform (pseudo-code):
listenerClick(launchExercice_button): labelLaunch
removeListenerClick labelLaunch
setTimeout 30s:
removeListenerClick labelTry
print "Good job! See you soon!"
numberOfClick = 0
listenerClick(tryTripleClick_zone): labelTry
if numberOfClick == 0:
setTimeout 2s: labelTimeout
if numberOfClick < 3
numberOfClick = 0
print "Non-triple click"
numberOfClick += 1
if numberOfClick == 3:
numberOfClick = 0
print "Triple click"
clearTimeout(labelTimeout)
into:
await click launchExercice_button
until 30s:
while true:
await click tryTripleClick_zone
parallel_some:
sequence:
await click tryTripleClick_zone
await click tryTripleClick_zone
print "Triple click"
sequence:
await 2s
print "Non-triple click"
print "Good job! See you soon!"
but I don't get any improvement of speed of execution.
Here is the last comparison in real code (javascript vs funcSug):
letnumberOfClickfunctionlaunch(){document.getElementById('launch').removeEventListener('click',launch)setTimeout(O=>{document.getElementById('clickZone').removeEventListener('click',clickZone)console.log("Good job! See you soon!")},30000)numberOfClick=0document.getElementById('clickZone').addEventListener('click',clickZone)}lettimeoutIDfunctionclickZone(){if(numberOfClick==0){timeoutID=setTimeout(O=>{if(numberOfClick<3){numberOfClick=0console.log("Non-triple click")}},2000)}numberOfClick+=1if(numberOfClick==3){numberOfClick=0console.log("Triple click")clearTimeout(timeoutID)}}document.getElementById('launch').addEventListener('click',launch)
vs
.awaitClickBeep'#launch'{par_race.waitSeconds30{whiletrue.awaitClickBeep'#clickZone'{par_race{seq.awaitClickBeep'#clickZone'.awaitClickBeep'#clickZone'.print"Triple click"}{seq.waitSeconds2.print"Non-triple click"}}}}.print"Good job! See you soon!"
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Concurrency might be made to improve speed of the execution (This is rather called parallelism) or to improve readability of programs.
These are two very different goals.
When I search to improve speed of the execution, I might want to transform (pseudo-code):
into:
but not when I search to improve readability of the program.
Conversely, when I search to improve readability of the program, I might want to transform (pseudo-code):
into:
but I don't get any improvement of speed of execution.
Here is the last comparison in real code (javascript vs funcSug):
vs
Beta Was this translation helpful? Give feedback.
All reactions