Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
GlibAdapter.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* GlibAdapter.h (C) 2000-2025 */
9/* */
10/* Utility classes to adapt to different versions of 'glib'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_CONCURRENCY_GLIBADAPTER_H
13#define ARCCORE_CONCURRENCY_GLIBADAPTER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/concurrency/ConcurrencyGlobal.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25class GlibCond;
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \internal
32 * \brief Encapsulates a GMutex from glib.
33 */
34class ARCCORE_CONCURRENCY_EXPORT GlibMutex
35{
36 friend class GlibCond;
37
38 public:
39
40 class Impl;
41
42 public:
43
44 class Lock
45 {
46 public:
47
48 Lock(GlibMutex& x);
49 ~Lock();
50 Lock() = delete;
51 Lock(const Lock&) = delete;
52 void operator=(const Lock&) = delete;
53
54 private:
55
56 Impl* m_mutex;
57 };
58
59 public:
60
61 GlibMutex() ARCCORE_NOEXCEPT;
62 ~GlibMutex();
63
64 public:
65
66 void lock();
67 void unlock();
68
69 private:
70
71 Impl* m_p = nullptr;
72};
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77/*!
78 * \internal
79 * \brief Encapsulates a GPrivate from glib.
80 */
81class ARCCORE_CONCURRENCY_EXPORT GlibPrivate
82{
83 public:
84
85 class Impl;
86
87 public:
88
89 GlibPrivate();
90 ~GlibPrivate();
91 void create();
92 void setValue(void* value);
93 void* getValue();
94
95 private:
96
97 Impl* m_p = nullptr;
98};
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
102
103/*!
104 * \internal
105 * \brief Encapsulates a GCond from glib.
106 */
107class ARCCORE_CONCURRENCY_EXPORT GlibCond
108{
109 public:
110
111 class Impl;
112
113 public:
114
115 GlibCond();
116 ~GlibCond();
117 void broadcast();
118 void wait(GlibMutex* mutex);
119
120 private:
121
122 Impl* m_p = nullptr;
123};
124
125/*---------------------------------------------------------------------------*/
126/*---------------------------------------------------------------------------*/
127
128} // namespace Arcane
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133#endif
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --