Issue 4981 in pharo: New implementation of process-specific storage

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 4981 in pharo: New implementation of process-specific storage

pharo
Status: FixReviewNeeded
Owner: [hidden email]
Labels: Type-Feature

New issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981


I spend a bit of time to improve (to my thinking ;) a process-specific  
storage.
An old implementation allowed you to use any key to identify  
process-specific value, but with dynamic variables (ProcessSpecificVariable  
subclasses) it limits to use one PSS key per class.

I rewrote these classes to use instances , so you can create and use as  
many as you want instances of process-specific variable class.

Also, one thing which i was concerned with in old implementation is  
potential resource leaks. In my opinion, the process-specific data must be  
held weakly and disappear once it is no longer referenced. In this way we  
can make sure that no matter who or for what purpose used a  
process-specific storage for storing arbitrary data over random processes,  
it will clean-up automatically once no longer needed. In this  
implementation, all process-specific data kept weakly.

I also replaced the dictionary lookup (so you cannot use PSS as simple  
key/value storage), and replaced it with simple index-based array access,  
which is faster.

Instead you must create a (sub)instance of one of ProcessSpecificVariable  
classes, put it somewhere and once you need its value, just send  
#value/#value: to it. So, effectively it works as a key in PSS, except that  
you don't pay price of dictionary lookup for accessing it.

You can keep using a ProcessSpecificVariable (sub)classes to access PSS, i  
preserved enough methods to keep compatibility with this feature.


Review is needed!

Attachments:
        Process-Specific.1.cs  8.8 KB


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo

Comment #1 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

Examples of use PSS:

Suppose MyProcessSpecificVar is a subclass of ProcessSpecificVariable.

Then you can do:

[ MyProcessSpecificVar value: foo. ] fork.

[ MyProcessSpecificVar value. ] fork.

etc, i.e. in same way as old implementation allows to do it.

But with new implementation , you can also use instances of it, so you  
don't have to create a new class per each process-specific var you might  
want to use:

mykey := MyProcessSpecificVar new.


[ mykey value ] fork.
[ mykey value: 10 ] fork.





_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo

Comment #2 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

Looks cool to me.

The difference with using the instances instead of going via the class if  
of course that you have to keep a reference to the instance somewhere.

The backward compatibiity is great.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo

Comment #3 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

Yes, you have to keep a reference. In same way as you keep a reference to  
the class in your code :)
You can put an instance of PS value into a class-var (on server startup for  
instance), and clear to nil at shutdown. Like that, you can make sure that  
all server-specific resources, like sessions will be wiped out from system.

The idea of having more than one PS values of a single class came to me  
when i thought, what if i want to use PSS for implementing things like  
thread-safe non-blocking collections. So, one of the ways to do that is to  
use PS value per each collection instance and synchronize using it.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo
Updates:
        Labels: Milestone-1.4

Comment #4 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo
Updates:
        Status: FixToInclude

Comment #5 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4981 in pharo: New implementation of process-specific storage

pharo
Updates:
        Status: Integrated

Comment #6 on issue 4981 by [hidden email]: New implementation of  
process-specific storage
http://code.google.com/p/pharo/issues/detail?id=4981

1224


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker