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)
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.
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With