From 70a8e750202cb005750c53064b1ddea7c847d088 Mon Sep 17 00:00:00 2001 From: maroy Date: Mon, 10 Jan 2005 11:04:44 +0000 Subject: [PATCH] added signal possibility to threads --- .../include/LiveSupport/Core/RunnableInterface.h | 12 ++++++++++-- .../core/include/LiveSupport/Core/Thread.h | 16 ++++++++++++++-- livesupport/modules/core/src/TestRunnable.h | 15 +++++++++++++-- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/livesupport/modules/core/include/LiveSupport/Core/RunnableInterface.h b/livesupport/modules/core/include/LiveSupport/Core/RunnableInterface.h index c6ce33bc3..9691f7756 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/RunnableInterface.h +++ b/livesupport/modules/core/include/LiveSupport/Core/RunnableInterface.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/RunnableInterface.h,v $ ------------------------------------------------------------------------------*/ @@ -57,7 +57,7 @@ namespace Core { * A Runnable object, that can form the main execution body of a thread. * * @author $Author: maroy $ - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @see Thread */ class RunnableInterface @@ -77,6 +77,14 @@ class RunnableInterface virtual void run(void) throw () = 0; + /** + * Send a signal to the runnable object. + * + * @param userData user-specific parameter for the signal. + */ + virtual void + signal(int userData) throw () = 0; + /** * Signal the thread to stop, gracefully. * This is just a call to signal the execution to stop, eventually. diff --git a/livesupport/modules/core/include/LiveSupport/Core/Thread.h b/livesupport/modules/core/include/LiveSupport/Core/Thread.h index 44ae231df..7beae5b58 100644 --- a/livesupport/modules/core/include/LiveSupport/Core/Thread.h +++ b/livesupport/modules/core/include/LiveSupport/Core/Thread.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/Thread.h,v $ ------------------------------------------------------------------------------*/ @@ -62,7 +62,7 @@ namespace Core { * A generic thread executor class. * * @author $Author: maroy $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see RunnableInterface */ class Thread @@ -152,6 +152,18 @@ class Thread */ virtual void join(void) throw (); + + /** + * Send a signal to the runnable object inside this thread. + * + * @param userData user-specific parameter for the signal. + */ + virtual void + signal(int userData) throw () + { + runnable->signal(userData); + } + }; diff --git a/livesupport/modules/core/src/TestRunnable.h b/livesupport/modules/core/src/TestRunnable.h index 9c4774f34..a77bc3fb3 100644 --- a/livesupport/modules/core/src/TestRunnable.h +++ b/livesupport/modules/core/src/TestRunnable.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.2 $ + Version : $Revision: 1.3 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/TestRunnable.h,v $ ------------------------------------------------------------------------------*/ @@ -59,7 +59,7 @@ namespace Core { * A sample Runnable object, for testing purposes. * * @author $Author: maroy $ - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ class TestRunnable : public virtual RunnableInterface { @@ -128,6 +128,17 @@ class TestRunnable : public virtual RunnableInterface shouldRun = false; } + /** + * Send a signal to this object. + * This currently simply does nothing. + * + * @param userData the user data for the signal. + */ + virtual void + signal(int userData) throw () + { + } + /** * Get the state of the object. */