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

Contents of /linuxsampler/trunk/src/common/ConditionServer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1933 - (show annotations) (download)
Thu Jul 9 17:37:41 2009 UTC (14 years, 9 months ago) by persson
File size: 2904 byte(s)
* fixed low-level ConditionServer usage bug that caused lockups on
  Windows

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2008 Christian Schoenebeck *
7 * *
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 "global_private.h"
25
26 #include "ConditionServer.h"
27
28 namespace LinuxSampler {
29
30 ConditionServer::ConditionServer() : Reader(Condition) {
31 Condition.GetConfigForUpdate() = false;
32 Condition.SwitchConfig() = false;
33 bOldCondition = false;
34 }
35
36 bool* ConditionServer::Push(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds) {
37 dmsg(3,("conditionserver:Push() requesting change to %d\n", bCondition));
38 PushMutex.Lock();
39 bool& c = Condition.GetConfigForUpdate();
40 bOldCondition = c;
41 c = bCondition;
42 Condition.SwitchConfig() = bCondition;
43 return &bOldCondition;
44 }
45
46 bool* ConditionServer::PushAndUnlock(bool bCondition, long TimeoutSeconds, long TimeoutNanoSeconds, bool bAlreadyLocked) {
47 dmsg(3,("conditionserver:PushAndUnlock() requesting change to %d\n", bCondition));
48 if (!bAlreadyLocked) PushMutex.Lock();
49 bool& c = Condition.GetConfigForUpdate();
50 bOldCondition = c;
51 c = bCondition;
52 Condition.SwitchConfig() = bCondition;
53 Unlock();
54 return &bOldCondition;
55 }
56
57 void ConditionServer::Unlock() {
58 PushMutex.Unlock();
59 }
60
61 bool ConditionServer::GetUnsafe() {
62 return Condition.GetConfigForUpdate();
63 }
64
65 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC