Reputation: 11
Is uv_prepare_init
deprecated?
In uv.h
there is a function definition, but nowhere I could find the function body in C file. However, on documentation, there are no keyword, as deprecated.
Is there any solution to replace uv_prepare_init
?
I need this handle for executing before polling I/O.
Upvotes: 1
Views: 402
Reputation: 50548
uv_prepare_init
isn't deprecated.
See the file loop-watcher.c
for more details. It's available both for unix (libuv/src/unix
) and windows (libuv/src/win
).
So, what's the magic?
How is it that there is no definition but the function is part of the library?
Macros. That's all. The definition is there, even though a bit obfuscated.
There exists a macro called UV_LOOP_WATCHER_DEFINE
, a part of which follows:
#define UV_LOOP_WATCHER_DEFINE(name, type) \
int uv_##name##_init(uv_loop_t* loop, uv_##name##_t* handle) { \
uv__handle_init(loop, (uv_handle_t*)handle, UV_##type); \
handle->name##_cb = NULL; \
return 0; \
} \
// ... continue ...
Immediately after the definition, the macro is used as:
UV_LOOP_WATCHER_DEFINE(prepare, PREPARE)
You can easily do the substitution for yourself and find that it's actually defining uv_prepare_init
.
Therefore we can say that the function is part of the library, it isn't deprecated (at least in v1.x
) and you can freely use it for your purposes.
No need to replace it in any way.
Upvotes: 1