1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Task</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.html" class="namespace">Poco</a></h1>
<h1 class="symbol">class Task</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Foundation<br />
<b>Package:</b> Tasks<br />
<b>Header:</b> Poco/Task.h</p>
<h2>Description</h2>
<div class="description">
<p>A <a href="Poco.Task.html" title="class Poco::Task">Task</a> is a subclass of <a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a> that has a name and supports progress reporting and cancellation. </p>
<p>A <a href="Poco.TaskManager.html" title="class Poco::TaskManager">TaskManager</a> object can be used to take care of the lifecycle of a <a href="Poco.Task.html" title="class Poco::Task">Task</a>. </p>
</div>
<h2>Inheritance</h2>
<p><b>Direct Base Classes: </b><a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a>, <a href="Poco.RefCountedObject.html" title="class Poco::RefCountedObject">RefCountedObject</a></p>
<p><b>All Base Classes: </b><a href="Poco.RefCountedObject.html" title="class Poco::RefCountedObject">RefCountedObject</a>, <a href="Poco.Runnable.html" title="class Poco::Runnable">Runnable</a></p>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Task.html#10560" title="Poco::Task::cancel()">cancel</a>, <a href="Poco.Task.html#10574" title="Poco::Task::getOwner()">getOwner</a>, <a href="Poco.Task.html#10561" title="Poco::Task::isCancelled()">isCancelled</a>, <a href="Poco.Task.html#10558" title="Poco::Task::name()">name</a>, <a href="Poco.Task.html#10570" title="Poco::Task::postNotification()">postNotification</a>, <a href="Poco.Task.html#10559" title="Poco::Task::progress()">progress</a>, <a href="Poco.Task.html#10563" title="Poco::Task::reset()">reset</a>, <a href="Poco.Task.html#10565" title="Poco::Task::run()">run</a>, <a href="Poco.Task.html#10564" title="Poco::Task::runTask()">runTask</a>, <a href="Poco.Task.html#10572" title="Poco::Task::setOwner()">setOwner</a>, <a href="Poco.Task.html#10568" title="Poco::Task::setProgress()">setProgress</a>, <a href="Poco.Task.html#10575" title="Poco::Task::setState()">setState</a>, <a href="Poco.Task.html#10566" title="Poco::Task::sleep()">sleep</a>, <a href="Poco.Task.html#10562" title="Poco::Task::state()">state</a></p>
<p><b>Inherited Functions: </b><a href="Poco.RefCountedObject.html#9659" title="Poco::RefCountedObject::duplicate()">duplicate</a>, <a href="Poco.RefCountedObject.html#9661" title="Poco::RefCountedObject::referenceCount()">referenceCount</a>, <a href="Poco.RefCountedObject.html#9660" title="Poco::RefCountedObject::release()">release</a>, <a href="Poco.Runnable.html#9810" title="Poco::Runnable::run()">run</a></p>
<h2>Enumerations</h2>
<h3><a name="10550">TaskState</a></h3>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="10551">TASK_IDLE</a></p>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="10552">TASK_STARTING</a></p>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="10553">TASK_RUNNING</a></p>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="10554">TASK_CANCELLING</a></p>
<div class="description">
<p></p>
</div>
<p class="decl"><a name="10555">TASK_FINISHED</a></p>
<div class="description">
<p></p>
</div>
<h2>Constructors</h2>
<h3><a name="10556">Task</a></h3>
<p class="decl"><a href="Poco.Task.html" title="class Poco::Task">Task</a>(<br /> const std::string & name<br />);</p>
<div class="description">
<p>Creates the <a href="Poco.Task.html" title="class Poco::Task">Task</a>. </p>
</div>
<h2>Destructor</h2>
<h3><a name="10577">~Task</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual ~<a href="Poco.Task.html" title="class Poco::Task">Task</a>();</p>
<div class="description">
<p>Destroys the <a href="Poco.Task.html" title="class Poco::Task">Task</a>. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="10560">cancel</a></h3>
<p class="decl">void cancel();</p>
<div class="description">
<p>Requests the task to cancel itself. For cancellation to work, the task's <a href="Poco.Task.html#10564" title="Poco::Task::runTask()">runTask</a>() method must periodically call <a href="Poco.Task.html#10561" title="Poco::Task::isCancelled()">isCancelled</a>() and react accordingly. </p>
</div>
<h3><a name="10561">isCancelled</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool isCancelled() const;</p>
<div class="description">
<p>Returns true if cancellation of the task has been requested. </p>
<p>A <a href="Poco.Task.html" title="class Poco::Task">Task</a>'s <a href="Poco.Task.html#10564" title="Poco::Task::runTask()">runTask</a>() method should periodically call this method and stop whatever it is doing in an orderly way when this method returns true. </p>
</div>
<h3><a name="10558">name</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">const std::string & name() const;</p>
<div class="description">
<p>Returns the task's name. </p>
</div>
<h3><a name="10559">progress</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">float progress() const;</p>
<div class="description">
<p>Returns the task's progress. The value will be between 0.0 (just started) and 1.0 (completed). </p>
</div>
<h3><a name="10563">reset</a></h3>
<p class="decl">void reset();</p>
<div class="description">
<p>Sets the task's progress to zero and clears the cancel flag. </p>
</div>
<h3><a name="10565">run</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void run();</p>
<div class="description">
<p>Calls the task's <a href="Poco.Task.html#10564" title="Poco::Task::runTask()">runTask</a>() method and notifies the owner of the task's start and completion. </p>
</div>
<div class="description"><p><b>See also:</b> <a href="Poco.Runnable.html#9810" title="Poco::Runnable::run()">Poco::Runnable::run()</a></p></div>
<h3><a name="10564">runTask</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual void runTask() = 0;</p>
<div class="description">
<p>Do whatever the task needs to do. Must be overridden by subclasses. </p>
</div>
<h3><a name="10562">state</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Task.html#10550" title="enum Poco::Task::TaskState">TaskState</a> state() const;</p>
<div class="description">
<p>Returns the task's current state. </p>
</div>
<h3><a name="10574">getOwner</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.TaskManager.html" title="class Poco::TaskManager">TaskManager</a> * getOwner() const;</p>
<div class="description">
<p>Returns the owner of the task, which may be NULL. </p>
</div>
<h3><a name="10570">postNotification</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">virtual void postNotification(<br /> <a href="Poco.Notification.html" title="class Poco::Notification">Notification</a> * pNf<br />);</p>
<div class="description">
<p>Posts a notification to the task manager's notification center. </p>
<p>A task can use this method to post custom notifications about its progress. </p>
</div>
<h3><a name="10572">setOwner</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setOwner(<br /> <a href="Poco.TaskManager.html" title="class Poco::TaskManager">TaskManager</a> * pOwner<br />);</p>
<div class="description">
<p>Sets the (optional) owner of the task. </p>
</div>
<h3><a name="10568">setProgress</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setProgress(<br /> float progress<br />);</p>
<div class="description">
<p>Sets the task's progress. The value should be between 0.0 (just started) and 1.0 (completed). </p>
</div>
<h3><a name="10575">setState</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">void setState(<br /> <a href="Poco.Task.html#10550" title="enum Poco::Task::TaskState">TaskState</a> state<br />);</p>
<div class="description">
<p>Sets the task's state. </p>
</div>
<h3><a name="10566">sleep</a> <img src="images/protected.gif" alt="protected" title="protected" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool sleep(<br /> long milliseconds<br />);</p>
<div class="description">
<p>Suspends the current thread for the specified amount of time. </p>
<p>If the task is cancelled while it is sleeping, <a href="Poco.Task.html#10566" title="Poco::Task::sleep()">sleep</a>() will return immediately and the return value will be true. If the time interval passes without the task being cancelled, the return value is false. </p>
<p>A <a href="Poco.Task.html" title="class Poco::Task">Task</a> should use this method in favor of <a href="Poco.Thread.html#10853" title="Poco::Thread::sleep()">Thread::sleep</a>(). </p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright © 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>
</div>
</body>
</html>
|