missionary

Eric Dvorsak 2025-01-22T12:51:43.614459Z

https://github.com/leonoel/missionary/issues/127#issuecomment-2607165823 @leonoel when running a task with (task success-fn error-fn) does it run on a thread from m/blk?

leonoel 2025-01-22T13:08:44.279149Z

a task generally doesn't run on a single thread and doesn't use the m/blk executor unless being told so

Eric Dvorsak 2025-01-22T13:11:10.525419Z

but since this form of invoking a task is not blocking the thread where I use it, I assume it runs on a separate thread?

leonoel 2025-01-22T13:11:33.206169Z

it depends how it's defined

leonoel 2025-01-22T13:11:54.723559Z

most likely yes, unless it's a very trivial task

leonoel 2025-01-22T13:14:50.363709Z

But the issue you linked can happen on any thread, the problem is the dynamically scoped context of m/sp. The reason why your hack works is because switching thread restores the dynamic scope

leonoel 2025-01-22T13:21:11.131479Z

the correct fix is to identify calls containing nested m/?, wrap them in m/via and sequence them in a m/sp

Eric Dvorsak 2025-01-22T13:22:31.610129Z

is it something that has to be done manually or it can be done by missionary?

Eric Dvorsak 2025-01-22T13:25:00.494759Z

in the meantime does it mean that I should "bubble up"? turn functions into task all the way to the final invokation?

leonoel 2025-01-22T13:25:18.905999Z

it cannot be done by missionary, we would need stackful coroutines for that

leonoel 2025-01-22T13:26:14.711569Z

yes, use task composition as much as you can

leonoel 2025-01-22T13:29:36.568459Z

after a task has been turned to a blocking call there's no way to get it back

Eric Dvorsak 2025-01-22T13:58:43.878049Z

m/? in an m/sp is still task composition right? it's only free m/? that would do that?

leonoel 2025-01-22T14:01:27.576119Z

yes, the m/? has to be visible to the macro so it can be rewritten as an asynchronous operation

Eric Dvorsak 2025-01-22T14:06:59.463069Z

ok thanks I understand better now