On 24.07.2018 17:43, Henry Rich wrote:
To amplify what Eric said:
Two threads cannot have access to the same J namespaces. There are currently
no locking mechanisms to allow two tasks to modify the same tables. Nor does
the memory allocator work if one thread allocates a block and another thread
frees it.
Ok. You're right.
More clever and simple is creating processes. Which work with memory by
Copy-On-Write model (in Linux).
No problems with intersection memory regions.
You could share data between the threads using mapped files, or communicate
between them with sockets.
It might be interesting to have the notion of a shared locale. Names within a
shared locale could be accessed by multiple threads.
Beatiful idea.
It might also be interesting to have facilities for putting threads to sleep
and waking them up. We don't have any plans for features like these, because
we have never had a concrete proposal for how to use them.
Example:
slow_function =: 3 : 0
...
)
Use_processes =: adverb : 0
...
)
Array_of_N_result =: slow_function Use_processes
array_of_args_for_slow_functions
After execution all processes is destroyed with all changed variables.
By default using of max cpu cores. May be need add parameter for limiting cores.
Or using new verb like power ^: for this purpose:
x (verb multiple_process N) y,
where N - is concrete count of cpu cores.
Sergey.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm