From 223388f1ad8f3e39856a1e6a01ef2acd1d820d25 Mon Sep 17 00:00:00 2001 From: Georg Holzmann Date: Mon, 14 Nov 2005 21:06:04 +0000 Subject: initial commit svn path=/trunk/externals/grh/; revision=3898 --- threadlib/src/threadlib.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 threadlib/src/threadlib.c (limited to 'threadlib/src/threadlib.c') diff --git a/threadlib/src/threadlib.c b/threadlib/src/threadlib.c new file mode 100755 index 0000000..da17100 --- /dev/null +++ b/threadlib/src/threadlib.c @@ -0,0 +1,83 @@ +/* +* +* threadlib +* library for threaded patching in PureData +* Copyright (C) 2005 Georg Holzmann +* heavily based on code by Tim Blechmann +* (detach, join, pd_devel) +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; see the file COPYING. If not, write to +* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +*/ + +#include "threadlib.h" + +typedef struct threadlib +{ + t_object x_obj; +} t_threadlib; + +t_class *threadlib_class; + +static void threadlib_help(void) +{ + post("\nthreadlib vers."VERSION", library for threaded patching\n" + "2005, by Georg Holzmann \n" + "heavily based on pd_devel code by Tim Blechmann\n" + + // help text: + "\tdetach run part of the patch in a helper thread\n" + "\tjoin synchronize messages to pd's main thread\n" + "\tsleep block system for specific time\n" + "\tthreadedsf threaded soundfiler from pd_devel_0.38\n" + + "WARNING: this is very experimental and can crash your patches !\n"); +} + +void *threadlib_new(void) +{ + t_threadlib *x = (t_threadlib *)pd_new(threadlib_class); + return (void *)x; +} + +void sleep_setup(); +void detach_setup(); +void join_setup(); +void threadedsf_setup(); +void sys_start_sfthread(); + +void threadlib_setup(void) +{ + // call all the setup functions: + sleep_setup(); + detach_setup(); + join_setup(); + threadedsf_setup(); + + // init callback system + h_init_callbacks(); + + // start global soundfiler helper thread + sys_start_sfthread(); + + post("\nthreadlib vers."VERSION", library for threaded patching\n" + "2005, by Georg Holzmann \n" + "heavily based on pd_devel code by Tim Blechmann\n" + "WARNING: this is very experimental and may crash your patches !\n"); + + threadlib_class = class_new(gensym("threadlib"), threadlib_new, 0, + sizeof(t_threadlib), 0, 0); + class_addmethod(threadlib_class, (t_method)threadlib_help, gensym("help"), 0); +} -- cgit v1.2.1