fix crash when midi scale is not set
[jack_mixer.git] / memory_atomic.h
blobea71da91f0f892cff911348cdc8c3067da425620
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Non-sleeping memory allocation
6 * Copyright (C) 2006,2007 Nedko Arnaudov <nedko@arnaudov.name>
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; version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *****************************************************************************/
23 #ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
24 #define MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
26 typedef void * rtsafe_memory_pool_handle;
28 /* will sleep */
29 bool
30 rtsafe_memory_pool_create(
31 size_t data_size, /* chunk size */
32 size_t min_preallocated, /* min chunks preallocated */
33 size_t max_preallocated, /* max chunks preallocated */
34 bool enforce_thread_safety, /* true - enforce thread safety (internal mutex),
35 false - assume caller code is already thread-safe */
36 rtsafe_memory_pool_handle * pool_ptr);
38 /* will sleep */
39 void
40 rtsafe_memory_pool_destroy(
41 rtsafe_memory_pool_handle pool);
43 /* may sleep */
44 void
45 rtsafe_memory_pool_sleepy(
46 rtsafe_memory_pool_handle pool);
48 /* will not sleep, returns NULL if no memory is available */
49 void *
50 rtsafe_memory_pool_allocate(
51 rtsafe_memory_pool_handle pool);
53 /* may sleep, will not fail */
54 void *
55 rtsafe_memory_pool_allocate_sleepy(
56 rtsafe_memory_pool_handle pool);
58 /* will not sleep */
59 void
60 rtsafe_memory_pool_deallocate(
61 rtsafe_memory_pool_handle pool,
62 void * data);
64 typedef void * rtsafe_memory_handle;
66 /* will sleep */
67 bool
68 rtsafe_memory_init(
69 size_t max_size,
70 size_t prealloc_min,
71 size_t prealloc_max,
72 bool enforce_thread_safety, /* true - enforce thread safety (internal mutex),
73 false - assume caller code is already thread-safe */
74 rtsafe_memory_handle * handle_ptr);
76 /* will not sleep, returns NULL if no memory is available */
77 void *
78 rtsafe_memory_allocate(
79 rtsafe_memory_handle handle_ptr,
80 size_t size);
82 /* may sleep */
83 void
84 rtsafe_memory_sleepy(
85 rtsafe_memory_handle handle_ptr);
87 /* will not sleep */
88 void
89 rtsafe_memory_deallocate(
90 void * data);
92 void
93 rtsafe_memory_uninit(
94 rtsafe_memory_handle handle_ptr);
96 #endif /* #ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED */