mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-28 23:08:55 +00:00

Provided by anonymous user. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@348238 c90b9560-bf6c-de11-be94-00142212c4b1
157 lines
3.9 KiB
XML
157 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="gearmanclient.dobackground" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>GearmanClient::doBackground</refname>
|
|
<refpurpose>Run a task in the background</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>string</type><methodname>GearmanClient::doBackground</methodname>
|
|
<methodparam><type>string</type><parameter>function_name</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>workload</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter>unique</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Runs a task in the background, returning a job handle which can be used
|
|
to get the status of the running task.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>function_name</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
&gearman.parameter.functionname;
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>workload</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
&gearman.parameter.workload;
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>unique</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
&gearman.parameter.unique;
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
The job handle for the submitted task.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Submit and monitor a background job</title>
|
|
<para>
|
|
The worker in this example has an artificial delay introduced to mimic
|
|
a long running job. The client script periodically checks the status
|
|
of the running job.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
/* create our object */
|
|
$gmclient= new GearmanClient();
|
|
|
|
/* add the default server */
|
|
$gmclient->addServer();
|
|
|
|
/* run reverse client */
|
|
$job_handle = $gmclient->doBackground("reverse", "this is a test");
|
|
|
|
if ($gmclient->returnCode() != GEARMAN_SUCCESS)
|
|
{
|
|
echo "bad return code\n";
|
|
exit;
|
|
}
|
|
|
|
$done = false;
|
|
do
|
|
{
|
|
sleep(3);
|
|
$stat = $gmclient->jobStatus($job_handle);
|
|
if (!$stat[0]) // the job is known so it is not done
|
|
$done = true;
|
|
echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denominator: " . $stat[3] . "\n";
|
|
}
|
|
while(!$done);
|
|
|
|
echo "done!\n";
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
Running: true, numerator: 3, denominator: 14
|
|
Running: true, numerator: 6, denominator: 14
|
|
Running: true, numerator: 9, denominator: 14
|
|
Running: true, numerator: 12, denominator: 14
|
|
Running: false, numerator: 0, denominator: 0
|
|
done!
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><methodname>GearmanClient::doNormal</methodname></member>
|
|
<member><methodname>GearmanClient::doHigh</methodname></member>
|
|
<member><methodname>GearmanClient::doLow</methodname></member>
|
|
<member><methodname>GearmanClient::doHighBackground</methodname></member>
|
|
<member><methodname>GearmanClient::doLowBackground</methodname></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|