Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with gnatcoll.sql.Exec;
- package body db_connection_pool
- is
- DB_Description : GNATCOLL.SQL.Exec.Database_Description := GNATCOLL.SQL.Postgres.Setup
- (Database => "rod",
- User => "rod",
- Host => "localhost",
- Password => "secret",
- SSL => gnatColl.SQL.postgres.Prefer);
- protected body
- safe_Connections
- is
- procedure fetch (new_Connection : out gnatcoll.sql.Exec.Database_Connection)
- is
- begin
- if next_Available > 0 then
- new_Connection := Available (next_Available); -- tbd: probly have to reset connection here, in case it's a new task ?
- next_Available := next_Available - 1;
- else
- new_Connection := gnatcoll.sql.Exec.build_Connection (DB_Description);
- end if;
- end;
- procedure free (the_Connection : in gnatcoll.sql.Exec.Database_Connection)
- is
- begin
- next_Available := next_Available + 1;
- Available (next_Available) := the_Connection;
- end;
- end safe_Connections;
- function fetch return gnatcoll.sql.Exec.Database_Connection
- is
- new_Connection : gnatcoll.sql.Exec.Database_Connection;
- begin
- safe_Connections.fetch (new_Connection);
- return new_Connection;
- end;
- procedure free (the_Connection : in gnatcoll.sql.Exec.Database_Connection)
- is
- begin
- safe_Connections.free (the_Connection);
- end;
- end db_connection_pool;
Add Comment
Please, Sign In to add comment