2 Copyright (C) 2004-2008 Grame
3 Copyright (C) 2016 Filipe Coelho
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.
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.
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.
21 #ifndef __JackLinuxFutex__
22 #define __JackLinuxFutex__
24 #include "JackSynchro.h"
25 #include "JackCompilerDeps.h"
32 \brief Inter process synchronization using Linux futex.
34 Based on the JackPosixSemaphore class.
35 Adapted to work with linux futex to be as light as possible and also work in multiple architectures.
37 Adds a new 'MakePrivate' function that makes the sync happen in the local process only,
38 making it even faster for internal clients.
41 class SERVER_EXPORT JackLinuxFutex
: public detail::JackSynchro
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
61 void BuildName(const char* name
, const char* server_name
, char* res
, int size
);
70 bool TimedWait(long usec
);
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
);
79 void MakePrivate(bool priv
);