Commit 88b2abde authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Concurrent.Promise: Improved behavior for CONCURRENT_DEBUG.

Don't store raw backtraces, they may contain references to stuff
that the user doesn't expect to get extra references.
parent eab2ec6a
...@@ -884,9 +884,6 @@ class Promise ...@@ -884,9 +884,6 @@ class Promise
final int _materialised; final int _materialised;
final AggregateState _astate; final AggregateState _astate;
#if CONCURRENT_DEBUG
array(Pike.BacktraceFrame) createdat;
#endif
//! Creates a new promise, optionally initialised from a traditional callback //! Creates a new promise, optionally initialised from a traditional callback
//! driven method via @expr{executor(success, failure, @@extra)@}. //! driven method via @expr{executor(success, failure, @@extra)@}.
...@@ -897,9 +894,6 @@ class Promise ...@@ -897,9 +894,6 @@ class Promise
function(function(mixed:void), function(function(mixed:void),
function(mixed:void), mixed ...:void) executor, mixed ... extra) function(mixed:void), mixed ...:void) executor, mixed ... extra)
{ {
#if CONCURRENT_DEBUG
createdat = backtrace()[..<1];
#endif
state = STATE_NO_FUTURE; state = STATE_NO_FUTURE;
if (executor) if (executor)
executor(success, failure, @extra); executor(success, failure, @extra);
...@@ -1201,15 +1195,21 @@ class Promise ...@@ -1201,15 +1195,21 @@ class Promise
return max_failures(-1); return max_failures(-1);
} }
private string orig_backtrace =
#ifdef CONCURRENT_DEBUG
sprintf("%s\n------\n", describe_backtrace(backtrace()))
#else
""
#endif
;
protected void _destruct() protected void _destruct()
{ {
// NB: Don't complain about dropping STATE_NO_FUTURE on the floor. // NB: Don't complain about dropping STATE_NO_FUTURE on the floor.
if (state == STATE_PENDING) if (state == STATE_PENDING)
try_failure(({ sprintf("%O: Promise broken.\n", this), try_failure(({ sprintf("%O: Promise broken.\n%s",
#if CONCURRENT_DEBUG this, orig_backtrace),
this->createdat || backtrace() }));
#endif
backtrace() }));
if ((state == STATE_REJECTED) && global_on_failure) if ((state == STATE_REJECTED) && global_on_failure)
call_callback(global_on_failure, result); call_callback(global_on_failure, result);
result = UNDEFINED; result = UNDEFINED;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment