Skip to content

Commit 24e7955

Browse files
committed
MemoryPool fixes
Various deprecated methods weren't correct following recent changes.
1 parent b53dc66 commit 24e7955

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

rtos/MemoryPool.h

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
111111
@return address of the allocated memory block or nullptr in case of no memory available.
112112
113113
@note You may call this function from ISR context if the millisec parameter is set to 0.
114-
@deprecated Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.
114+
@deprecated Replaced with `try_alloc_for`. For example use `try_alloc_for(5s)` rather than `alloc_for(5000)`.
115115
*/
116-
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.")
116+
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Replaced with `try_alloc_for`. For example use `try_alloc_for(5s)` rather than `alloc_for(5000)`.")
117117
T *alloc_for(uint32_t millisec)
118118
{
119-
return alloc_for(std::chrono::duration<uint32_t, std::milli>(millisec));
119+
return try_alloc_for(std::chrono::duration<uint32_t, std::milli>(millisec));
120120
}
121121

122122
/** Allocate a memory block from a memory pool, optionally blocking.
@@ -139,13 +139,13 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
139139
due to internal 32-bit computations, but this is guaranteed to work if the
140140
wait is <= 0x7fffffff milliseconds (~24 days). If the limit is exceeded,
141141
the wait will time out earlier than specified.
142-
@deprecated Pass a chrono time_point, not an integer millisecond count. For example use `Kernel::Clock::now() + 5s`
143-
rather than `Kernel::get_ms_count() + 5000`.
142+
@deprecated Replaced with `try_alloc_until`. For example use `try_alloc_until(Kernel::Clock::now() + 5s)`
143+
rather than `alloc_until(Kernel::get_ms_count() + 5000)`.
144144
*/
145-
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono time_point, not an integer millisecond count. For example use `Kernel::Clock::now() + 5s` rather than `Kernel::get_ms_count() + 5000`.")
145+
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Replaced with `try_alloc_until`. For example use `try_alloc_until(Kernel::Clock::now() + 5s)` rather than `alloc_until(Kernel::get_ms_count() + 5000)`.")
146146
T *alloc_until(uint64_t millisec)
147147
{
148-
return alloc_until(Kernel::Clock::time_point(std::chrono::duration<uint64_t, std::milli>(millisec)));
148+
return try_alloc_until(Kernel::Clock::time_point(std::chrono::duration<uint64_t, std::milli>(millisec)));
149149
}
150150

151151
/** Allocate a memory block from a memory pool, blocking.
@@ -171,6 +171,7 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
171171
}
172172
return try_alloc_for(rel_time);
173173
}
174+
174175
/** Allocate a memory block from a memory pool, without blocking, and set memory block to zero.
175176
@return address of the allocated memory block or nullptr in case of no memory available.
176177
@@ -202,12 +203,12 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
202203
@return address of the allocated memory block or nullptr in case of no memory available.
203204
204205
@note You may call this function from ISR context if the millisec parameter is set to 0.
205-
@deprecated Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.
206+
@deprecated Replaced with `try_calloc_for`. For example use `try_calloc_for(5s)` rather than `calloc_for(5000)`.
206207
*/
207-
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono duration, not an integer millisecond count. For example use `5s` rather than `5000`.")
208+
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Replaced with `try_calloc_for`. For example use `try_calloc_for(5s)` rather than `calloc_for(5000)`.")
208209
T *calloc_for(uint32_t millisec)
209210
{
210-
return calloc_for(std::chrono::duration<uint32_t, std::milli>(millisec));
211+
return try_calloc_for(std::chrono::duration<uint32_t, std::milli>(millisec));
211212
}
212213

213214
/** Allocate a memory block from a memory pool, optionally blocking, and set memory block to zero.
@@ -218,7 +219,7 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
218219
*/
219220
T *try_calloc_for(Kernel::Clock::duration_u32 rel_time)
220221
{
221-
T *item = alloc_for(rel_time);
222+
T *item = try_alloc_for(rel_time);
222223
if (item != nullptr) {
223224
memset(item, 0, sizeof(T));
224225
}
@@ -234,13 +235,13 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
234235
due to internal 32-bit computations, but this is guaranteed to work if the
235236
wait is <= 0x7fffffff milliseconds (~24 days). If the limit is exceeded,
236237
the wait will time out earlier than specified.
237-
@deprecated Pass a chrono time_point, not an integer millisecond count. For example use `Kernel::Clock::now() + 5s`
238-
rather than `Kernel::get_ms_count() + 5000`.
238+
@deprecated Replaced with `try_calloc_until`. For example use `try_calloc_until(Kernel::Clock::now() + 5s)`
239+
rather than `calloc_until(Kernel::get_ms_count() + 5000)`.
239240
*/
240-
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Pass a chrono time_point, not an integer millisecond count. For example use `Kernel::Clock::now() + 5s` rather than `Kernel::get_ms_count() + 5000`.")
241+
MBED_DEPRECATED_SINCE("mbed-os-6.0.0", "Replaced with `try_calloc_until`. For example use `try_calloc_until(Kernel::Clock::now() + 5s)` rather than `calloc_until(Kernel::get_ms_count() + 5000)`.")
241242
T *calloc_until(uint64_t millisec)
242243
{
243-
return alloc_until(Kernel::Clock::time_point(std::chrono::duration<uint64_t, std::milli>(millisec)));
244+
return try_calloc_until(Kernel::Clock::time_point(std::chrono::duration<uint64_t, std::milli>(millisec)));
244245
}
245246

246247
/** Allocate a memory block from a memory pool, blocking, and set memory block to zero.
@@ -255,7 +256,7 @@ class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
255256
*/
256257
T *try_calloc_until(Kernel::Clock::time_point abs_time)
257258
{
258-
T *item = alloc_until(abs_time);
259+
T *item = try_alloc_until(abs_time);
259260
if (item != nullptr) {
260261
memset(item, 0, sizeof(T));
261262
}

0 commit comments

Comments
 (0)