Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78639737
FutureProxy.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Aug 22, 03:09
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Aug 24, 03:09 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20079688
Attached To
rPHU libphutil
FutureProxy.php
View Options
<?php
/**
* Wraps another @{class:Future} and allows you to post-process its result once
* it resolves.
*/
abstract
class
FutureProxy
extends
Future
{
private
$proxied
;
public
function
__construct
(
Future
$proxied
=
null
)
{
if
(
$proxied
)
{
$this
->
setProxiedFuture
(
$proxied
);
}
}
public
function
setProxiedFuture
(
Future
$proxied
)
{
$this
->
proxied
=
$proxied
;
return
$this
;
}
protected
function
getProxiedFuture
()
{
if
(!
$this
->
proxied
)
{
throw
new
Exception
(
pht
(
'The proxied future has not been provided yet.'
));
}
return
$this
->
proxied
;
}
public
function
isReady
()
{
return
$this
->
getProxiedFuture
()->
isReady
();
}
public
function
resolve
(
$timeout
=
null
)
{
$this
->
getProxiedFuture
()->
resolve
(
$timeout
);
return
$this
->
getResult
();
}
public
function
setException
(
Exception
$ex
)
{
$this
->
getProxiedFuture
()->
setException
(
$ex
);
return
$this
;
}
public
function
getException
()
{
return
$this
->
getProxiedFuture
()->
getException
();
}
public
function
getReadSockets
()
{
return
$this
->
getProxiedFuture
()->
getReadSockets
();
}
public
function
getWriteSockets
()
{
return
$this
->
getProxiedFuture
()->
getWriteSockets
();
}
protected
function
getResult
()
{
if
(
$this
->
result
===
null
)
{
$result
=
$this
->
getProxiedFuture
()->
resolve
();
$result
=
$this
->
didReceiveResult
(
$result
);
$this
->
result
=
$result
;
}
return
$this
->
result
;
}
public
function
start
()
{
$this
->
getProxiedFuture
()->
start
();
return
$this
;
}
abstract
protected
function
didReceiveResult
(
$result
);
}
Event Timeline
Log In to Comment