1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
5 An audio time-stretching and pitch-shifting library.
6 Copyright 2007-2008 Chris Cannam.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. See the file
12 COPYING included with this distribution for more information.
15 #ifndef _RUBBERBAND_THREAD_H_
16 #define _RUBBERBAND_THREAD_H_
26 //#define DEBUG_THREAD 1
27 //#define DEBUG_MUTEX 1
28 //#define DEBUG_CONDITION 1
50 static bool threadingAvailable();
53 virtual void run() = 0;
59 static DWORD WINAPI
staticRun(LPVOID lpParam
);
63 static void *staticRun(void *);
80 #ifndef NO_THREAD_CHECKS
84 pthread_mutex_t m_mutex
;
85 #ifndef NO_THREAD_CHECKS
105 Condition(std::string name
);
108 // To wait on a condition, either simply call wait(), or call
109 // lock() and then wait() (perhaps testing some state in between).
110 // To signal a condition, call signal().
112 // Although any thread may signal on a given condition, only one
113 // thread should ever wait on any given condition object --
114 // otherwise there will be a race conditions in the logic that
115 // avoids the thread code having to track whether the condition's
116 // mutex is locked or not. If that is your requirement, this
117 // Condition wrapper is not for you.
120 void wait(int us
= 0);
131 pthread_mutex_t m_mutex
;
132 pthread_cond_t m_condition
;
135 #ifdef DEBUG_CONDITION