tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,3 @@
Show the syntax for a complete stoppage of a program inside a [[Conditional Structures|conditional]]. This includes all [[threads]]/[[processes]] which are part of your program.
Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks, etc.). Unless otherwise described, no special cleanup outside that provided by the operating system is provided.

View file

@ -0,0 +1,2 @@
---
note: Basic language learning

View file

@ -0,0 +1,3 @@
IF problem = 1 THEN
stop
FI

View file

@ -0,0 +1 @@
if(problem)exit 1

View file

@ -0,0 +1,10 @@
with Ada.Task_Identification; use Ada.Task_Identification;
procedure Main is
-- Create as many task objects as your program needs
begin
-- whatever logic is required in your Main procedure
if some_condition then
Abort_Task (Current_Task);
end if;
end Main;

View file

@ -0,0 +1,11 @@
procedure Main is
-- Create as many task objects as your program needs
begin
-- whatever logic is required in your Main procedure
if some_condition then
-- for each task created by the Main procedure
The_task.Stop;
-- end the Main procedure
return; -- actually, this is not needed
end if;
end Main;

View file

@ -0,0 +1,14 @@
task body Some_Task is
begin
loop
select
-- Some alternatives
...
or accept Stop do
-- Some cleanup while holding the caller is here
end Stop;
-- A cleanup asynchronous to the caller is here
exit; -- We are through
end select
end loop;
end Some_Task;

View file

@ -0,0 +1,10 @@
task body Some_Task is
begin
loop
select
-- Some alternatives
...
or terminate; -- We are through
end select
end loop;
end Some_Task;

View file

@ -0,0 +1,3 @@
on run
If problem then return
end run

View file

@ -0,0 +1,8 @@
on run
f()
display dialog "This message will never be displayed."
end run
on f()
error
end f

View file

@ -0,0 +1,2 @@
If (problem)
ExitApp

View file

@ -0,0 +1,3 @@
If problem Then
Exit
Endif

View file

@ -0,0 +1,3 @@
if problem = 1 then
end
end if

View file

@ -0,0 +1 @@
10 IF 1 THEN STOP

View file

@ -0,0 +1 @@
10 IF 1 THEN END

View file

@ -0,0 +1,3 @@
10 LET a = 1: LET b = 1
20 IF a = b THEN GO TO 9995
9995 STOP

View file

@ -0,0 +1 @@
IF condition% THEN QUIT

View file

@ -0,0 +1 @@
if condition exit

View file

@ -0,0 +1,6 @@
#include <cstdlib>
void problem_occured()
{
std::exit(EXIT_FAILURE);
}

View file

@ -0,0 +1,6 @@
#include <cstdlib>
void problem_occured()
{
std::abort();
}

View file

@ -0,0 +1,6 @@
#include <exception>
void problem_occured()
{
std::terminate();
}

View file

@ -0,0 +1,18 @@
#include <stdlib.h>
/* More "natural" way of ending the program: finish all work and return
from main() */
int main(int argc, char **argv)
{
/* work work work */
...
return 0; /* the return value is the exit code. see below */
}
if(problem){
exit(exit_code);
/* On unix, exit code 0 indicates success, but other OSes may follow
different conventions. It may be more portable to use symbols
EXIT_SUCCESS and EXIT_FAILURE; it all depends on what meaning
of codes are agreed upon.
*/
}

View file

@ -0,0 +1,5 @@
#include <stdlib.h>
if(problem){
abort();
}

View file

@ -0,0 +1 @@
exit_group();

View file

@ -0,0 +1,6 @@
(if problem
(. System exit integerErrorCode))
;conventionally, error code 0 is the code for "OK",
; while anything else is an actual problem
;optionally: (-> Runtime (. getRuntime) (. exit integerErrorCode))
}

View file

@ -0,0 +1,4 @@
(if problem
(-> Runtime (. getRuntime) (. halt integerErrorCode)))
; conventionally, error code 0 is the code for "OK",
; while anything else is an actual problem

View file

@ -0,0 +1,8 @@
(defun terminate (status)
#+sbcl (sb-ext:quit :unix-status status) ; SBCL
#+ccl ( ccl:quit status) ; Clozure CL
#+clisp ( ext:quit status) ; GNU CLISP
#+cmu ( unix:unix-exit status) ; CMUCL
#+abcl ( ext:quit :status status) ; Armed Bear CL
#+allegro ( excl:exit status :quiet t) ; Allegro CL
(cl-user::quit)) ; Many implementations put QUIT in the sandbox CL-USER package.

View file

@ -0,0 +1 @@
System.Halt;

View file

@ -0,0 +1 @@
System.Halt(1); // Optional exit code

View file

@ -0,0 +1,3 @@
if (true) {
interp.exitAtTop()
}

View file

@ -0,0 +1,3 @@
if (true) {
interp.exitAtTop("because the task said so")
}

View file

