1 ! Copyright (C) 2009 Joe Groff.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: classes help.markup help.syntax kernel math ;
8 { "size" integer } { "class" class }
11 { $description "Creates a " { $link pool } " of " { $snippet "size" } " objects of " { $snippet "class" } "." } ;
14 { $syntax "POOL: class size" }
15 { $description "Creates a " { $link pool } " of " { $snippet "size" } " objects of " { $snippet "class" } ", and associates it with the class using " { $link set-class-pool } "." } ;
22 { $description "Returns the " { $link pool } " associated with " { $snippet "class" } ", or " { $link f } " if no pool is associated." } ;
28 { $description "Frees an object from the " { $link pool } " it was allocated from. The object must have been allocated by " { $link new-from-pool } "." } ;
35 { $description "Allocates an object from the " { $link pool } " associated with " { $snippet "class" } ". If the pool is exhausted, " { $link f } " is returned." } ;
37 { POSTPONE: POOL: class-pool set-class-pool new-from-pool free-to-pool } related-words
40 { $class-description "A " { $snippet "pool" } " contains a fixed-size set of preallocated tuple objects. Once the pool has been allocated, its objects can be allocated with " { $link pool-new } " and freed with " { $link pool-free } " in constant time. A pool can also be associated with its class with the " { $link POSTPONE: POOL: } " syntax or the " { $link set-class-pool } " word, after which the words " { $link new-from-pool } " and " { $link free-to-pool } " can be used with the class name to allocate and free objects." } ;
44 { "object" object } { "pool" pool }
46 { $description "Frees an object back into " { $link pool } "." } ;
53 { $description "Returns the number of unallocated objects inside a " { $link pool } "." } ;
60 { $description "Returns an unallocated object out of a " { $link pool } ". If the pool is exhausted, " { $link f } " is returned." } ;
62 { pool <pool> pool-new pool-free pool-size } related-words
66 { "class" class } { "pool" pool }
68 { $description "Associates a " { $link pool } " with " { $snippet "class" } "." } ;
70 ARTICLE: "memory.pools" "Pools"
71 "The " { $vocab-link "memory.pools" } " vocabulary provides " { $link pool } " objects which manage preallocated collections of objects."