Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
feat(zone): adds onCreateTimer overriding interface
Browse files Browse the repository at this point in the history
Add onCreateTimer overriding interface similar to scheduleMicrotask.
  • Loading branch information
gfanzh authored and rkirov committed Feb 11, 2015
1 parent 3db2752 commit 43e00e5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/core/zone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ typedef void ZoneOnTurnStart();

typedef void ZoneScheduleMicrotask(fn());

typedef async.Timer ZoneCreateTimer(async.ZoneDelegate delegate,
async.Zone zone, Duration duration, fn());

/**
* Handles a [VmTurnZone] onError event.
*/
Expand Down Expand Up @@ -85,6 +88,7 @@ class VmTurnZone {
onTurnDone = _defaultOnTurnDone;
onTurnStart = _defaultOnTurnStart;
onScheduleMicrotask = _defaultOnScheduleMicrotask;
onCreateTimer = _defaultOnCreateTimer;
countPendingAsync = _defaultCountPendingAsync;
}

Expand Down Expand Up @@ -134,7 +138,7 @@ class VmTurnZone {
async.Timer _onCreateTimer(async.Zone self, async.ZoneDelegate delegate, async.Zone zone, Duration duration, fn()) {
var s = traceEnter(VmTurnZone_createTimer);
try {
return new _WrappedTimer(this, delegate, zone, duration, fn);
return onCreateTimer(delegate, zone, duration, fn);
} finally {
traceLeave(s);
}
Expand Down Expand Up @@ -224,6 +228,15 @@ class VmTurnZone {
ZoneScheduleMicrotask onScheduleMicrotask;
void _defaultOnScheduleMicrotask(fn) => _asyncQueue.add(fn);

/**
* Called any time a timer is created. If you override [onCreateTimer],
* you are expected to return a [Timer] which call the function at some point.
*/
ZoneCreateTimer onCreateTimer;
async.Timer _defaultOnCreateTimer(async.ZoneDelegate delegate,
async.Zone zone, Duration duration, fn())
=> new _WrappedTimer(this, delegate, zone, duration, fn);

LongStackTrace _longStacktrace = null;

LongStackTrace _getLongStacktrace(name) {
Expand Down

0 comments on commit 43e00e5

Please sign in to comment.