Comments (6)
It may be better to store the thread id for hpx_main as a non-reference counting id (i.e., threads_id_type
) in this case.
from hpxc.
Thank you, @Pansysk75. If I remember correctly, the issue was in hpxc_setspecific, where the thandle would be null for hpx_main
, and what you're referring to was supposed to be the workaround.
from hpxc.
@hkaiser I was looking at a fix using hpx::threads::add_thread_exit_callback()
to add a callback function to hpx_main. The callback doesn't seem to get called, even though hpx_main terminates :((
Should that work in theory, or am I not supposed to use it like that?
thread_handle(hpx::threads::thread_id_ref_type id)
:
. . .
{
auto on_completion = [thandle = this]() {
std::cout << "This print is not printing" << std::endl;
// Signal completion
thandle->promise.set_value(nullptr);
int r = --thandle->refc;
if (r == 0)
{
delete thandle;
}
};
if (!hpx::threads::add_thread_exit_callback(id.noref(), on_completion)) <--------
{
// Failed to add callback because the hpx thread has terminated
// This throw does not happen
throw;
}
}
The rationale of doing this, is to retain the ability to have hpxc-thread-data even for threads not launched through the hpxc API, and have that data be deleted when the thread finished (just like we do for the other threads spawned with hpxc_thread_create)
from hpxc.
@Pansysk75 now I'm confused. I thought the whole problem was that hpx_main was not terminating, in which case it would be logical for the callback to never be called...
from hpxc.
@Pansysk75 now I'm confused. I thought the whole problem was that hpx_main was not terminating, in which case it would be logical for the callback to never be called...
Ah, it's terminating, holding the reference just keeps it from getting deleted after termination
from hpxc.
@Pansysk75 now I'm confused. I thought the whole problem was that hpx_main was not terminating, in which case it would be logical for the callback to never be called...
Ah, it's terminating, holding the reference just keeps it from getting deleted after termination
Well, in this case the callback should be invoked (see: https://github.com/STEllAR-GROUP/hpx/blob/e7c31a49dd4e550a61134e498f3ecfb585d201cb/libs/core/threading_base/include/hpx/threading_base/register_thread.hpp#L72)
from hpxc.
Related Issues (8)
- HPXC executables should be linked without the hpx_init library
- Thread exit functions are not being called (presumably because of hpxc_thread_exit). HOT 2
- HPXC examples don't execute
- hpxc_thread_t isn't an integer HOT 2
- pthread_compatibility.h is missing hpxc_thread_self() HOT 1
- no pthread_cond_timedwait() HOT 4
- Installation does not move libraries HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hpxc.