Mar 30
Da'oud Rashid Dynamic thread names
Mar 30, 2016; 21:02
Da'oud Rashid
Dynamic thread names
Hi all,
I’m in the process of upgrading from Lasso 8.5 to 9.x.
I’m looking to replace my global vars with define threadName => somevalue .
However, there are a number of instances in my old code where the global variable names are dynamic:
Global($aVariableName + ’Something’ = $aVariable)
Is it possible to do something similar for thread names? For example, something like the following (which doesn’t work):
define ($myThreadName) => $aVariable->ascopydeep
and
$aVariable = thread($myThreadName)->ascopydeep
I can do the following:
define myMap => thread{
parent map
public oncreate => ..oncreate
public load(map::map) => {
#map->foreachpair => {
self->insert(#1->first->ascopydeep = #1->second->ascopydeep)
}
}
}
myMaps->load($mapOfVars)
However, I’d prefer to create separate threads….mainly so I don’t run into issues with a heavy volume of concurrent access to the threads. Also, iterating through each item in the map doesn’t seem like a very efficient way to decouple the thread from the thread variable.
As an aside, I’m curious to know why ascopydeep doesn’t seem to work for threads (and doesn’t throw an error):
local(
item1Ref = 'item1',
foo = 'unchanged'
)
var(
myMap = map(#item1Ref = #foo),
mySecondMap = $myMap->ascopydeep
)
define myThread => $myMap->ascopydeep
$myMap->find(#item1Ref) = ‘changed'
$mySecondMap->find(#item1Ref)
// result: unchanged (as expected)
myThread->Find(#item1Ref)
// result: changed (unexpected)
—— AND — —
define myMap => thread{
parent map
public oncreate => ..oncreate
}
myMap->Insert(‘item1’ = ‘unchanged’)
var(mySecondMap = myThread->ascopydeep)
$mySecondMap->Find(’item1’) = ‘changed’
$mySecondMap->Find(‘item1’)
// result: changed (expected)
myThread->Find(‘item1’)
// result: changed (unexpected)
Unfortunately, myMap->foreachpair => {…} doesn’t seem to work (it throws an error), so I can’t use that to copy values into a thread variable.
Thank you,
Da’oud
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Mar 30
Ke Carlton Re: Dynamic thread names
Mar 30, 2016; 20:54
Ke Carlton
Re: Dynamic thread names
Mar 31
Da'oud Rashid Re: Dynamic thread names
Mar 31, 2016; 14:55
Da'oud Rashid
Re: Dynamic thread names
Mar 31
Ke Carlton Re: Dynamic thread names
Mar 31, 2016; 10:35
Ke Carlton
Re: Dynamic thread names
Mar 31
Da'oud Rashid Re: Dynamic thread names
Mar 31, 2016; 16:21
Da'oud Rashid
Re: Dynamic thread names
Apr 01
Jolle Carlestam Re: Dynamic thread names
Apr 01, 2016; 06:27
Jolle Carlestam
Re: Dynamic thread names
Apr 01
Ke Carlton Re: Dynamic thread names
Apr 01, 2016; 04:32
Ke Carlton
Re: Dynamic thread names
Apr 01
Jolle Carlestam Re: Dynamic thread names
Apr 01, 2016; 06:35
Jolle Carlestam
Re: Dynamic thread names
Apr 01
Ke Carlton Re: Dynamic thread names
Apr 01, 2016; 04:36
Ke Carlton
Re: Dynamic thread names