now working with libuv v1.34.x

This commit is contained in:
Michele Caini 2019-12-04 23:05:47 +01:00
parent 8f868995fc
commit ed766f709a
5 changed files with 79 additions and 6 deletions

View File

@ -16,7 +16,7 @@ endif()
# Project configuration
#
project(uvw VERSION 2.2.0)
project(uvw VERSION 2.3.0)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)

View File

@ -17,7 +17,7 @@ ExternalProject_Add(
ExternalProject_Add(
libuv
GIT_REPOSITORY https://github.com/libuv/libuv.git
GIT_TAG v1.33.0
GIT_TAG v1.34.0
SOURCE_DIR @LIBUV_DEPS_DIR@
CONFIGURE_COMMAND ""
BUILD_COMMAND ""

View File

@ -14,7 +14,7 @@ class UVMConan(ConanFile):
exports = "LICENSE"
exports_sources = "src/*"
no_copy_source = True
requires = "libuv/1.32.0@bincrafters/stable"
requires = "libuv/1.34.0@bincrafters/stable"
def package(self):
self.copy(pattern="LICENSE", dst="licenses")

View File

@ -53,7 +53,8 @@ enum class UVFsType: std::underlying_type_t<uv_fs_type> {
OPENDIR = UV_FS_OPENDIR,
READDIR = UV_FS_READDIR,
CLOSEDIR = UV_FS_CLOSEDIR,
STATFS = UV_FS_STATFS
STATFS = UV_FS_STATFS,
MKSTEMP = UV_FS_MKSTEMP
};
@ -152,6 +153,7 @@ enum class UVSymLinkFlags: int {
* * `FsRequest::Type::READDIR`
* * `FsRequest::Type::CLOSEDIR`
* * `FsRequest::Type::STATFS`
* * `FsRequest::Type::MKSTEMP`
*
* It will be emitted by FsReq and/or FileReq according with their
* functionalities.
@ -288,6 +290,23 @@ struct FsEvent<details::UVFsType::STATFS> {
};
/**
* @brief FsEvent event specialization for `FsRequest::Type::MKSTEMP`.
*
* It will be emitted by FsReq and/or FileReq according with their
* functionalities.
*/
template<>
struct FsEvent<details::UVFsType::MKSTEMP> {
FsEvent(const char *pathname, std::size_t desc) noexcept
: path{pathname}, descriptor{desc}
{}
const char * path; /*!< The created file path. */
std::size_t descriptor; /*!< The file descriptor as an integer. */
};
/**
* @brief FsEvent event specialization for `FsRequest::Type::SCANDIR`.
*
@ -974,7 +993,7 @@ public:
*
* @return A `std::pair` composed as it follows:
* * A boolean value that is true in case of success, false otherwise.
* * The actual path of the newly created directoy.
* * The actual path of the newly created directory.
*/
std::pair<bool, const char *> mkdtempSync(std::string tpl) {
auto req = get();
@ -982,6 +1001,52 @@ public:
return std::make_pair(!(req->result < 0), req->path);
}
/**
* @brief Async [mkstemp](https://linux.die.net/man/3/mkstemp).
*
* Emit a `FsEvent<FsReq::Type::MKSTEMP>` event when completed.<br/>
* Emit an ErrorEvent event in case of errors.
*
* @param tpl Template, as described in the official documentation.
*/
void mkstemp(std::string tpl) {
cleanupAndInvoke(&uv_fs_mkstemp, parent(), get(), tpl.data(), &fsResultCallback<Type::MKSTEMP>);
}
/**
* @brief Sync [mkstemp](https://linux.die.net/man/3/mkstemp).
*
* Returns a composed value where:
*
* * The first parameter indicates the created file path.
* * The second parameter is the file descriptor as an integer.
*
* See the official
* [documentation](http://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_mkstemp)
* for further details.
*
* @param tpl Template, as described in the official documentation.
*
* @return A pair where:
* * The first parameter is a boolean value that is true in case of success,
* false otherwise.
* * The second parameter is a composed value (see above).
*/
std::pair<bool, std::pair<std::string, std::size_t>> mkstempSync(std::string tpl) {
std::pair<bool, std::pair<std::string, std::size_t>> ret{false, {}};
auto req = get();
cleanupAndInvokeSync(&uv_fs_mkdtemp, parent(), req, tpl.data());
ret.first = !(req->result < 0);
if(ret.first) {
ret.second.first = req->path;
ret.second.second = static_cast<std::size_t>(req->result);
}
return ret;
}
/**
* @brief Async [rmdir](http://linux.die.net/man/2/rmdir).
*

View File

@ -1004,11 +1004,19 @@ struct Utilities {
* [`gettimeofday`](https://linux.die.net/man/2/gettimeofday)
* @return The current time.
*/
static TimeVal64 timeOfDay() {
static TimeVal64 timeOfDay() noexcept {
uv_timeval64_t ret;
uv_gettimeofday(&ret);
return ret;
}
/**
* @brief Causes the calling thread to sleep for a while.
* @param msec Number of milliseconds to sleep.
*/
static void sleep(unsigned int msec) noexcept {
uv_sleep(msec);
}
};