Closed hannesa2 closed 9 years ago
Hi hannesa2,
No operations do not run in parallel by design, however if you need to do something in parallel you can always create a second operation service.
Thank you for your fast response ! I've to clarify : "No operations do not run in parallel .. " means "Every operation do run parallel .." , yes ?
operation search(double lat, double lon, int radius) unique (radius)
will run parallel by design ?
Ops.execute(SearchOperation.newIntent(lat, lon, 10);
Ops.execute(SearchOperation.newIntent(lat, lon, 1000);
if not, it's an issue on my side ?
Hi Sorry Hannesa,
I meant operations do not run in parallel (by design to avoid race conditions in chatty applications).
If you want to run ops in parallel, create another operation service.
I think about to make it parallel, but for this I've to understand how it works by design. Several services are a way, but I need a kind of 'load balancer' for it.
When I execute this operation at the same time
operation search(int radius) unique (radius)
with different runtime behavior, say more radius has a longer runtime
Ops.execute(SearchOperation.newIntent(10000); //no1
Ops.execute(SearchOperation.newIntent(10); //no2
Ops.execute(SearchOperation.newIntent(11); //no3
Ops.execute(SearchOperation.newIntent(10); //no4
Ops.execute(SearchOperation.newIntent(10); //no5
Ops.execute(SearchOperation.newIntent(10000); //no6
Ops.execute(SearchOperation.newIntent(10); //no7
how are they executed, in which order ? Which one will be skipped ? As I understand
am I right ?
What do you suggest to make all parallel, as I see dynamic Service count doesn't work because of entry in AndroidManifest.xml Make onExecute in an own thread, with an callback for finish, is a good idea ?
Hi,
Effectively, under the hood, a Mechanoid OperaitonService delegates responsibility of operation execution to the OperationProcessor
The Processor receives operation requests and puts them into a cue and they are executed First In First Out (FIFO).
When an operation is executing, and then finishes, it then takes the next operation from the queue and executes it, and continues with this pattern until no operations are left, once all operations are executed the service attempts to shut itself down.
So far this pattern has worked well for all our operations, and we have not needed parallelisation.
Operation uniqueness means that, if an operation is unique, and a currently running (or operation waiting in the queue) then the operation will not be added to the queue and the operation will return the ID of the existing operation it matches in the queue.
You can disable this uniqueness with the 'not unique' constraint so all operations you add will be put into the queue.
operation search(int radius) not unique
thanks for the explanation
Hi, does the operation-service runs in UI-thread ?
No, that would be bad :)
You can take a look at the code that executes the operations,
With a bit of work, it could be possible to introduce an option to parallize operations, but thats not on the roadmap currently.
In my Activity, I start an operation (with Net-REST call) at the same time
twice, a short running and a long running. With this, I've two issues:
Therefore I've a general question: Does Mechanoid-Operations have the ability to run parallel at the background with included REST-calls ?