Jack2: JackLinuxFutex.h Source File

Jack2 1.9.12

JackLinuxFutex.h
1 /*
2 Copyright (C) 2004-2008 Grame
3 Copyright (C) 2016 Filipe Coelho
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21 #ifndef __JackLinuxFutex__
22 #define __JackLinuxFutex__
23
24 #include "JackSynchro.h"
25 #include "JackCompilerDeps.h"
26 #include <stddef.h>
27
28 namespace Jack
29 {
30
41 class SERVER_EXPORT JackLinuxFutex : public detail::JackSynchro
42 {
43
44 private:
45 struct FutexData {
46 int futex; // futex, needs to be 1st member
47 bool internal; // current internal state
48 bool wasInternal; // initial internal state, only changes in allocate
49 bool needsChange; // change state on next wait call
50 int externalCount; // how many external clients have connected
51 };
52
53 int fSharedMem;
54 FutexData* fFutex;
55 bool fPrivate;
56 bool fPromiscuous;
57 int fPromiscuousGid;
58
59 protected:
60
61 void BuildName(const char* name, const char* server_name, char* res, int size);
62
63 public:
64
65 JackLinuxFutex();
66
67 bool Signal();
68 bool SignalAll();
69 bool Wait();
70 bool TimedWait(long usec);
71
72 bool Allocate(const char* name, const char* server_name, int value, bool internal = false);
73 bool Connect(const char* name, const char* server_name);
74 bool ConnectInput(const char* name, const char* server_name);
75 bool ConnectOutput(const char* name, const char* server_name);
76 bool Disconnect();
77 void Destroy();
78
79 void MakePrivate(bool priv);
80 };
81
82 } // end of namespace
83
84
85 #endif
86
Jack
Definition: JackAC3Encoder.cpp:30
Jack::detail::JackSynchro
An inter process synchronization primitive.
Definition: JackSynchro.h:35
Jack::JackLinuxFutex
Inter process synchronization using Linux futex.
Definition: JackLinuxFutex.h:41