"Thread safe" task

Post comments and suggestions for RoboTask here
Post Reply
Vara04
Posts: 54
Joined: Fri Feb 24, 2012 8:02 pm
Location: France

"Thread safe" task

Post by Vara04 »

It would be interesting tasks initiated from another task (with Start Task) runs in its
context and independently.
This is to have no deadlocks between tasks.

Example of use:
I do a common task that makes a series of operations with parameters.
I called this task in various other tasks that I do not control the trigger.
Currently, if two tasks require the common task of the two tasks lock.

So ideally, it should be that each can perform the common task of its own.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

"Thread safe" task

Post by Oleg »

You can get deadlock effect when tasks waits each other infinite.
Suppose Task1 starts Task2 with waiting and Task2 starts Task1 with waiting.
Task1 waits Task2, and Task2 waits Task1. This is deadlock.

Your example:
Task1 starts CommonTask
Task2 starts CommonTask

If you want to guarantee that CommonTask will performed for each caller you should start CommoTask so:
Wait CommonTask
Start CommonTask with waiting

Wait For task waits until the task finished.
If CommonTask is not running then Wait For task will not wait.
In this case CommonTask will performed for each caller.

I can send you small examples if it's necessary
Denli
Posts: 2
Joined: Tue Mar 31, 2015 10:59 pm

Re: "Thread safe" task

Post by Denli »

Oleg wrote: I can send you small examples if it's necessary
example please
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: "Thread safe" task

Post by Oleg »

Import these 3 tasks, please:
WaitForTaskExample.zip
(1.97 KiB) Downloaded 2520 times
Oleg Yershov
Denli
Posts: 2
Joined: Tue Mar 31, 2015 10:59 pm

Re: "Thread safe" task

Post by Denli »

Example helped me :D Thank you so much!
Vara04
Posts: 54
Joined: Fri Feb 24, 2012 8:02 pm
Location: France

Re: "Thread safe" task

Post by Vara04 »

Yes but :
- if the commonTask must be call by a lot of tasks
- and the common task run during "long time",
all tasks are waiting... and there is a risk that at least, 2 tasks launch commonTask at the same time after waiting :D

For the moment I copy all steps in all tasks :roll:
Chris
(Robotask v6.4.2 on Win2008 x64)
Post Reply