2008-05-21 23:22:09 -04:00
|
|
|
! Copyright (C) 2008 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: accessors kernel arrays namespaces sequences continuations
|
2008-12-17 22:04:17 -05:00
|
|
|
io.pools db fry db.private ;
|
2008-05-21 23:22:09 -04:00
|
|
|
IN: db.pools
|
|
|
|
|
2008-10-02 13:11:56 -04:00
|
|
|
TUPLE: db-pool < pool db ;
|
2008-05-21 23:22:09 -04:00
|
|
|
|
2008-10-02 13:51:21 -04:00
|
|
|
: <db-pool> ( db -- pool )
|
2008-05-21 23:22:09 -04:00
|
|
|
db-pool <pool>
|
2008-10-02 13:51:21 -04:00
|
|
|
swap >>db ;
|
2008-05-21 23:22:09 -04:00
|
|
|
|
2008-10-02 13:51:21 -04:00
|
|
|
: with-db-pool ( db quot -- )
|
|
|
|
[ <db-pool> ] dip with-pool ; inline
|
2008-05-21 23:22:09 -04:00
|
|
|
|
|
|
|
M: db-pool make-connection ( pool -- )
|
2008-10-02 13:11:56 -04:00
|
|
|
db>> db-open ;
|
2008-05-21 23:22:09 -04:00
|
|
|
|
|
|
|
: with-pooled-db ( pool quot -- )
|
2008-12-17 22:04:17 -05:00
|
|
|
'[ db-connection _ with-variable ] with-pooled-connection ; inline
|