diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2002-10-22 23:16:30 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2002-10-22 23:16:30 +0000 |
commit | c2645dc4003b1391aba9b387a79a66cff1e63d3e (patch) | |
tree | 1ea6dccb8011a8ff64efb7c2ecf9a22caad860b3 /externals/grill/py/scripts/threads.py | |
parent | d62e56f4df9594f72ce501f5e19c974fd18e7295 (diff) |
This commit was generated by cvs2svn to compensate for changes in r189,
which included commits to RCS files with non-trunk default branches.
svn path=/trunk/; revision=190
Diffstat (limited to 'externals/grill/py/scripts/threads.py')
-rw-r--r-- | externals/grill/py/scripts/threads.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/externals/grill/py/scripts/threads.py b/externals/grill/py/scripts/threads.py new file mode 100644 index 00000000..e8486699 --- /dev/null +++ b/externals/grill/py/scripts/threads.py @@ -0,0 +1,43 @@ +# py/pyext - python script objects for PD and MaxMSP +# +# Copyright (c) 2002 Thomas Grill (xovo@gmx.net) +# For information on usage and redistribution, and for a DISCLAIMER OF ALL +# WARRANTIES, see the file, "license.txt," in this distribution. +# + +"""This is an example script for the py/pyext object's threading functionality. + +For threading support pyext exposes several function and variables + +- _detach([0/1]): by enabling thread detaching, threads will run in their own threads +- _priority(prio+-): you can raise or lower the priority of the current thread +- _stop({wait time in ms}): stop all running threads (you can additionally specify a wait time in ms) +- _shouldexit: this is a flag which indicates that the running thread should terminate + +""" + +import pyext +from time import sleep + +################################################################# + +class ex1(pyext._class): + """This is a simple class with one method looping over time.""" + + # number of inlets and outlets + _inlets=2 + _outlets=2 + + sltime=0.2 # sleep time + loops=30 # loops to iterate + + # method for bang to any inlet + def bang_(self,n): + for i in range(30): + # if _shouldexit is true, the thread ought to stop + if self._shouldexit: break + + self._outlet(n,i) + sleep(self.sltime) + + |