@ -0,0 +1,4 @@
debug @
if QUIT \ quit back to the interpreter
else BYE \ exit forth environment completely (e.g. end of a Forth shell script)
then

View file

@ -0,0 +1,3 @@
IF (condition) STOP [message]
! message is optional and is a character string.
! If present, the message is output to the standard output device.

View file

@ -0,0 +1 @@
10 IF 1 THEN STOP

View file

@ -0,0 +1 @@
Star Trek=@err{found a Star Trek reference\n}@abort

View file

@ -0,0 +1,5 @@
func main() {
if problem {
return
}
}

View file

@ -0,0 +1,46 @@
package main
import (
"fmt"
"runtime"
"time"
)
const problem = true
func main() {
fmt.Println("main program start")
// this will get run on exit
defer paperwork()
// this will not run to completion
go pcj()
// this will not get run on exit
rec := &requiresExternalCleanup{"external object"}
runtime.SetFinalizer(rec, cleanup)
if problem {
fmt.Println("main program returning")
return
}
}
func paperwork() {
fmt.Println("i's dotted, t's crossed")
}
func pcj() {
fmt.Println("there's uncle Joe")
time.Sleep(1e10)
fmt.Println("movin kinda slow")
}
type requiresExternalCleanup struct {
id string
}
func cleanup(rec *requiresExternalCleanup) {
fmt.Println(rec.id, "cleanup")
}

View file

@ -0,0 +1,13 @@
func main() {
fmt.Println("main program start")
// this will not get run on os.Exit
defer func() {
fmt.Println("deferred function")
}()
if problem {
fmt.Println("main program exiting")
os.Exit(-1)
}
}

View file

@ -0,0 +1,17 @@
func pcj() {
fmt.Println("at the junction")
defer func() {
fmt.Println("deferred from pcj")
}()
panic(10)
}
func main() {
fmt.Println("main program start")
defer func() {
fmt.Println("deferred from main")
}()
go pcj()
time.Sleep(1e9)
fmt.Println("main program done")
}

View file

@ -0,0 +1 @@
if (problem) System.exit(intExitCode)

View file

@ -0,0 +1 @@
if (problem) Runtime.runtime.halt(intExitCode)

View file

@ -0,0 +1,8 @@
import Control.Monad
import System.Exit
when problem do
exitWith ExitSuccess -- success
exitWith (ExitFailure integerErrorCode) -- some failure with code
exitSuccess -- success; in GHC 6.10+
exitFailure -- generic failure

View file

@ -0,0 +1 @@
ALARM( 999 )

View file

@ -0,0 +1,3 @@
exit(i) # terminates the program setting an exit code of i
stop(x1,x2,..) # terminates the program writing out x1,..; if any xi is a file writing switches to that file
runerr(i,x) # terminates the program with run time error 'i' for value 'x'

View file

@ -0,0 +1 @@
2!:55^:] condition

View file

@ -0,0 +1 @@
3 : 'if. 0~: condition do. 2!:55 condition end.'

View file

@ -0,0 +1,6 @@
if(problem){
System.exit(integerErrorCode);
//conventionally, error code 0 is the code for "OK",
// while anything else is an actual problem
//optionally: Runtime.getRuntime().exit(integerErrorCode);
}

View file

@ -0,0 +1,5 @@
if(problem){
Runtime.getRuntime().halt(integerErrorCode);
//conventionally, error code 0 is the code for "OK",
// while anything else is an actual problem
}

View file

@ -0,0 +1,2 @@
if (some_condition)
quit();

View file

@ -0,0 +1 @@
if 2 =2 then end

View file

@ -0,0 +1,6 @@
bye ; exits to shell
throw "toplevel ; exits to interactive prompt
pause ; escapes to interactive prompt for debugging
continue ; resumes after a PAUSE

View file

@ -0,0 +1,3 @@
if some_condition then
os.exit( number )
end

View file

@ -0,0 +1,4 @@
beginning
define(`problem',1)
ifelse(problem,1,`m4exit(1)')
ending

View file

@ -0,0 +1,3 @@
if condition
return
end

View file

@ -0,0 +1,3 @@
if condition
quit
end

View file

@ -0,0 +1 @@
If[problem, Abort[]];

View file

@ -0,0 +1,6 @@
/* Basically, it's simply quit() */
block([ans], loop, if (ans: read("Really quit ? (y, n)")) = 'y
then quit()
elseif ans = 'n then (print("Nice choice!"), 'done)
else (print("I dont' understand..."), go(loop)));

View file

@ -0,0 +1,9 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
extremePrejudice = (1 == 1)
if extremePrejudice then do
exit extremePrejudice
end
return

View file

@ -0,0 +1,2 @@
if problem:
quit(QuitFailure)

View file

@ -0,0 +1,4 @@
if problem then
exit integerErrorCode;
(* conventionally, error code 0 is the code for "OK",
while anything else is an actual problem *)

View file

@ -0,0 +1,3 @@
if(problem) {
Runtime->Exit(1);
};

