neo4j/neo4j — pull request #967 by tinwelint (2013-07-14 22:14:41+00:00)
Title: Cheaper StatementState ref counting

o Cheaper ref counting
ReferenceCountingStatementOperations adds sharing of StatementState instances
among potentially multiple consumers, where they will be individually
closed, but the statement state not actually closed until ref count
reaches 0.

Previously a new "referenced" StatementState was returned for each of
these shared instances. And the single reason for that was to prevent and
fast-fail closing any given statement state instance multiple times. There
were no other such checks, just for closing. Keeping in mind that
KernelAPI is an internal API, having such checks should merely exist for
debugging purposes, _when_ debugging; not at runtime in production. As
seen by performance benchmarks all these StatementState instances are
costly.

This commit returns the same "referenced" StatementState (just inc/dec its
ref counter) for all the same shared instances to gain performance.

o StatementStateOwners moved to ThreadToStatementContextBridge since this
functionality is specific to the core API, and ThreadToStatementContextBridge
is specific to the core API.