95 lines
2.6 KiB
Plaintext
95 lines
2.6 KiB
Plaintext
|
|
use core.accessibility_modifier;
|
||
|
|
use core.identifier;
|
||
|
|
use core.statement;
|
||
|
|
use core.parameter_list;
|
||
|
|
use core.return_type_list;
|
||
|
|
use core.type_system;
|
||
|
|
|
||
|
|
module Proc {
|
||
|
|
syntax {
|
||
|
|
type_system.extend({
|
||
|
|
name: "proc",
|
||
|
|
category: "concurrency",
|
||
|
|
primary_async_type: true,
|
||
|
|
replaces: ["async", "await"]
|
||
|
|
});
|
||
|
|
|
||
|
|
declaration.configure({
|
||
|
|
// Proc is the primary async function type
|
||
|
|
primary_async_keyword: "proc",
|
||
|
|
structure: {
|
||
|
|
prefix: ["accessibility_modifier"],
|
||
|
|
keyword: "proc",
|
||
|
|
name: "identifier",
|
||
|
|
signature: "required",
|
||
|
|
body: "block_required"
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
signature.configure({
|
||
|
|
// Async-specific signature constraints
|
||
|
|
concurrency_model: "cooperative",
|
||
|
|
return_types: {
|
||
|
|
// Can return Runnable or specific async result
|
||
|
|
allowed: ["Runnable", "Any"],
|
||
|
|
default: "Runnable"
|
||
|
|
},
|
||
|
|
features: {
|
||
|
|
cancellation: true,
|
||
|
|
timeout: true,
|
||
|
|
error_propagation: true
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
run_block.configure({
|
||
|
|
sections: [
|
||
|
|
{
|
||
|
|
name: "ok",
|
||
|
|
description: "Successful execution path",
|
||
|
|
required: true
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "error",
|
||
|
|
description: "Error handling path",
|
||
|
|
required: false
|
||
|
|
},
|
||
|
|
{
|
||
|
|
name: "cancel",
|
||
|
|
description: "Cancellation handling",
|
||
|
|
required: false
|
||
|
|
}
|
||
|
|
]
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
type ProcError {
|
||
|
|
String message;
|
||
|
|
Integer error_code;
|
||
|
|
Any context;
|
||
|
|
}
|
||
|
|
|
||
|
|
type Proc {
|
||
|
|
+proc run() -> [Runnable];
|
||
|
|
+proc cancel() -> [Boolean];
|
||
|
|
+proc is_running() -> [Boolean];
|
||
|
|
+proc is_completed() -> [Boolean];
|
||
|
|
|
||
|
|
+proc get_result() -> [Any];
|
||
|
|
+proc get_status() -> [String];
|
||
|
|
|
||
|
|
+proc set_timeout(Integer milliseconds) -> [Boolean];
|
||
|
|
+proc set_priority(Integer priority) -> [Boolean];
|
||
|
|
|
||
|
|
+proc on_error() -> [ProcError];
|
||
|
|
+proc recover(fn error_handler) -> [Boolean];
|
||
|
|
}
|
||
|
|
|
||
|
|
+fn create() -> [Proc];
|
||
|
|
+fn wait_all(Proc<> tasks) -> [Boolean];
|
||
|
|
+fn wait_any(Proc<> tasks) -> [Proc];
|
||
|
|
|
||
|
|
+fn parallel_map(fn mapper, Any<> input) -> [Any<>];
|
||
|
|
+fn parallel_filter(fn predicate, Any<> input) -> [Any<>];
|
||
|
|
+fn race(Proc<> tasks) -> [Proc];
|
||
|
|
}
|