@terascope/utils / event-loop / EventLoop
Class: EventLoop
A simple class for detecting when the event loop is blocked.
The recommend use is to call EventLoop.init(logger)
and then
await EventLoop.wait()
where you want to slow down potentially
long running synchronous code
Constructors
new EventLoop()
new EventLoop(
logger
):EventLoop
Parameters
Parameter | Type |
---|---|
logger | Logger |
Returns
Source
packages/utils/src/event-loop.ts:52
Properties
checkedInDiff
checkedInDiff:
number
Source
packages/utils/src/event-loop.ts:45
logger
readonly
logger:Logger
Source
packages/utils/src/event-loop.ts:52
DEFAULT_HEARTBEAT
static
DEFAULT_HEARTBEAT:number
=1000
Source
packages/utils/src/event-loop.ts:15
Accessors
blocked
get
blocked():boolean
Returns
boolean
Source
packages/utils/src/event-loop.ts:72
Methods
cancel()
cancel():
void
Cancel the event loop checker
Returns
void
Source
packages/utils/src/event-loop.ts:79
init()
static
init(logger
):EventLoop
Creates or replaces an instead of a global EvenLoop
Parameters
Parameter | Type |
---|---|
logger | Logger |
Returns
Source
packages/utils/src/event-loop.ts:34
wait()
static
wait():void
|Promise
<void
>
Adds a setTimeout if the event loop is blocked and will the delay will get slower the longer the event loop is block (with an upper limit)
Returns
void
| Promise
<void
>