Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Basthon
Basthon Kernel
Commits
564feae7
Commit
564feae7
authored
Nov 15, 2022
by
Romain Casati
Browse files
Manage pending input in kernel-base.
parent
9d39cf62
Changes
2
Hide whitespace changes
Inline
Side-by-side
packages/gui-base/src/main.ts
View file @
564feae7
...
...
@@ -383,7 +383,11 @@ export class GUIBase {
/**
* Restart the kernel.
*/
public
kernelRestart
():
void
{
this
.
kernelSafe
?.
restart
();
}
public
kernelRestart
():
void
{
if
(
this
.
kernelSafe
?.
pendingInput
())
throw
new
Error
(
"
pending input
"
);
this
.
kernelSafe
?.
restart
();
}
/**
* Load ressources from URL (common part to files and modules).
...
...
packages/kernel-base/src/kernel.ts
View file @
564feae7
...
...
@@ -31,7 +31,8 @@ export class KernelBase {
private
_rootPath
:
string
;
private
_ready
:
boolean
=
false
;
private
readonly
_loaded
=
new
PromiseDelegate
<
void
>
();
public
_execution_count
:
number
=
0
;
protected
_execution_count
:
number
=
0
;
protected
_pendingInput
:
boolean
=
false
;
constructor
(
options
:
any
)
{
// root path where kernel is installed
...
...
@@ -215,8 +216,11 @@ export class KernelBase {
data
.
resolve
=
resolve
;
data
.
reject
=
reject
;
});
this
.
_pendingInput
=
true
;
this
.
dispatchEvent
(
"
eval.input
"
,
data
);
return
await
promise
;
const
res
=
await
promise
;
this
.
_pendingInput
=
false
;
return
res
;
}
/**
...
...
@@ -240,6 +244,13 @@ export class KernelBase {
}
};
/**
* Is an input pending?
*/
public
pendingInput
()
{
return
this
.
_pendingInput
;
}
/**
* Internal. Code evaluation after an eval.request event.
*/
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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