greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018
09:32 AM
Task XML Blocks
I assumed that the TASK which is spawned would be asynchronous. But that doesn't seem to be the case.
It looks like it is blocking ?????
It looks like it is blocking ?????
Code in MAIN.BRS
t = m.scene.findNode("mytask")
for i=0 to 5
? "Main " i " before"
t.Input = { data:i }
? "Main " i " after"
? " "
end for
Code in TASK.XML
Sub Activate()
x = m.top.Input.data
? "Task in = " x
sleep(100)
? "Task exit after 100 milliseconds"
End Sub
RESULT
Main 0 before
Task in = 0
Task exit after 100 milliseconds
Main 0 after
Main 1 before
Task in = 1
Task exit after 100 milliseconds
Main 1 after
Main 2 before
Task in = 2
Task exit after 100 milliseconds
Main 2 after
Main 3 before
Task in = 3
Task exit after 100 milliseconds
Main 3 after
Main 4 before
Task in = 4
Task exit after 100 milliseconds
Main 4 after
Main 5 before
Task in = 5
Task exit after 100 milliseconds
Main 5 after
5 REPLIES 5
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018
11:54 AM
Re: Task XML Blocks
My understanding (though don't hold me to it / correct me if I'm mistaken) is that the task blocks itself (because it operates on its own thread), but you could spin off 5 separate tasks asynchronously that don't block each other; use createObject in the brs / render thread to spin off new tasks of the same type.
aspiring
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018
03:42 PM
Re: Task XML Blocks
I thought a TASK was like a fork, new activity.
What I have is, the main.brs routine triggers the TASK node. The TASK executes BUT the main doesn't get control back until the TASK completes.
You can this by the displays I provided.
What I have is, the main.brs routine triggers the TASK node. The TASK executes BUT the main doesn't get control back until the TASK completes.
You can this by the displays I provided.
Main 0 before
Task in = 0
Task exit after 100 milliseconds
Main 0 after
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2018
06:59 PM
Re: Task XML Blocks
My understanding of how tasks operate is limited at best and I've only used the control field to start a task (setting it to "RUN"). I assume you're trying to use the third development use case:
So maybe there's an implied "wait for the output data" in this? The documentation could be better. I used two labels and an observeField in my task and in my main loop to "RUN" the task and then get its output when it finished. The main loop is definitely not blocking (not that I'm doing anything useful while waiting).
-JT
- A Task node observes its input <interface> fields using the port form of the ifSGNodeField observeField() method, and returns output data with each field change. In this case, the Task node acts like a continuous server.
So maybe there's an implied "wait for the output data" in this? The documentation could be better. I used two labels and an observeField in my task and in my main loop to "RUN" the task and then get its output when it finished. The main loop is definitely not blocking (not that I'm doing anything useful while waiting).
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2018
10:19 AM
Re: Task XML Blocks
I think I have it.
If you trigger the Task with the observed field, it will run synchronously. That is the main activity will block until the task completes.
if you set parameters in the node and then set the control to "run", it spawns a new thread and the main activity continues.
If you trigger the Task with the observed field, it will run synchronously. That is the main activity will block until the task completes.
if you set parameters in the node and then set the control to "run", it spawns a new thread and the main activity continues.
greubel
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2018
10:36 AM
Re: Task XML Blocks
Anyone have an idea what "waitRelease", "syncRelease" and "sleepRelease " in the Task node are used for ?