mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
Remove deprecated wait functionality
This commit is contained in:
parent
16be668192
commit
af2335cf50
@ -32,17 +32,4 @@ class Failure implements Promise {
|
||||
public function watch(callable $func) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated. New code should use Amp\wait($promise) instead.
|
||||
*/
|
||||
public function wait() {
|
||||
trigger_error(
|
||||
'Amp\\Promise::wait() is deprecated and scheduled for removal. ' .
|
||||
'Please update code to use Amp\\wait($promise) instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
throw $this->error;
|
||||
}
|
||||
}
|
||||
|
@ -46,34 +46,6 @@ class Future implements Promisor, Promise {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated. New code should use Amp\wait($promise) instead.
|
||||
*/
|
||||
public function wait() {
|
||||
trigger_error(
|
||||
'Amp\\Promise::wait() is deprecated and scheduled for removal. ' .
|
||||
'Please update code to use Amp\\wait($promise) instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
$isWaiting = true;
|
||||
$resolvedError = $resolvedResult = null;
|
||||
$this->when(function($error, $result) use (&$isWaiting, &$resolvedError, &$resolvedResult) {
|
||||
$isWaiting = false;
|
||||
$resolvedError = $error;
|
||||
$resolvedResult = $result;
|
||||
});
|
||||
$reactor = getReactor();
|
||||
while ($isWaiting) {
|
||||
$reactor->tick();
|
||||
}
|
||||
if ($resolvedError) {
|
||||
throw $resolvedError;
|
||||
}
|
||||
|
||||
return $resolvedResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update watchers of resolution progress events
|
||||
*
|
||||
|
@ -32,17 +32,4 @@ class Success implements Promise {
|
||||
public function watch(callable $func): Success {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated. New code should use Amp\wait($promise) instead.
|
||||
*/
|
||||
public function wait() {
|
||||
trigger_error(
|
||||
'Amp\\Promise::wait() is deprecated and scheduled for removal. ' .
|
||||
'Please update code to use Amp\\wait($promise) instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
|
@ -37,34 +37,6 @@ class Unresolved implements Promise {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is deprecated. New code should use Amp\wait($promise) instead.
|
||||
*/
|
||||
public function wait() {
|
||||
trigger_error(
|
||||
'Amp\\Promise::wait() is deprecated and scheduled for removal. ' .
|
||||
'Please update code to use Amp\\wait($promise) instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
|
||||
$isWaiting = true;
|
||||
$resolvedError = $resolvedResult = null;
|
||||
$this->when(function($error, $result) use (&$isWaiting, &$resolvedError, &$resolvedResult) {
|
||||
$isWaiting = false;
|
||||
$resolvedError = $error;
|
||||
$resolvedResult = $result;
|
||||
});
|
||||
$reactor = getReactor();
|
||||
while ($isWaiting) {
|
||||
$reactor->tick();
|
||||
}
|
||||
if ($resolvedError) {
|
||||
throw $resolvedError;
|
||||
}
|
||||
|
||||
return $resolvedResult;
|
||||
}
|
||||
|
||||
protected function resolve(\Exception $error = null, $result = null) {
|
||||
if ($this->isResolved) {
|
||||
throw new \LogicException(
|
||||
|
@ -550,37 +550,3 @@ function __coroutinePromisify(CoroutineStruct $cs) : Promise {
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// === DEPRECATED FUNCTIONS ========================================================================
|
||||
|
||||
/**
|
||||
* Get the global singleton event reactor instance
|
||||
*
|
||||
* Note that the $factory callable is only invoked if no global reactor has yet been initialized.
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* === THIS FUNCTION IS DEPRECATED ===
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
*
|
||||
* @param callable $factory Optional factory callable for initializing a reactor
|
||||
* @return Reactor
|
||||
*/
|
||||
function reactor(callable $factory = null) {
|
||||
static $reactor;
|
||||
|
||||
$msg = 'This function is deprecated and scheduled for removal. Please use Amp\\getReactor()';
|
||||
trigger_error($msg, E_USER_DEPRECATED);
|
||||
|
||||
if ($reactor) {
|
||||
return $reactor;
|
||||
} elseif ($factory) {
|
||||
return ($reactor = $factory());
|
||||
} elseif (extension_loaded('uv')) {
|
||||
return ($reactor = new UvReactor);
|
||||
} elseif (extension_loaded('libevent')) {
|
||||
return ($reactor = new LibeventReactor);
|
||||
} else {
|
||||
return ($reactor = new NativeReactor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user