Page 1 of 1

Do requires in threads get cached? Are they cached separately from the main thread?

Posted: Tue Sep 12, 2017 3:04 am
by Guard13007
What the title says.

Do threads cache require'd modules?

And if they do, is this the same cache as the main thread? Or do threads get their own cache?

Re: Do requires in threads get cached? Are they cached separately from the main thread?

Posted: Tue Sep 12, 2017 3:41 am
by zorg
Threads (real ones with love.thread, not coroutines) have their own Lua states;
They don't "share" anything on the lua side, which includes modules required (including löve's ones like love.timer; love.thread is the only one that gets loaded automatically... although love.filesystem gets loaded too since either 0.9 or 0.10)

Also, all of this is on the wiki: love.thread

Re: Do requires in threads get cached? Are they cached separately from the main thread?

Posted: Tue Sep 12, 2017 7:13 am
by Guard13007
I don't believe that answers my question. I am aware that Love modules must be loaded and that they are their own states, but they also allows flat tables and userdata to be shared. I am wondering if that sharing applies to cached modules (although based on having to require love's modules and it being a separate state, I'm guessing no). And I'm guessing now that this means they /do/ cache require'd modules in their own thread only.

Edit: Sorry if I sounded rude. I'm half awake and trying to just make sure I understand it properly. >.<

Re: Do requires in threads get cached? Are they cached separately from the main thread?

Posted: Tue Sep 12, 2017 7:35 am
by bartbes
No, even data sent over channels isn't shared unless they're love objects. The tables are copied over, and, of course, you can't send functions to begin with.