Mercurial > octave
annotate liboctave/util/oct-mutex.cc @ 29358:0a5b15007766 stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 09:52:15 -0500 |
parents | bd51beb6205e |
children | 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 2008-2021 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
7934 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
7934 | 28 #endif |
29 | |
30 #include "oct-mutex.h" | |
7957
ba2e00a216e8
Do not use "error" in octave_base_mutex class
John W. Eaton <jwe@octave.org>
parents:
7952
diff
changeset
|
31 #include "lo-error.h" |
7934 | 32 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
33 #if defined (OCTAVE_USE_WINDOWS_API) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
34 # include <windows.h> |
9233
b935bbfab7c4
Exclude pthread.h inclusion under Win32
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7957
diff
changeset
|
35 #elif defined (HAVE_PTHREAD_H) |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
36 # include <pthread.h> |
7934 | 37 #endif |
38 | |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
39 namespace octave |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
40 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
41 void |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
42 base_mutex::lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
43 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
44 (*current_liboctave_error_handler) ("mutex not supported on this platform"); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
45 } |
7934 | 46 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
47 void |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
48 base_mutex::unlock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
49 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
50 (*current_liboctave_error_handler) ("mutex not supported on this platform"); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
51 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
52 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
53 bool |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
54 base_mutex::try_lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
55 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
56 (*current_liboctave_error_handler) ("mutex not supported on this platform"); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
57 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
58 return false; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
59 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
60 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
61 #if defined (OCTAVE_USE_WINDOWS_API) |
7934 | 62 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
63 class |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
64 w32_mutex : public base_mutex |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
65 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
66 public: |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
67 w32_mutex (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
68 : base_mutex () |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
69 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
70 InitializeCriticalSection (&cs); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
71 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
72 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
73 ~w32_mutex (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
74 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
75 DeleteCriticalSection (&cs); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
76 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
77 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
78 void lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
79 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
80 EnterCriticalSection (&cs); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
81 } |
7934 | 82 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
83 void unlock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
84 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
85 LeaveCriticalSection (&cs); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
86 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
87 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
88 bool try_lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
89 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
90 return (TryEnterCriticalSection (&cs) != 0); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
91 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
92 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
93 private: |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
94 CRITICAL_SECTION cs; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
95 }; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
96 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
97 static DWORD thread_id = 0; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
98 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
99 void |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
100 thread::init (void) |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
101 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
102 thread_id = GetCurrentThreadId (); |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
103 } |
7934 | 104 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
105 bool |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
106 thread::is_thread (void) |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
107 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
108 return (GetCurrentThreadId () == thread_id); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
109 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
110 |
7934 | 111 #elif defined (HAVE_PTHREAD_H) |
112 | |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
113 class |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
114 pthread_mutex : public base_mutex |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
115 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
116 public: |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
117 pthread_mutex (void) |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
118 : base_mutex (), m_pm () |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
119 { |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
120 pthread_mutexattr_t attr; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
121 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
122 pthread_mutexattr_init (&attr); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
123 pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE); |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
124 pthread_mutex_init (&m_pm, &attr); |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
125 pthread_mutexattr_destroy (&attr); |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
126 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
127 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
128 ~pthread_mutex (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
129 { |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
130 pthread_mutex_destroy (&m_pm); |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
131 } |
7934 | 132 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
133 void lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
134 { |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
135 pthread_mutex_lock (&m_pm); |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
136 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
137 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
138 void unlock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
139 { |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
140 pthread_mutex_unlock (&m_pm); |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
141 } |
7934 | 142 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
143 bool try_lock (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
144 { |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
145 return (pthread_mutex_trylock (&m_pm) == 0); |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
146 } |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
147 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
148 private: |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
149 pthread_mutex_t m_pm; |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
150 }; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
151 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
152 static pthread_t thread_id = 0; |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
153 |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
154 void |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
155 thread::init (void) |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
156 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
157 thread_id = pthread_self (); |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
158 } |
7934 | 159 |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
160 bool |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
161 thread::is_thread (void) |
7952
2c0a0edae596
reorganize octave_mutex class
John W. Eaton <jwe@octave.org>
parents:
7943
diff
changeset
|
162 { |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
163 return (pthread_equal (thread_id, pthread_self ()) != 0); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
164 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11523
diff
changeset
|
165 |
7934 | 166 #endif |
167 | |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
168 static base_mutex * |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
169 init_rep (void) |
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
170 { |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
171 #if defined (OCTAVE_USE_WINDOWS_API) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
172 return new w32_mutex (); |
7934 | 173 #elif defined (HAVE_PTHREAD_H) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
174 return new pthread_mutex (); |
7934 | 175 #else |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
176 return new base_mutex (); |
7934 | 177 #endif |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
178 } |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
179 |
27379
3db033e86376
use m_ prefix for data members in most liboctave/util classes
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
180 mutex::mutex (void) : m_rep (init_rep ()) { } |
23057
bb7513d73673
move mutex classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
181 } |