Functions | |
template<typename TRANSACTOR> | |
void | pqxx::connection_base::perform (const TRANSACTOR &T, int Attempts) |
Perform the transaction defined by a transactor-based object. | |
template<typename TRANSACTOR> | |
void | pqxx::connection_base::perform (const TRANSACTOR &T) |
Perform the transaction defined by a transactor-based object. |
See the transactor class template for more about transactors. To use the transactor framework, encapsulate your transaction code in a class derived from an instantiation of the pqxx::transactor template. Then, to execute it, create an object of your transactor class and pass it to one of the perform() functions here.
The perform() functions may create and execute several copies of the transactor before succeeding or ultimately giving up. If there is any doubt over whether execution succeeded (this can happen if the connection to the server is lost just before the backend can confirm success), it is no longer retried and an in_doubt_error is thrown.
Some transactions may be replayed if their connection fails, until they do succeed. These can be encapsulated in a transactor-derived classes. The transactor framework will take care of setting up a backend transaction context for the operation, and of aborting and retrying if its connection goes bad.
The transactor framework also makes it easier for you to do this safely, avoiding typical pitfalls and encouraging programmers to separate their transaction definitions (essentially, business rules implementations) from their higher-level code (application using those business rules). The former go into the transactor-based class.
Pass an object of your transactor-based class to connection_base::perform() to execute the transaction code embedded in it (see the definitions in pqxx/connection_base.hxx).
connection_base::Perform() is actually a template, specializing itself to any transactor type you pass to it. This means you will have to pass it a reference of your object's ultimate static type; runtime polymorphism is not allowed. Hence the absence of virtual methods in transactor. The exact methods to be called at runtime *must* be resolved at compile time.
Your transactor-derived class must define a copy constructor. This will be used to create a "clean" copy of your transactor for every attempt that Perform() makes to run it.
|
Perform the transaction defined by a transactor-based object.
|
|
Perform the transaction defined by a transactor-based object.
|