You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by "pnoltes (via GitHub)" <gi...@apache.org> on 2026/01/18 21:51:22 UTC
[PR] Feature/769 libuv package and thread header (celix)
pnoltes opened a new pull request, #815:
URL: https://github.com/apache/celix/pull/815
This PR adds the libuv dependency and creates initial celix_uv_cleanup.h and tests.
Follow up PRs will replace celix_threads.h usage with libuv variants.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724880168
##########
libs/utils/include/celix_uv_cleanup.h:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef CELIX_UV_CLEANUP_H
+#define CELIX_UV_CLEANUP_H
+
+#include <uv.h>
+
+#include "celix_cleanup.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CELIX_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(uv_thread_t, uv_thread_join)
Review Comment:
I'm not sure whether this one makes sense, since it can only be used with joinable thread and detached threads are used a lot in my day job.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2702753158
##########
libs/utils/gtest/src/UvThreadsTestSuite.cc:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "celix_uv_cleanup.h"
+
+#include <atomic>
+#include <gtest/gtest.h>
+
+class UvThreadsTestSuite : public ::testing::Test {
+};
+
+static void uvThreadIncrement(void* data) {
+ auto* counter = static_cast<std::atomic<int>*>(data);
+ counter->fetch_add(1);
+}
+
+TEST_F(UvThreadsTestSuite, ThreadAutoCleanupTest) {
+ std::atomic<int> counter{0};
+ {
+ celix_auto(uv_thread_t) thread;
+ ASSERT_EQ(0, uv_thread_create(&thread, uvThreadIncrement, &counter));
+ } //thread out of scope -> join
+ EXPECT_EQ(1, counter.load());
+}
+
+TEST_F(UvThreadsTestSuite, MutexGuardTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+
+ {
+ celix_auto(celix_uv_mutex_lock_guard_t) guard = celixUvMutexLockGuard_init(&mutex);
+ EXPECT_NE(0, uv_mutex_trylock(&mutex));
+ } //guard out of scope -> unlock
+
+ ASSERT_EQ(0, uv_mutex_trylock(&mutex));
+ uv_mutex_unlock(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, MutexStealTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+ celix_steal_ptr(mutexCleanup);
+ uv_mutex_destroy(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, RwlockGuardTest) {
+ uv_rwlock_t lock;
+ ASSERT_EQ(0, uv_rwlock_init(&lock));
+ celix_autoptr(uv_rwlock_t) lockCleanup = &lock;
+
+#ifndef __APPLE__ //On MacOs uv_rwlock_tryrdlock and uv_rwlock_trywrlock on write locked lock results in SIGABRT
Review Comment:
I am not sure why this is needed, maybe I made a mistake but as far as I can see this is maybe a upstream bug.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2703117186
##########
libs/utils/gtest/src/UvThreadsTestSuite.cc:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "celix_uv_cleanup.h"
+
+#include <atomic>
+#include <gtest/gtest.h>
+
+class UvThreadsTestSuite : public ::testing::Test {
+};
+
+static void uvThreadIncrement(void* data) {
+ auto* counter = static_cast<std::atomic<int>*>(data);
+ counter->fetch_add(1);
+}
+
+TEST_F(UvThreadsTestSuite, ThreadAutoCleanupTest) {
+ std::atomic<int> counter{0};
+ {
+ celix_auto(uv_thread_t) thread;
+ ASSERT_EQ(0, uv_thread_create(&thread, uvThreadIncrement, &counter));
+ } //thread out of scope -> join
+ EXPECT_EQ(1, counter.load());
+}
+
+TEST_F(UvThreadsTestSuite, MutexGuardTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+
+ {
+ celix_auto(celix_uv_mutex_lock_guard_t) guard = celixUvMutexLockGuard_init(&mutex);
+ EXPECT_NE(0, uv_mutex_trylock(&mutex));
+ } //guard out of scope -> unlock
+
+ ASSERT_EQ(0, uv_mutex_trylock(&mutex));
+ uv_mutex_unlock(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, MutexStealTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+ celix_steal_ptr(mutexCleanup);
+ uv_mutex_destroy(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, RwlockGuardTest) {
+ uv_rwlock_t lock;
+ ASSERT_EQ(0, uv_rwlock_init(&lock));
+ celix_autoptr(uv_rwlock_t) lockCleanup = &lock;
+
+#ifndef __APPLE__ //On MacOs uv_rwlock_tryrdlock and uv_rwlock_trywrlock on write locked lock results in SIGABRT
Review Comment:
```C
int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock) {
int err;
err = pthread_rwlock_tryrdlock(rwlock);
if (err) {
if (err != EBUSY && err != EAGAIN)
abort();
return UV_EBUSY;
}
return 0;
}
```
According to `man pthread_rwlock_rdlock`:
```
The pthread_rwlock_rdlock() function may fail if:
EDEADLK
A deadlock condition was detected or the current thread already owns the read-write lock for writing.
These functions shall not return an error code of [EINTR].
The following sections are informative.
```
How about trying lock in another thread?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2730498059
##########
libs/utils/CMakeLists.txt:
##########
@@ -18,7 +18,13 @@
celix_subproject(UTILS "Option to enable building the Utilities library" ON)
if (UTILS)
find_package(libzip REQUIRED)
- find_package(jansson REQUIRED) #TODO add jansson dep info to build (conan) and documentation info
+ find_package(jansson REQUIRED)
+ find_package(libuv REQUIRED)
+
+ if (NOT TARGET libuv::uv AND TARGET uv)
+ #Note: conan libuv package 1.49.2 defines uv target, but 1.51.0 defines libuv::uv target
Review Comment:
Running conan1 gives the following notice:
```
WARN: **************************************************
WARN: *** Conan 1 is legacy and on a deprecation path **
WARN: *********** Please upgrade to Conan 2 ************
WARN: **************************************************
```
I think it's time to get rid of Conan 1.x.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724881748
##########
libs/utils/CMakeLists.txt:
##########
@@ -18,7 +18,13 @@
celix_subproject(UTILS "Option to enable building the Utilities library" ON)
if (UTILS)
find_package(libzip REQUIRED)
- find_package(jansson REQUIRED) #TODO add jansson dep info to build (conan) and documentation info
+ find_package(jansson REQUIRED)
+ find_package(libuv REQUIRED)
+
+ if (NOT TARGET libuv::uv AND TARGET uv)
+ #Note: conan libuv package 1.49.2 defines uv target, but 1.51.0 defines libuv::uv target
Review Comment:
Using latest conan 1.x is OK, thus this hack can be removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2705865775
##########
libs/utils/gtest/src/UvThreadsTestSuite.cc:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "celix_uv_cleanup.h"
+
+#include <atomic>
+#include <gtest/gtest.h>
+
+class UvThreadsTestSuite : public ::testing::Test {
+};
+
+static void uvThreadIncrement(void* data) {
+ auto* counter = static_cast<std::atomic<int>*>(data);
+ counter->fetch_add(1);
+}
+
+TEST_F(UvThreadsTestSuite, ThreadAutoCleanupTest) {
+ std::atomic<int> counter{0};
+ {
+ celix_auto(uv_thread_t) thread;
+ ASSERT_EQ(0, uv_thread_create(&thread, uvThreadIncrement, &counter));
+ } //thread out of scope -> join
+ EXPECT_EQ(1, counter.load());
+}
+
+TEST_F(UvThreadsTestSuite, MutexGuardTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+
+ {
+ celix_auto(celix_uv_mutex_lock_guard_t) guard = celixUvMutexLockGuard_init(&mutex);
+ EXPECT_NE(0, uv_mutex_trylock(&mutex));
+ } //guard out of scope -> unlock
+
+ ASSERT_EQ(0, uv_mutex_trylock(&mutex));
+ uv_mutex_unlock(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, MutexStealTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+ celix_steal_ptr(mutexCleanup);
+ uv_mutex_destroy(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, RwlockGuardTest) {
+ uv_rwlock_t lock;
+ ASSERT_EQ(0, uv_rwlock_init(&lock));
+ celix_autoptr(uv_rwlock_t) lockCleanup = &lock;
+
+#ifndef __APPLE__ //On MacOs uv_rwlock_tryrdlock and uv_rwlock_trywrlock on write locked lock results in SIGABRT
Review Comment:
Thanks for the info, that indeed help. Good insight to look at the pthread documentation 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724892855
##########
cmake/Modules/Findlibuv.cmake:
##########
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# - Try to find libuv
+# Once done this will define
+# libuv_FOUND - System has libuv
+# LIBUV_INCLUDE_DIR - The libuv include directory
+# LIBUV_LIBRARY - The libuv library
+# uv - Imported target for libuv
+
+find_package(libuv CONFIG QUIET)
+
+if (NOT libuv_FOUND)
+ find_package(PkgConfig QUIET)
+ if (PkgConfig_FOUND)
+ pkg_check_modules(LIBUV QUIET libuv)
+ endif ()
+endif ()
+
+if (NOT libuv_FOUND)
+ find_path(LIBUV_INCLUDE_DIR
+ NAMES uv.h
+ HINTS ${LIBUV_INCLUDEDIR} ${LIBUV_INCLUDE_DIRS}
+ )
+
+ find_library(LIBUV_LIBRARY
+ NAMES uv libuv
+ HINTS ${LIBUV_LIBDIR} ${LIBUV_LIBRARY_DIRS}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(libuv DEFAULT_MSG LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
+ mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
+endif ()
+
Review Comment:
Shall we move line https://github.com/apache/celix/blob/fc022b3929314951b0ff100a64a30db97ddd415f/cmake/CelixConfig.cmake#L46 before https://github.com/apache/celix/blob/fc022b3929314951b0ff100a64a30db97ddd415f/cmake/CelixConfig.cmake#L42-L43? So that these targets will be available to export targets?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724886444
##########
cmake/Modules/Findlibuv.cmake:
##########
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# - Try to find libuv
+# Once done this will define
+# libuv_FOUND - System has libuv
+# LIBUV_INCLUDE_DIR - The libuv include directory
+# LIBUV_LIBRARY - The libuv library
+# uv - Imported target for libuv
+
Review Comment:
`cmake/CelixDeps.cmake.in` should also be updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on PR #815:
URL: https://github.com/apache/celix/pull/815#issuecomment-3789263728
I will finish reviewing this weekend.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "pnoltes (via GitHub)" <gi...@apache.org>.
pnoltes merged PR #815:
URL: https://github.com/apache/celix/pull/815
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724892855
##########
cmake/Modules/Findlibuv.cmake:
##########
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# - Try to find libuv
+# Once done this will define
+# libuv_FOUND - System has libuv
+# LIBUV_INCLUDE_DIR - The libuv include directory
+# LIBUV_LIBRARY - The libuv library
+# uv - Imported target for libuv
+
+find_package(libuv CONFIG QUIET)
+
+if (NOT libuv_FOUND)
+ find_package(PkgConfig QUIET)
+ if (PkgConfig_FOUND)
+ pkg_check_modules(LIBUV QUIET libuv)
+ endif ()
+endif ()
+
+if (NOT libuv_FOUND)
+ find_path(LIBUV_INCLUDE_DIR
+ NAMES uv.h
+ HINTS ${LIBUV_INCLUDEDIR} ${LIBUV_INCLUDE_DIRS}
+ )
+
+ find_library(LIBUV_LIBRARY
+ NAMES uv libuv
+ HINTS ${LIBUV_LIBDIR} ${LIBUV_LIBRARY_DIRS}
+ )
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(libuv DEFAULT_MSG LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
+ mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
+endif ()
+
Review Comment:
Shall we move line https://github.com/apache/celix/blob/fc022b3929314951b0ff100a64a30db97ddd415f/cmake/CelixConfig.cmake#L46 before https://github.com/apache/celix/blob/fc022b3929314951b0ff100a64a30db97ddd415f/cmake/CelixConfig.cmake#L39? So that these targets will be available to export targets?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724881748
##########
libs/utils/CMakeLists.txt:
##########
@@ -18,7 +18,13 @@
celix_subproject(UTILS "Option to enable building the Utilities library" ON)
if (UTILS)
find_package(libzip REQUIRED)
- find_package(jansson REQUIRED) #TODO add jansson dep info to build (conan) and documentation info
+ find_package(jansson REQUIRED)
+ find_package(libuv REQUIRED)
+
+ if (NOT TARGET libuv::uv AND TARGET uv)
+ #Note: conan libuv package 1.49.2 defines uv target, but 1.51.0 defines libuv::uv target
Review Comment:
Using latest conan 1.x is OK, thus this hack can be removed.
Let update our conan 1.x all to the latest.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2724880168
##########
libs/utils/include/celix_uv_cleanup.h:
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef CELIX_UV_CLEANUP_H
+#define CELIX_UV_CLEANUP_H
+
+#include <uv.h>
+
+#include "celix_cleanup.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+CELIX_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(uv_thread_t, uv_thread_join)
Review Comment:
I'm not sure whether this one makes sense, since detached threads are used a lot in my day job.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #815:
URL: https://github.com/apache/celix/pull/815#issuecomment-3765793895
## [Codecov](https://app.codecov.io/gh/apache/celix/pull/815?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 91.45%. Comparing base ([`6eca661`](https://app.codecov.io/gh/apache/celix/commit/6eca6616cfbf44c6b426bf23af6bf4e59f35ae20?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`feb9d8e`](https://app.codecov.io/gh/apache/celix/commit/feb9d8ec82c0584df97799bf225604a5d07ce74f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #815 +/- ##
==========================================
+ Coverage 91.43% 91.45% +0.02%
==========================================
Files 234 235 +1
Lines 28655 28687 +32
==========================================
+ Hits 26200 26236 +36
+ Misses 2455 2451 -4
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/celix/pull/815?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Feature/769 libuv package and thread header (celix)
Posted by "PengZheng (via GitHub)" <gi...@apache.org>.
PengZheng commented on code in PR #815:
URL: https://github.com/apache/celix/pull/815#discussion_r2703117186
##########
libs/utils/gtest/src/UvThreadsTestSuite.cc:
##########
@@ -0,0 +1,122 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "celix_uv_cleanup.h"
+
+#include <atomic>
+#include <gtest/gtest.h>
+
+class UvThreadsTestSuite : public ::testing::Test {
+};
+
+static void uvThreadIncrement(void* data) {
+ auto* counter = static_cast<std::atomic<int>*>(data);
+ counter->fetch_add(1);
+}
+
+TEST_F(UvThreadsTestSuite, ThreadAutoCleanupTest) {
+ std::atomic<int> counter{0};
+ {
+ celix_auto(uv_thread_t) thread;
+ ASSERT_EQ(0, uv_thread_create(&thread, uvThreadIncrement, &counter));
+ } //thread out of scope -> join
+ EXPECT_EQ(1, counter.load());
+}
+
+TEST_F(UvThreadsTestSuite, MutexGuardTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+
+ {
+ celix_auto(celix_uv_mutex_lock_guard_t) guard = celixUvMutexLockGuard_init(&mutex);
+ EXPECT_NE(0, uv_mutex_trylock(&mutex));
+ } //guard out of scope -> unlock
+
+ ASSERT_EQ(0, uv_mutex_trylock(&mutex));
+ uv_mutex_unlock(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, MutexStealTest) {
+ uv_mutex_t mutex;
+ ASSERT_EQ(0, uv_mutex_init(&mutex));
+ celix_autoptr(uv_mutex_t) mutexCleanup = &mutex;
+ celix_steal_ptr(mutexCleanup);
+ uv_mutex_destroy(&mutex);
+}
+
+TEST_F(UvThreadsTestSuite, RwlockGuardTest) {
+ uv_rwlock_t lock;
+ ASSERT_EQ(0, uv_rwlock_init(&lock));
+ celix_autoptr(uv_rwlock_t) lockCleanup = &lock;
+
+#ifndef __APPLE__ //On MacOs uv_rwlock_tryrdlock and uv_rwlock_trywrlock on write locked lock results in SIGABRT
Review Comment:
I'll have a look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@celix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org