| 1 | package RPC::Lite::Threading; | ||
| 2 | |||
| 3 | =pod | ||
| 4 | |||
| 5 | =head1 Threading in RPC::Lite | ||
| 6 | |||
| 7 | RPC::Lite supports threading if you have the Thread::Pool module | ||
| 8 | installed. Threading can allow for more robust services but | ||
| 9 | you must be aware of all the pitfalls threaded programming | ||
| 10 | entails. Don't enable threading unless you need it and are | ||
| 11 | aware of the issues you must take into consideration. | ||
| 12 | |||
| 13 | The intention of providing threading is to allow for servers | ||
| 14 | that can handle both long and short-running requests. For example, | ||
| 15 | you might implement a simple Authenticate() method which matches | ||
| 16 | a given username/password with an entry in a database. That call | ||
| 17 | should be relatively trivial and return quickly. However, you | ||
| 18 | might also implement a Search() method which can take seconds or | ||
| 19 | longer to return. In a non-threaded implementation, any call to | ||
| 20 | Authenticate will block if a Search call is in progress. Obviously, | ||
| 21 | that's not optimal behavior. With careful programming and threading | ||
| 22 | support, long-running calls need not make the server unresponsive to | ||
| 23 | other incoming requests. | ||
| 24 | |||
| 25 | All of the caveats that come with multi-threaded programming will | ||
| 26 | apply to a threaded service, however. It's important to keep in mind | ||
| 27 | that you may need locks around certain functionality to avoid the | ||
| 28 | standard data corruption issues with concurrency. | ||
| 29 | |||
| 30 | RPC::Lite::Server has more information on how to enable and configure | ||
| 31 | threading. | ||
| 32 | |||
| 33 | =cut | ||
| 34 | |||
| 35 | 1; |