On Monday 19 May 2014 17:01:35 Steve Wampler wrote:
> On 05/19/2014 01:58 AM, user wrote:
> > I seem to have bumped into a vicious circle with threads.
> >
> > I want to "parallelize" a generator procedure producing a VARYING number
> > of results every call, in a sequence that is NOT important.
> >
> >>From the docs I understand that the usual method would be:
> >
> >    every [(GEN) do] put(L1,thread put(L2,gen()))
>
> You're putting a sequence of threads into L1, where each thread is putting
> results from gen() into L2.
Yes, exactly ONE result for each thread (total number of threads, and 
therefore results, varies each time this "every [(GEN)]..." line gets 
executed).

> So L2 is the sequence of results you're 
> interested in?
That's right!

> I assume you're going to do a 'every wait(!L1)' to wait 
> for all the results to get loaded into L2, right?
Right!

>
> What are the symptoms you're seeing?  Did you make L2 thread-safe?
Oops! How do I do that?

>
> > with GEN preferably generating the exact number of (varying) iterations
> > as any call of gen() would produce in results.
>
> I have trouble understanding this.  Can you give a short, concrete,
> example?

#----------------------------------------------------
procedure main()
T:=[];R:=[]
every (1 to 10) do put(T,thread put(R,gen()))  #CONSTANT no.of results!
#every (              put(T,thread put(R,gen()))) #SINGLE !
write("Number of Threads: ",*T)
write("Number of Results:  ",*R)
n:=0
every wait(!T) do write("Thread no.",n +:=1,"\nResult is ",R[n])
write("Threads finished!")
end
#----------------------------------------------------
procedure gen()
delay(2000)      ### to check (with top e.g.) if multi-threading does occur!
suspend (1 to 10) #CONSTANT no.of results, contrary to my actual code!
end
#----------------------------------------------------

>
> > The obvious solution would be to lose the "(GEN) do" but then only ONE
> > THREAD GETS CREATED !
>
> Yep - that's expected.
Can you explain please?

Thanks again.



------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Unicon-group mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/unicon-group

Reply via email to