Clemapfel / jluna

Julia Wrapper for C++ with Focus on Safety, Elegance, and Ease of Use
https://clemens-cords.com/jluna
MIT License
239 stars 12 forks source link

Linker error when casting Task to unsafe::Value* #30

Closed paulerikf closed 1 year ago

paulerikf commented 1 year ago

Noticed that this example from the docs on interacting with julia-side Tasks fails to compile:

// declare lambda
auto lambda = [](){ //...

// create task
auto task = ThreadPool::create<void>(lambda);

// create proxy to task
auto task_proxy = Proxy(static_cast<unsafe::Value*>(task));

// all Julia-only attributes can now be accessed:
std::cout << (bool) task_proxy["sticky"] << std::endl;

make install output:

/usr/bin/ld: CMakeFiles/jluna_test.dir/.test/main.cpp.o: in function `main::$_90::operator()() const':
main.cpp:(.text+0x2a20a): undefined reference to `jluna::Task<unsigned long>::operator _jl_value_t*()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

operator unsafe::Value*() is declared in both Task<T> & Task<void>, but not implemented.

paulerikf commented 1 year ago

Side note: The note about the "sticky" property confused me a bit...

From the docs:

Julia Hint: Threads.Tasks.sticky is a property that governs whether a task can be executed concurrently. By default, sticky is set to false, making it “stick” to the main thread, instead of “detaching” and being run on its own.

I'm assuming false actually makes it "detach", instead of "sticking" to the main thread? I probably don't want to be changing that to true then, right?