Jump to content
UBot Underground

Calling out to all advanced Ubot Users! Multi-threading question...


Recommended Posts

Hello ,

 

I have some doubts related to multi threading-- could Some advanced user who understands multi threading well.. please take a look and let me know if my logic is correct or not?
Thanks a lot.

How do I  save data from inside of a thread -in a multi threading scenario..?
Below I have written down what I think should be the right way to go about saving data from inside of a thread which uses local list and variables to process data -
Could you please tell me if my logic is correct or not?

-------------------------------------------------------------------------------------------------------


2 different ways -
a]  to save 'processed data' from 'inside of a function or command in a thread having [local] lists/variables -
b] and also [optionally] , to load data on to a variable to be processed inside of a thread

--------------------------------------------------------------------------------------------------------------
method - 01
---
outside of the thread -

1. create a new 'global scope' list - to load data, which will later  be read inside of a thread.
----
add list to list(%global list, $list from text("one,two,three,four,five,six,seven,eight", ","), "Delete", "Global")
----

2.inside the thread -

read from the global list -using - 'next list item' - but add the data to a local variable or list
----
thread {
    in new browser {
        set(#get data, $next list item(%global list), "Local")
        add item to list(%local list, $next list item(%global list), "Delete", "Local")
    }
    decrement(#threadsOpen)
}
----

[process this data]

also, if some data needs to be saved after the thread finishes - use 'add item to a list with global scope' - but read data from a local variable/local list .

thread {
    in new browser {
        set(#get data, $next list item(%global list), "Local")
        add item to list(%local list, $next list item(%global list), "Delete", "Local")
        add item to list(%save list, "{#get data},{$list item(%local list, 0)}", "Delete", "Global")
    }
    decrement(#threadsOpen)
}
-----
Method -02
-------------
outside of the thread -

1. create a new 'global scope' list position variable - this will be seen by 'all' open threads -and will be incremented inside the thread - to 'get' the next list item inside the local -functions or commands.
----
set(#listpositionCTR, "-1", "Global")
---
2.inside the thread -

we increment the global list position variable first.

Then,create a local list and read from that local list -using - the 'global scope' list position variable -(i.e instead of using next list item , we use list item(a list position variable)
to add the data to a local variable or local list


--------
Is the above correct?

 

Link to post
Share on other sites

it would be better if you give a live example code your using to debug for you..

 

also have you take a look at the entire thread at

http://www.ubotstudio.com/forum/index.php?/topic/10042-new-v4-tutorial-multi-threading-example/

 

 

which also goes over local lists, and variables, and how they are tied to the defined command and held local to that defined command when used within a thread

Link to post
Share on other sites
  • 2 weeks later...

i would steer clear of using tables/lists where you can can, and use a database instead. Many issues are resolved by using one. 

 

As for the issue of locals and lists, i would just use them global, which they are by default, and name them according to the thread duty,

 

thread_scraping_table1

thread_clicking_table1

 

once you get the hang more of what you're doing then you can start to tweak your code and improve upon it, and add more local functions, but its tricky when you are starting off to get it all right.

Link to post
Share on other sites

i would just use them global, which they are by default, and name them according to the thread duty,

 

I don't understand what you mean would you care to elaborate with some sample code?

 

Thanks.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...