Code for Generic Object Pool?
BlitzMax Forums/BlitzMax Programming/Code for Generic Object Pool?
| ||
Is there a generic object pool type in Blitzmax or does anyone have code for such? Thanks! |
| ||
Hi I have some 'pooled object' management (based on array, and reusing items) But after a fast search I found this http://www.blitzbasic.com/Community/posts.php?topic=62215 http://www.blitzbasic.com/Community/posts.php?topic=62667 so you can have an idea about possible solutions Cheers |
| ||
That second one looks like what I need. I saw the first on the search but missed the second. Thanks! |
| ||
I was under the impression BlitzMax already used this strategy internally for allocating objects..? (i.e. maintain a page or two's worth of preallocated objects on a stack ready to pop off very quickly on New) Maybe I imagined that. Unless I misunderstand what this is for? |
| ||
I dont' know if Mark changed BMax internally in this time (some threads are of preistoric-era). You can always test if there are changes in time allocation/deallocation when you create a new object instance or delete it, with basic New, AddLast, Remove etc In any case, if some changes should/could be done internally, we should need a command to setup how many 'pages' or 'preallocated items' the program needs: this is something useful in some cases, in other (like GUI apps) you can 'wait' the allocation/deallocation time I think. |