Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
64ba197d
Commit
64ba197d
authored
7 years ago
by
David Sehnal
Browse files
Options
Downloads
Patches
Plain Diff
working on mol-task
parent
abcb1f54
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/mol-task/execution/synchronous.ts
+0
-1
0 additions, 1 deletion
src/mol-task/execution/synchronous.ts
src/mol-task/time.ts
+2
-0
2 additions, 0 deletions
src/mol-task/time.ts
src/mol-task/util/immediate.ts
+15
-24
15 additions, 24 deletions
src/mol-task/util/immediate.ts
with
17 additions
and
25 deletions
src/mol-task/execution/synchronous.ts
+
0
−
1
View file @
64ba197d
...
@@ -10,7 +10,6 @@ import RuntimeContext from './runtime-context'
...
@@ -10,7 +10,6 @@ import RuntimeContext from './runtime-context'
const
voidPromise
=
Promise
.
resolve
(
void
0
);
const
voidPromise
=
Promise
.
resolve
(
void
0
);
class
SynchronousRuntimeContext
implements
RuntimeContext
{
class
SynchronousRuntimeContext
implements
RuntimeContext
{
id
:
number
=
0
;
requiresUpdate
:
boolean
=
false
;
requiresUpdate
:
boolean
=
false
;
update
(
progress
:
Partial
<
RuntimeContext
.
ProgressUpdate
>
):
Promise
<
void
>
{
return
voidPromise
;
}
update
(
progress
:
Partial
<
RuntimeContext
.
ProgressUpdate
>
):
Promise
<
void
>
{
return
voidPromise
;
}
runChild
<
T
>
(
progress
:
Partial
<
RuntimeContext
.
ProgressUpdate
>
,
task
:
Task
<
T
>
):
Promise
<
T
>
{
return
ExecuteSynchronous
(
task
);
}
runChild
<
T
>
(
progress
:
Partial
<
RuntimeContext
.
ProgressUpdate
>
,
task
:
Task
<
T
>
):
Promise
<
T
>
{
return
ExecuteSynchronous
(
task
);
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-task/time.ts
+
2
−
0
View file @
64ba197d
...
@@ -16,6 +16,8 @@ const now: () => number = (function () {
...
@@ -16,6 +16,8 @@ const now: () => number = (function () {
const
t
=
process
.
hrtime
();
const
t
=
process
.
hrtime
();
return
t
[
0
]
*
1000
+
t
[
1
]
/
1000000
;
return
t
[
0
]
*
1000
+
t
[
1
]
/
1000000
;
};
};
}
else
if
(
Date
.
now
)
{
return
()
=>
Date
.
now
();
}
else
{
}
else
{
return
()
=>
+
new
Date
();
return
()
=>
+
new
Date
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-task/
exec
uti
on
/immediate.ts
→
src/mol-task/uti
l
/immediate.ts
+
15
−
24
View file @
64ba197d
...
@@ -10,14 +10,21 @@
...
@@ -10,14 +10,21 @@
* MIT license.
* MIT license.
*/
*/
declare
var
WorkerGlobalScope
:
any
;
function
createImmediateActions
()
{
function
createImmediateActions
()
{
const
global
:
any
=
(
function
()
{
const
_window
=
typeof
window
!==
'
undefined
'
&&
window
;
const
_self
=
typeof
self
!==
'
undefined
'
&&
typeof
WorkerGlobalScope
!==
'
undefined
'
&&
self
instanceof
WorkerGlobalScope
&&
self
;
const
_global
=
typeof
global
!==
'
undefined
'
&&
global
;
return
_window
||
_global
||
_self
;
})();
type
Callback
=
(...
args
:
any
[])
=>
void
;
type
Callback
=
(...
args
:
any
[])
=>
void
;
type
Task
=
{
callback
:
Callback
,
args
:
any
[]
}
type
Task
=
{
callback
:
Callback
,
args
:
any
[]
}
const
tasksByHandle
:
{
[
handle
:
number
]:
Task
}
=
{
};
const
tasksByHandle
:
{
[
handle
:
number
]:
Task
}
=
{
};
const
doc
=
typeof
document
!==
'
undefined
'
?
document
:
void
0
;
const
doc
=
typeof
document
!==
'
undefined
'
?
document
:
void
0
;
let
currentlyRunningATask
=
false
;
let
nextHandle
=
1
;
// Spec says greater than zero
let
nextHandle
=
1
;
// Spec says greater than zero
let
registerImmediate
:
((
handle
:
number
)
=>
void
);
let
registerImmediate
:
((
handle
:
number
)
=>
void
);
...
@@ -60,24 +67,9 @@ function createImmediateActions() {
...
@@ -60,24 +67,9 @@ function createImmediateActions() {
}
}
function
runIfPresent
(
handle
:
number
)
{
function
runIfPresent
(
handle
:
number
)
{
// From the spec: 'Wait until any invocations of this algorithm started before this one have completed.'
// So if we're currently running a task, we'll need to delay this invocation.
if
(
currentlyRunningATask
)
{
// Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
// 'too much recursion' error.
setTimeout
(
runIfPresent
,
0
,
handle
);
}
else
{
const
task
=
tasksByHandle
[
handle
];
const
task
=
tasksByHandle
[
handle
];
if
(
task
)
{
currentlyRunningATask
=
true
;
try
{
run
(
task
);
}
finally
{
clearImmediate
(
handle
);
clearImmediate
(
handle
);
currentlyRunningATask
=
false
;
run
(
task
);
}
}
}
}
}
function
installNextTickImplementation
()
{
function
installNextTickImplementation
()
{
...
@@ -87,9 +79,6 @@ function createImmediateActions() {
...
@@ -87,9 +79,6 @@ function createImmediateActions() {
}
}
function
canUsePostMessage
()
{
function
canUsePostMessage
()
{
// The test against `importScripts` prevents this implementation from being installed inside a web worker,
// where `global.postMessage` means something completely different and can't be used for this purpose.
const
global
=
typeof
window
!==
'
undefined
'
?
window
as
any
:
void
0
;
if
(
global
&&
global
.
postMessage
&&
!
global
.
importScripts
)
{
if
(
global
&&
global
.
postMessage
&&
!
global
.
importScripts
)
{
let
postMessageIsAsynchronous
=
true
;
let
postMessageIsAsynchronous
=
true
;
const
oldOnMessage
=
global
.
onmessage
;
const
oldOnMessage
=
global
.
onmessage
;
...
@@ -108,7 +97,6 @@ function createImmediateActions() {
...
@@ -108,7 +97,6 @@ function createImmediateActions() {
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
// * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
const
messagePrefix
=
'
setImmediate$
'
+
Math
.
random
()
+
'
$
'
;
const
messagePrefix
=
'
setImmediate$
'
+
Math
.
random
()
+
'
$
'
;
const
global
=
typeof
window
!==
'
undefined
'
?
window
as
any
:
void
0
;
const
onGlobalMessage
=
function
(
event
:
any
)
{
const
onGlobalMessage
=
function
(
event
:
any
)
{
if
(
event
.
source
===
global
&&
if
(
event
.
source
===
global
&&
typeof
event
.
data
===
'
string
'
&&
typeof
event
.
data
===
'
string
'
&&
...
@@ -189,7 +177,10 @@ function createImmediateActions() {
...
@@ -189,7 +177,10 @@ function createImmediateActions() {
const
immediateActions
=
(
function
()
{
const
immediateActions
=
(
function
()
{
if
(
typeof
setImmediate
!==
'
undefined
'
)
{
if
(
typeof
setImmediate
!==
'
undefined
'
)
{
if
(
typeof
window
!==
'
undefined
'
)
{
if
(
typeof
window
!==
'
undefined
'
)
{
return
{
setImmediate
:
(
handler
:
any
,
...
args
:
any
[])
=>
window
.
setImmediate
(
handler
,
...
args
as
any
),
clearImmediate
:
(
handle
:
any
)
=>
window
.
clearImmediate
(
handle
)
};
return
{
setImmediate
:
(
handler
:
any
,
...
args
:
any
[])
=>
window
.
setImmediate
(
handler
,
...
args
as
any
),
clearImmediate
:
(
handle
:
any
)
=>
window
.
clearImmediate
(
handle
)
};
}
else
return
{
setImmediate
,
clearImmediate
}
}
else
return
{
setImmediate
,
clearImmediate
}
}
}
return
createImmediateActions
();
return
createImmediateActions
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment