Hi Jim,
I haven't worked with Storage very much because frankly it's a pain and
it's slow. I get why it's a pain and has so much overhead. Every single
object has to have its own lock/unlock ('locker') mechanism and it works
between preemptive processes. So cool for that - no small thing. For me
it's good to keep it as flat as possible and limited to data that's likely
to be actively manipulated in the other processes. I figured this out the
first time I attempted to put a smalish collection of objects into Storage.
Not a good use case, in my opinion.

Otherwise I'm coming back to the liking a single IP object var for storing
essentially read-only data. If you don't have a situation where multiple
processes are likely to be hitting on it, like this sounds, it works fine.
If I need to make the data accessible to a preemptive process write it to
disk and read it into the process. I find TEXT TO DOCUMENT, which is thread
safe, pretty fast.


On Fri, Sep 13, 2019 at 9:33 PM Jim Crate via 4D_Tech <4d_tech@lists.4d.com>
wrote:

> On Sep 9, 2019, at 9:55 PM, Keisuke Miyako via 4D_Tech <
> 4d_tech@lists.4d.com> wrote:
> >
> >> So it looks like you can’t .push() a shared object onto a shared
> collection.
> >
> > not quite.
> >
> > a shared object is either single (solo) or multiple (once belonged to a
> group)
> > if an object joins a group, it is free to leave it, but it can't join
> another group.
> > [snip]
> > in your case, the problem is that you add $sharedObj to $catalogObj,
> > then $catalogObj to Storage.
> >
> > if you reverse the order, that is,
> > add $catalogObj to Storage first,
> > then $sharedObj to $catalogObj later,
> > it should work.
>
> $catalogObj is a sub-object from the results of an API call with HTTP Get.
> So it is an existing non-shared object (I.e. not manually created with keys
> and values by 4D code). I want to add that object to a shared collection so
> it can be put into Storage.
>
> The only reason $sharedObj exists is because I need to copy all attributes
> of $catalogObj to $sharedObj so I can add to a shared collection. (Note: I
> had an error in the first code snippet below; $sharedObj should have been
> assigned a New Shared Object.)
>
> If I use the code in the reference KB article, copying the non-shared
> $catalogObj to a new shared object $sharedObj, I can’t add $sharedObj to
> the shared collection. Presumably I could add that shared object to Storage
> as a root-level object, but I want a shared collection of those objects.
>
> It looks like collection.push() is actually copying the shared object, and
> that results in an error because of the shared object's __LockerID property
> being duplicated. However, we don’t seem to have any other way to add
> objects to a collection besides .unshift(), which probably does the same as
> .push(). It seems like .push() should just add the shared object reference
> to the shared collection, not copy it, especially for shared objects.
>
> If collection.push($myObj) actually copies $myObj, this should be clearly
> documented. If the general rule is that working with objects is by
> reference, we need to know when objects are copied instead of referenced.
>
> Jim Crate
>
>
> >> 2019/09/10 13:13、Jim Crate via 4D_Tech <4d_tech@lists.4d.com>のメール:
> >>
> >> So what doesn’t work is:
> >>
> >> $sharedObj:=New Shared Object
> >> OB_CopyToSharedObject ($catalogObj;$sharedObj)
> >> Use (Storage.MySharedCollection)
> >> Storage.MySharedCollection.push($sharedObj)
> >> End use
> >>
> >>
> >> What does work is:
> >>
> >> Storage.MySharedCollection.push(New shared object)
> >> Use (Storage.MySharedCollection[Storage.MySharedCollection.length-1])
> >> OB_CopyToSharedObject
> ($catalogObj;Storage.MySharedCollection[Storage.MySharedCollection.length-1])
> >> End use
> >
> >
> >
> > **********************************************************************
> > 4D Internet Users Group (4D iNUG)
> > Archive:  http://lists.4d.com/archives.html
> > Options: https://lists.4d.com/mailman/options/4d_tech
> > Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> > **********************************************************************
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************



-- 
Kirk Brooks
San Francisco, CA
=======================

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to