LockedConnection

Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Alias This

__conn

Members

Properties

__conn
inout(Connection) __conn [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
__refCount
int __refCount [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

int id = 0;
class Connection {
	public int id;
}

auto pool = new ConnectionPool!Connection({
	auto conn = new Connection(); // perform the connection here
	conn.id = id++;
	return conn;
});

// create and lock a first connection
auto c1 = pool.lockConnection();
assert(c1.id == 0);
pool.remove(c1);
destroy(c1);

auto c2 = pool.lockConnection();
assert(c2.id == 1); // assert that we got a new connection
pool.remove(c2);
pool.add(c2);
destroy(c2);

auto c3 = pool.lockConnection();
assert(c3.id == 1); // should get the same connection back

Meta