View file

@ -0,0 +1 @@
if Problem then {Application.exit 0} end

View file

@ -0,0 +1 @@
if(stuff, quit)

View file

@ -0,0 +1,2 @@
if (problem)
exit(1);

View file

@ -0,0 +1,2 @@
STOP; /* terminates the entire program */
/* PL/I does any required cleanup, such as closing files. */

View file

@ -0,0 +1 @@
STOP THREAD (tiger); /* terminates only thread "tiger". */

View file

@ -0,0 +1,3 @@
SIGNAL FINISH; /* terminates the entire program. */
/* PL/I does any required cleanup, */
/* such as closing files. */

View file

@ -0,0 +1 @@
if $problem { exit $error-code }

View file

@ -0,0 +1,6 @@
if ($problem) {
exit integerErrorCode;
# conventionally, error code 0 is the code for "OK"
# (you can also omit the argument in this case)
# while anything else is an actual problem
}

View file

@ -0,0 +1,2 @@
(push '*Bye '(prinl "Goodbye world!"))
(bye)

View file

@ -0,0 +1,3 @@
if condition then
sysexit();
endif;

View file

@ -0,0 +1 @@
condition {stop} if

View file

@ -0,0 +1 @@
condition {quit} if

View file

@ -0,0 +1,3 @@
if (somecondition) {
exit
}

View file

@ -0,0 +1 @@
halt.

View file

@ -0,0 +1 @@
abort.

View file

@ -0,0 +1,3 @@
If problem = 1
End
EndIf

View file

@ -0,0 +1,3 @@
import sys
if problem:
sys.exit(1)

View file

@ -0,0 +1,3 @@
import os
if problem:
os.abort()

View file

@ -0,0 +1 @@
if(problem) q(status=10)

View file

@ -0,0 +1 @@
if error? try [6 / 0] [quit]

View file

@ -0,0 +1 @@
if error? try [dangerous-operation] [quit/return -12]

View file

@ -0,0 +1 @@
if error? try [something-silly] [q/return -12]

View file

@ -0,0 +1 @@
view layout [button "stopme" [halt]]

View file

@ -0,0 +1,29 @@
/*REXX program showing five ways to perform a REXX program termination. */
/*─────1st way────────────────────────────────────────────────────────*/
exit
/*─────2nd way────────────────────────────────────────────────────────*/
exit (expression) /*Note: the "expression" doen't need parenthesis*/
/*"expression" is any REXX expression. */
/*─────3rd way────────────────────────────────────────────────────────*/
return /*which returns to this program's invoker. If */
/*this is the main body (and not a subroutine), */
/*the REXX interpreter terminates the program. */
/*─────4th way────────────────────────────────────────────────────────*/
return (expression) /* [See the note above concerning parenthesis.] */
/*─────5th way────────────────────────────────────────────────────────*/
/*control*/
/**/ /*if there is no EXIT and program control "falls */
/**/ /*through" to the "bottom" (end) of the program, */
/**/ /*an EXIT is simulated and the program is */
/**/ /*terminated. */
/**/
/* e-o-f */ /* e-o-f = end-of-file. */

View file

@ -0,0 +1 @@
problem? [ bye ] ifTrue

View file

@ -0,0 +1,3 @@
if problem
exit(1)
end

View file

@ -0,0 +1,3 @@
if problem
abort # equivalent to exit(1)
end

View file

@ -0,0 +1 @@
&code = condition errlevel :s(end)

View file

@ -0,0 +1,2 @@
(if problem
(exit)) ; exit successfully

View file

@ -0,0 +1,2 @@
(if problem
(exit #f)) ; exit unsuccessfully

View file

@ -0,0 +1,2 @@
(if problem
(exit some-value)) ; converts "some-value" into an appropriate exit code for your system

View file

@ -0,0 +1,9 @@
$ include "seed7_05.s7i";
const proc: main is func
begin
# whatever logic is required in your main procedure
if some_condition then
exit(PROGRAM);
end if;
end func;

View file

@ -0,0 +1 @@
problem ifTrue: [exit: 1].

View file

@ -0,0 +1,5 @@
if problem then
OS.Process.exit OS.Process.failure
(* valid status codes include OS.Process.success and OS.Process.failure *)
else
()

View file

@ -0,0 +1 @@
:Stop

View file

@ -0,0 +1,5 @@
Prgm
...
Stop
...
EndPrgm

View file

@ -0,0 +1,4 @@
$$ MODE TUSCRIPT
IF (condition==1) STOP
-> execution stops and message:
IF (condition==2) ERROR/STOP "condition ",condition, " Execution STOP "

View file

@ -0,0 +1,6 @@
if {$problem} {
# Print a friendly message...
puts stderr "some problem occurred"
# Indicate to the caller of the program that there was a problem
exit 1
}

View file

@ -0,0 +1,3 @@
if {$problem} {
error "some problem occurred"
}

Some files were not shown because too many files have changed in this diff Show more