/[svn]/linuxsampler/branches/release0_4_0/src/common/ConditionServer.cpp
ViewVC logotype

Annotation of /linuxsampler/branches/release0_4_0/src/common/ConditionServer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 943 - (hide annotations) (download)
Sat Nov 25 18:07:35 2006 UTC (17 years, 6 months ago) by (unknown author)
File size: 3143 byte(s)
This commit was manufactured by cvs2svn to create branch 'release0_4_0'.
1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 880 * Copyright (C) 2005, 2006 Christian Schoenebeck *
7 schoenebeck 53 * *
8     * This program is free software; you can redistribute it and/or modify *
9     * it under the terms of the GNU General Public License as published by *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #include "ConditionServer.h"
25    
26 schoenebeck 880 namespace LinuxSampler {
27    
28 schoenebeck 53 ConditionServer::ConditionServer() {
29     bConditionQuick = false;
30     bChangeRequest = false;
31     bOldCondition = false;
32     }
33    
34     bool* ConditionServer::Push(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
35     dmsg(3,("conditionserver:Push() requesting change to %d\n", bCondition));
36     PushMutex.Lock();
37     bOldCondition = bConditionQuick;
38     if (bConditionQuick != bCondition) {
39     bChangeRequest = bCondition;
40     int timeoutexceeded = SyncCondition.WaitAndUnlockIf(bOldCondition, TimeoutSeconds, TimeoutNanoSeconds); // wait until actually condition was changed on Pop() side
41     if (timeoutexceeded) return NULL;
42     }
43     return &bOldCondition;
44     }
45    
46     bool* ConditionServer::PushAndUnlock(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
47     bool* pBefore = Push(bCondition, TimeoutSeconds, TimeoutNanoSeconds);
48     Unlock();
49     return pBefore;
50     }
51    
52     void ConditionServer::Unlock() {
53     PushMutex.Unlock();
54     }
55    
56     bool ConditionServer::GetUnsafe() {
57     return bConditionQuick;
58     }
59    
60     bool ConditionServer::Pop() {
61     if (bConditionQuick == bChangeRequest) return bConditionQuick;
62     dmsg(3,("conditionserver:Pop() change requested\n"));
63     bConditionQuick = bChangeRequest;
64     SyncCondition.Set(bChangeRequest);
65     dmsg(3,("conditionserver:Pop() condition now: %d\n", bConditionQuick));
66     return bConditionQuick;
67     }
68 schoenebeck 880
69     } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC