Blockland Forums > Modification Help

blocklandjs

Pages: << < (3/7) > >>

Metario:


--- Quote from: PhantOS on February 21, 2018, 11:51:06 AM ---Kyunde make asynchronous brick loading/saving (It might already be but I never bothered to research whether it's single thread)

--- End quote ---
it's not asynch seeing as it's using torkscript
you could do this alot faster with bljs's libuv implementation as it provides an asynchronous file writing/reading part: see http://blocklandjs.readthedocs.io/en/latest/JavaScript/libuv/fs.html#uv.fs.read

it'll spawn a new thread so the game and the engine will not be stuck on writing the file out

mctwist:

I would recommend that you create a threadpool which keep the threads alive and then send the action to the pool which puts it into a thread. This makes it possible to stack work without having way too many threads launched. Also keep in mind to copy over all data that is used in current thread to make sure it is not altered. This means that it will slow the process a bit if the data is huge(Mentioned below).

Also, as you say that reading is asynchronous, but how would writing work? Saving parts of a file? Saving the whole file as one big string?

Metario:


--- Quote from: mctwist on February 21, 2018, 01:26:54 PM ---I would recommend that you create a threadpool which keep the threads alive and then send the action to the pool which puts it into a thread. This makes it possible to stack work without having way too many threads launched. Also keep in mind to copy over all data that is used in current thread to make sure it is not altered. This means that it will slow the process a bit if the data is huge(Mentioned below).

Also, as you say that reading is asynchronous, but how would writing work? Saving parts of a file? Saving the whole file as one big string?

--- End quote ---
http://docs.libuv.org/en/v1.x/threadpool.html
libuv already does this internally- no need to worry about it.

Writing can be done sequentially, or as a one-shot method. The offset method can be used to write onto the end of files (or just using the append flag)

Kyuande:

Imagine remaking the event system using bljs, would make stuff much faster

PhantOS:

You'd probably be able to raise the too many events quota extremely high

Pages: << < (3/7) > >>

Go to full version