cgi/conn_pool.h File Reference

connection pool functions. More...

#include <cgi/mysqlw.h>

Data Structures

struct  s_conn_pool
 Connection pool structure. More...

Typedefs

typedef struct s_pool_conns t_pool_conns
 Connection pool type.

Functions

t_conn_poolconn_pool_create (long size)
 Create connection pool.
void conn_pool_free (t_conn_pool *pool)
 Free connection pool and release memory.
int conn_push (t_conn_pool *pool, t_mysql *conn)
 Push connection to connection pool.
t_mysqlconn_pop (t_conn_pool *pool)
 Pop connection from connection pool.


Detailed Description

connection pool functions.

Author:
Vladimir Pavluk, 2006-2007
Connection pool and related functions. Connection pool is a structure which lets using several prepared MySQL connections in several simultanous sessions without any collision. Using prepared connections drastically speeds up program execution for persistent FastCGI applications.

Typical usage:

On thread startup:

 t_mysql *conn = conn_pop(pool); // If there are no connections NULL will be returned.
 if(!conn)
     conn = mysqlw_connect(...);

On thread shutdown:

 conn_push(pool, conn); // If there is no room for connection, it will be closed.

Typedef Documentation

typedef struct s_pool_conns t_pool_conns

Connection pool type.

Connection pool data type. Alias for struct s_conn_pool.


Function Documentation

t_conn_pool* conn_pool_create ( long  size  ) 

Create connection pool.

Creates connection pool with specified size.

Parameters:
size pool size (in number of connections).
Returns:
pointer to connection pool (t_conn_pool *) on success, NULL otherwise.
See also:
conn_pool_free(t_conn_pool *)

void conn_pool_free ( t_conn_pool pool  ) 

Free connection pool and release memory.

Frees connection pool and releases all memory allocated for it.

Parameters:
pool connection pool.
See also:
conn_pool_create(long)

t_mysql* conn_pop ( t_conn_pool pool  ) 

Pop connection from connection pool.

Returns connection from connection pool and removes it from the pool. Returns NULL if there is no more connections.

Parameters:
pool connection pool.
Returns:
MySQL connection, or NULL upon failure.
See also:
conn_pool_create(long)

conn_push(t_conn_pool *, t_mysql *)

int conn_push ( t_conn_pool pool,
t_mysql conn 
)

Push connection to connection pool.

Pushes connection to connection pool. If there is no room for it, connection will be closed.

Parameters:
pool connection pool.
conn MySQL connection
See also:
conn_pool_create(long)

conn_pop(t_conn_pool *)


Generated on Tue Jun 17 17:31:12 2008 for Data Processing Library by  doxygen 1.5.5