<!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::Util::Timer</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.Util.html" class="namespace">Poco::Util</a></h1> <h1 class="symbol">class Timer</h1> </div> <div class="body"> <p> <b>Library:</b> Util<br /> <b>Package:</b> Timer<br /> <b>Header:</b> Poco/Util/Timer.h</p> <h2>Description</h2> <div class="description"> <p>A <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a> allows to schedule tasks (<a href="Poco.Util.TimerTask.html" title="class Poco::Util::TimerTask">TimerTask</a> objects) for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals. </p> <p>The <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a> object creates a thread that executes all scheduled tasks sequentially. Therefore, tasks should complete their work as quickly as possible, otherwise subsequent tasks may be delayed. </p> <p><a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a> is save for multithreaded use - multiple threads can schedule new tasks simultaneously. </p> <p>Acknowledgement: The interface of this class has been inspired by the java.util.<a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a> class from Java 1.3. </p> </div> <h2>Inheritance</h2> <p><b>Direct Base Classes: </b><a href="Poco.Runnable.html" title="class Poco::Runnable">Poco::Runnable</a></p> <p><b>All Base Classes: </b><a href="Poco.Runnable.html" title="class Poco::Runnable">Poco::Runnable</a></p> <h2>Member Summary</h2> <p><b>Member Functions: </b><a href="Poco.Util.Timer.html#17265" title="Poco::Util::Timer::cancel()">cancel</a>, <a href="Poco.Util.Timer.html#17285" title="Poco::Util::Timer::run()">run</a>, <a href="Poco.Util.Timer.html#17266" title="Poco::Util::Timer::schedule()">schedule</a>, <a href="Poco.Util.Timer.html#17277" title="Poco::Util::Timer::scheduleAtFixedRate()">scheduleAtFixedRate</a></p> <p><b>Inherited Functions: </b><a href="Poco.Runnable.html#9810" title="Poco::Runnable::run()">run</a></p> <h2>Constructors</h2> <h3><a name="17261">Timer</a></h3> <p class="decl"><a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>();</p> <div class="description"> <p>Creates the <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>. </p> </div> <h3><a name="17262">Timer</a></h3> <p class="decl">explicit <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>(<br /> <a href="Poco.Thread.html#10815" title="enum Poco::Thread::Priority">Poco::Thread::Priority</a> priority<br />);</p> <div class="description"> <p>Creates the <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>, using a timer thread with the given priority. </p> </div> <h2>Destructor</h2> <h3><a name="17264">~Timer</a> <img src="images/virtual.gif" alt="virtual" title="virtual" style="vertical-align:baseline;" border="0" /> </h3> <p class="decl">~<a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>();</p> <div class="description"> <p>Destroys the <a href="Poco.Util.Timer.html" title="class Poco::Util::Timer">Timer</a>, cancelling all pending tasks. </p> </div> <h2>Member Functions</h2> <h3><a name="17265">cancel</a></h3> <p class="decl">void cancel();</p> <div class="description"> <p>Cancels all pending tasks. </p> <p>If a task is currently running, it is allowed to finish. </p> </div> <h3><a name="17266">schedule</a></h3> <p class="decl">void schedule(<br /> <a href="Poco.Util.TimerTask.html#17293" title="Poco::Util::TimerTask::Ptr">TimerTask::Ptr</a> pTask,<br /> <a href="Poco.Timestamp.html" title="class Poco::Timestamp">Poco::Timestamp</a> time<br />);</p> <div class="description"> <p>Schedules a task for execution at the specified time. </p> <p>If the time lies in the past, the task is executed immediately. </p> </div> <h3><a name="17269">schedule</a></h3> <p class="decl">void schedule(<br /> <a href="Poco.Util.TimerTask.html#17293" title="Poco::Util::TimerTask::Ptr">TimerTask::Ptr</a> pTask,<br /> long delay,<br /> long interval<br />);</p> <div class="description"> <p>Schedules a task for periodic execution. </p> <p>The task is first executed after the given delay. Subsequently, the task is executed periodically with the given interval in milliseconds between invocations. </p> </div> <h3><a name="17273">schedule</a></h3> <p class="decl">void schedule(<br /> <a href="Poco.Util.TimerTask.html#17293" title="Poco::Util::TimerTask::Ptr">TimerTask::Ptr</a> pTask,<br /> <a href="Poco.Timestamp.html" title="class Poco::Timestamp">Poco::Timestamp</a> time,<br /> long interval<br />);</p> <div class="description"> <p>Schedules a task for periodic execution. </p> <p>The task is first executed at the given time. Subsequently, the task is executed periodically with the given interval in milliseconds between invocations. </p> </div> <h3><a name="17277">scheduleAtFixedRate</a></h3> <p class="decl">void scheduleAtFixedRate(<br /> <a href="Poco.Util.TimerTask.html#17293" title="Poco::Util::TimerTask::Ptr">TimerTask::Ptr</a> pTask,<br /> long delay,<br /> long interval<br />);</p> <div class="description"> <p>Schedules a task for periodic execution at a fixed rate. </p> <p>The task is first executed after the given delay. Subsequently, the task is executed periodically every number of milliseconds specified by interval. </p> <p>If task execution takes longer than the given interval, further executions are delayed. </p> </div> <h3><a name="17281">scheduleAtFixedRate</a></h3> <p class="decl">void scheduleAtFixedRate(<br /> <a href="Poco.Util.TimerTask.html#17293" title="Poco::Util::TimerTask::Ptr">TimerTask::Ptr</a> pTask,<br /> <a href="Poco.Timestamp.html" title="class Poco::Timestamp">Poco::Timestamp</a> time,<br /> long interval<br />);</p> <div class="description"> <p>Schedules a task for periodic execution at a fixed rate. </p> <p>The task is first executed at the given time. Subsequently, the task is executed periodically every number of milliseconds specified by interval. </p> <p>If task execution takes longer than the given interval, further executions are delayed. </p> </div> <h3><a name="17285">run</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">void run();</p> <div class="description"> <p></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> <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>