now working with libuv v1.31.x
This commit is contained in:
parent
749581309e
commit
ea4b6c84d0
@ -93,7 +93,7 @@ exist a valid `libuv` wrapper in C++. That's all.
|
||||
|
||||
To be able to use `uvw`, users must provide the following system-wide tools:
|
||||
|
||||
* A full-featured compiler that supports at least C++14.
|
||||
* A full-featured compiler that supports at least C++17.
|
||||
* `libuv` (which version depends on the tag of `uvw` in use).
|
||||
|
||||
The requirements below are mandatory to compile the tests and to extract the
|
||||
@ -169,10 +169,7 @@ for the latest version.
|
||||
|
||||
The documentation is mostly inspired by the official
|
||||
[libuv API documentation](http://docs.libuv.org/en/v1.x/) for obvious
|
||||
reasons.<br/>
|
||||
If you are mainly interested in the way `uvw` imports `libuv` in a `cmake` based
|
||||
project, I suggest you to take a look at
|
||||
[this](https://github.com/skypjack/libuv_cmake) repository instead.
|
||||
reasons.
|
||||
|
||||
## Tests
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ ExternalProject_Add(
|
||||
ExternalProject_Add(
|
||||
libuv
|
||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||
GIT_TAG v1.30.1
|
||||
GIT_TAG v1.31.0
|
||||
SOURCE_DIR @LIBUV_DEPS_DIR@
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
|
||||
@ -52,7 +52,8 @@ enum class UVFsType: std::underlying_type_t<uv_fs_type> {
|
||||
LCHOWN = UV_FS_LCHOWN,
|
||||
OPENDIR = UV_FS_OPENDIR,
|
||||
READDIR = UV_FS_READDIR,
|
||||
CLOSEDIR = UV_FS_CLOSEDIR
|
||||
CLOSEDIR = UV_FS_CLOSEDIR,
|
||||
STATFS = UV_FS_STATFS
|
||||
};
|
||||
|
||||
|
||||
@ -76,6 +77,7 @@ enum class UVFileOpenFlags: int {
|
||||
DSYNC = UV_FS_O_DSYNC,
|
||||
EXCL = UV_FS_O_EXCL,
|
||||
EXLOCK = UV_FS_O_EXLOCK,
|
||||
FILEMAP = UV_FS_O_FILEMAP,
|
||||
NOATIME = UV_FS_O_NOATIME,
|
||||
NOCTTY = UV_FS_O_NOCTTY,
|
||||
NOFOLLOW = UV_FS_O_NOFOLLOW,
|
||||
@ -149,6 +151,7 @@ enum class UVSymLinkFlags: int {
|
||||
* * `FsRequest::Type::OPENDIR`
|
||||
* * `FsRequest::Type::READDIR`
|
||||
* * `FsRequest::Type::CLOSEDIR`
|
||||
* * `FsRequest::Type::STATFS`
|
||||
*
|
||||
* It will be emitted by FsReq and/or FileReq according with their
|
||||
* functionalities.
|
||||
@ -268,6 +271,23 @@ struct FsEvent<details::UVFsType::LSTAT> {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief FsEvent event specialization for `FsRequest::Type::STATFS`.
|
||||
*
|
||||
* It will be emitted by FsReq and/or FileReq according with their
|
||||
* functionalities.
|
||||
*/
|
||||
template<>
|
||||
struct FsEvent<details::UVFsType::STATFS> {
|
||||
FsEvent(const char *pathname, Statfs curr) noexcept
|
||||
: path{pathname}, statfs{std::move(curr)}
|
||||
{}
|
||||
|
||||
const char * path; /*!< The path affecting the request. */
|
||||
Statfs statfs; /*!< An initialized instance of Statfs. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief FsEvent event specialization for `FsRequest::Type::SCANDIR`.
|
||||
*
|
||||
@ -352,6 +372,12 @@ protected:
|
||||
else { ptr->publish(FsEvent<e>{req->path, req->statbuf}); }
|
||||
}
|
||||
|
||||
static void fsStatfsCallback(uv_fs_t *req) {
|
||||
auto ptr = Request<T, uv_fs_t>::reserve(req);
|
||||
if(req->result < 0) { ptr->publish(ErrorEvent{req->result}); }
|
||||
else { ptr->publish(FsEvent<Type::STATFS>{req->path, *static_cast<Statfs *>(req->ptr)}); }
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
void cleanupAndInvoke(Args&&... args) {
|
||||
uv_fs_req_cleanup(this->get());
|
||||
@ -461,6 +487,7 @@ public:
|
||||
* * `FileReq::FileOpen::DSYNC`
|
||||
* * `FileReq::FileOpen::EXCL`
|
||||
* * `FileReq::FileOpen::EXLOCK`
|
||||
* * `FileReq::FileOpen::FILEMAP`
|
||||
* * `FileReq::FileOpen::NOATIME`
|
||||
* * `FileReq::FileOpen::NOCTTY`
|
||||
* * `FileReq::FileOpen::NOFOLLOW`
|
||||
@ -500,6 +527,7 @@ public:
|
||||
* * `FileReq::FileOpen::DSYNC`
|
||||
* * `FileReq::FileOpen::EXCL`
|
||||
* * `FileReq::FileOpen::EXLOCK`
|
||||
* * `FileReq::FileOpen::FILEMAP`
|
||||
* * `FileReq::FileOpen::NOATIME`
|
||||
* * `FileReq::FileOpen::NOCTTY`
|
||||
* * `FileReq::FileOpen::NOFOLLOW`
|
||||
@ -1106,6 +1134,39 @@ public:
|
||||
return std::make_pair(!(req->result < 0), req->statbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Async [statfs](http://linux.die.net/man/2/statfs).
|
||||
*
|
||||
* Emit a `FsEvent<FsReq::Type::STATFS>` event when completed.<br/>
|
||||
* Emit an ErrorEvent event in case of errors.
|
||||
*
|
||||
* Any fields in the resulting object that are not supported by the
|
||||
* underlying operating system are set to zero.
|
||||
*
|
||||
* @param path Path, as described in the official documentation.
|
||||
*/
|
||||
void stasfs(std::string path) {
|
||||
cleanupAndInvoke(&uv_fs_statfs, parent(), get(), path.data(), &fsStatfsCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sync [statfs](http://linux.die.net/man/2/statfs).
|
||||
*
|
||||
* Any fields in the resulting object that are not supported by the
|
||||
* underlying operating system are set to zero.
|
||||
*
|
||||
* @param path Path, as described in the official documentation.
|
||||
*
|
||||
* @return A `std::pair` composed as it follows:
|
||||
* * A boolean value that is true in case of success, false otherwise.
|
||||
* * An initialized instance of Statfs.
|
||||
*/
|
||||
std::pair<bool, Statfs> statfsSync(std::string path) {
|
||||
auto req = get();
|
||||
cleanupAndInvokeSync(&uv_fs_statfs, parent(), req, path.data());
|
||||
return std::make_pair(!(req->result < 0), *static_cast<uv_statfs_t *>(req->ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Async [rename](http://linux.die.net/man/2/rename).
|
||||
*
|
||||
|
||||
@ -197,6 +197,7 @@ constexpr FileHandle StdERR{2}; /*!< Placeholder for stderr descriptor. */
|
||||
|
||||
using TimeSpec = uv_timespec_t; /*!< Library equivalent for uv_timespec_t. */
|
||||
using Stat = uv_stat_t; /*!< Library equivalent for uv_stat_t. */
|
||||
using Statfs = uv_statfs_t; /*!< Library equivalent for uv_statfs_t. */
|
||||
using Uid = uv_uid_t; /*!< Library equivalent for uv_uid_t. */
|
||||
using Gid = uv_gid_t; /*!< Library equivalent for uv_gid_t. */
|
||||
|
||||
|
||||
@ -60,7 +60,6 @@ ADD_UVW_TEST(idle uvw/idle.cpp)
|
||||
ADD_UVW_LIB_TEST(lib uvw/lib.cpp)
|
||||
ADD_UVW_TEST(loop uvw/loop.cpp)
|
||||
ADD_UVW_DIR_TEST(pipe uvw/pipe.cpp)
|
||||
ADD_UVW_TEST(poll uvw/poll.cpp)
|
||||
ADD_UVW_TEST(prepare uvw/prepare.cpp)
|
||||
ADD_UVW_TEST(process uvw/process.cpp)
|
||||
ADD_UVW_TEST(request uvw/request.cpp)
|
||||
@ -68,7 +67,6 @@ ADD_UVW_TEST(resource uvw/resource.cpp)
|
||||
ADD_UVW_TEST(signal uvw/signal.cpp)
|
||||
ADD_UVW_TEST(stream uvw/stream.cpp)
|
||||
ADD_UVW_TEST(tcp uvw/tcp.cpp)
|
||||
ADD_UVW_TEST(thread uvw/thread.cpp)
|
||||
ADD_UVW_TEST(timer uvw/timer.cpp)
|
||||
ADD_UVW_TEST(tty uvw/tty.cpp)
|
||||
ADD_UVW_TEST(udp uvw/udp.cpp)
|
||||
|
||||
@ -198,7 +198,6 @@ TEST(FileReq, RWSync) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, Stat) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
@ -228,7 +227,6 @@ TEST(FileReq, Stat) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(FileReq, StatSync) {
|
||||
const std::string filename = std::string{TARGET_FILE_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
|
||||
@ -100,18 +100,6 @@ TEST(FsReq, MkdtempAndRmdirSync) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(FsReq, Scandir) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(FsReq, ScandirSync) {
|
||||
// TODO
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
TEST(FsReq, Stat) {
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
@ -267,16 +255,6 @@ TEST(FsReq, RenameSync) {
|
||||
}
|
||||
|
||||
|
||||
TEST(FsReq, CopyFile) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(FsReq, CopyFileSync) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(FsReq, Access) {
|
||||
const std::string filename = std::string{TARGET_FS_REQ_DIR} + std::string{"/test.file"};
|
||||
|
||||
|
||||
@ -119,13 +119,3 @@ TEST(Pipe, Shutdown) {
|
||||
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(Pipe, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto handle = uvw::PipeHandle::create(loop);
|
||||
|
||||
handle = nullptr;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <uvw.hpp>
|
||||
|
||||
|
||||
TEST(Poll, StartAndStopReadableWritable) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto handle = uvw::PollHandle::create(loop, 0);
|
||||
|
||||
handle = nullptr;
|
||||
|
||||
// TODO
|
||||
}
|
||||
@ -36,13 +36,3 @@ TEST(Process, StdIO) {
|
||||
pipe->close();
|
||||
loop->run();
|
||||
}
|
||||
|
||||
|
||||
TEST(Process, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto handle = uvw::ProcessHandle::create(loop);
|
||||
|
||||
handle = nullptr;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -11,14 +11,3 @@ struct FakeStreamHandle: uvw::StreamHandle<FakeStreamHandle, fake_stream_t> {
|
||||
template<typename... Args>
|
||||
bool init(Args&&...) { return true; }
|
||||
};
|
||||
|
||||
|
||||
TEST(Stream, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto handle = FakeStreamHandle::create(loop);
|
||||
|
||||
handle = nullptr;
|
||||
|
||||
// TODO
|
||||
|
||||
}
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <gtest/gtest.h>
|
||||
#include <uvw.hpp>
|
||||
|
||||
|
||||
TEST(Thread, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Thread>([](std::shared_ptr<void>){});
|
||||
|
||||
resource->run();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(ThreadLocalStorage, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::ThreadLocalStorage>();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(Once, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Once>();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(Mutex, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Mutex>();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(RWLock, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::RWLock>();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(Semaphore, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Semaphore>(1);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(Condition, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Condition>();
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
TEST(Barrier, TODO) {
|
||||
auto loop = uvw::Loop::getDefault();
|
||||
auto resource = loop->resource<uvw::Barrier>(1);
|
||||
|
||||
// TODO
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user