Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concurrency in Elm

I have a really computationally expensive code that I need to run in my 'update' function.

When it runs, my whole app blocks until it finishes.

Is there any way to run this code asynchronously to prevent the blocking? (while not using ports and staying in elm)

like image 496
doodledood Avatar asked Aug 19 '16 10:08

doodledood


People also ask

What is concurrency control in EF Core?

Concurrency control refers to specific mechanisms used to ensure data consistency in presence of concurrent changes. EF Core implements optimistic concurrency control, meaning that it will let multiple processes or users make changes independently without the overhead of synchronization or locking.

What is concurrency in OS?

Concurrency is the execution of the multiple instruction sequences at the same time. It happens in the operating system when there are several process threads running in parallel. The running process threads always communicate with each other through shared memory or message passing.

What is optimistic concurrency in efef core?

EF Core implements optimistic concurrency control, meaning that it will let multiple processes or users make changes independently without the overhead of synchronization or locking. In the ideal situation, these changes will not interfere with each other and therefore will be able to succeed.

What is optimistic concurrency control?

The situations in which multiple processes or users access or change the same data in a database at the same time. To implement optimistic concurrency control, you need to configure properties as concurrency tokens.


1 Answers

Elm tasks do not support pre-emptive multi-tasking.

With Process.spawn, you can construct tasks which will context-switch when used as arguments to Task.andThen.

However, for those, you have to work within the constraint that the resulting task has type Task x Process.Id, which means there is no easy way to communicate the result of your task back to the main app.

See the documentation for Process.Id.

like image 52
Søren Debois Avatar answered Oct 13 '22 21:10

Søren Debois