1. task function request

I have a use for task_talkback(object stuff) and i request it be added to Euphoria asap.

It would allow a task to provide more information about it's continuing operation than task_status() provides. For instance, percent completed, speed of something, etc... basically the same stuff provided by global vars and return {}. Returning from an uncompleted task or using global vars will mess things up in a tasking environment.

At the moment, i would use it in http.e and news5.ew.

useless

new topic     » topic index » view message » categorize

2. Re: task function request

Would this do what you need?

constant 
tID = 1, 
tData = 2 
 
sequence taskvars = {{},{}} 
 
 
export function task_get_var(atom taskid) 
    atom idx 
    idx = find(taskid, taskvars[tID]) 
     
    if idx > 0 then 
        return taskvars[tData][idx] 
    else 
        return 0 
    end if    
end function 
 
export procedure task_set_var(atom taskid, object taskvar) 
    atom idx 
    idx = find(taskid, taskvars[tID]) 
     
    if idx > 0 then 
        taskvars[tData][idx] = taskvar 
    end if 
end procedure 
 
new topic     » goto parent     » topic index » view message » categorize

3. Re: task function request

Ryanj posted code...
i tested it...
it didn't run right... but it's also late at night, and he did help even if the code didn't run. I came up with this:

  
sequence taskvars_ids = {}  
sequence taskvars_datas = {}  
 
export function task_get_var(atom taskid)  
    object taskvar  
    atom idx  
  
    idx = find(taskid, taskvars_ids)  
      
    if idx > 0 then  
        return taskvars_datas[idx]  
    else  
        return 0  
    end if     
end function  
  
export procedure task_set_var(atom taskid, object taskdata)  
    atom idx  
 
    idx = find(taskid, taskvars_ids)  
    if idx = 0 then 
      taskvars_ids &= taskid 
      taskvars_datas &= {taskdata} 
    end if 
    if idx > 0 then  
        taskvars_datas[idx] = taskdata 
    end if  
end procedure  
  

I added it to my task.e. It's running using news4.ex and a new unreleased version of http.e. News4.ex looks really nice with a percent of download ticker running for each site. News5.ex no longer crashes from http.e being terminated by the OS, and it also has a download percent ticker.

Thank you lots, Ry!

useless

new topic     » goto parent     » topic index » view message » categorize

4. Re: task function request

LOL! My code was written stupidly and hurriedly. I totally forgot to use "&=". I shouldn't be writing code when i'm this sleepy...oh well.

new topic     » goto parent     » topic index » view message » categorize

5. Re: task function request

Ry asked for a screen shot, here it is:

http://imgbin.org/index.php?page=image&id=759

useless

new topic     » goto parent     » topic index » view message » categorize

6. Re: task function request

The tasks code posted in this thread has been improved further. It's now dual path to/from each task, and has overwriting flags as shown, plus non-overwriting queueing message passing. Wildcard _set and _get to come, for easier bulk task msg spamming between tasks.

<task1> mommy, task6 is spamming me!

While one would think the single thread there would work fine, in practice it doesn't work reliably, because the bidirectional single msg "channel" for each thread can easily get overwritten before it's read. Having a dedicated channel to each task, and one from each task works better.

Derek has a link to the most recent bleeding edge code for comments and feedback. So does Ry and Unk. You may apply as well, but if you do not understand "to" or "will change, in flux", please don't.

useless

new topic     » goto parent     » topic index » view message » categorize

7. Re: task function request

I just looked at the code. I like the idea of having both flags and queues.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu