I have a manager that holds connections to the server. I keep the connection alive and i want my threads to request connections when it needs. My question is
How do i have track objects automatically? I would like it to work similar to scoped pointer. I request a connection, then when my obj goes out of scope it tells the manager it is not in use anymore. I wont be passing it around as a pointer. I’ll be doing something like
{ Obj = Man.GetObj(); //some loop Obj.DoSomething() } //auto tell man that obj is no longer in use
You could create your own wrapper object and implements
IDisposable. In theDispose()method, signal the manager that you’re no longer in use. You can then have your statement like…The
usingblock automatically calls theDispose()method at the close of the scope.