It'd be super neat if Wt had either an an arbitrary object resource  
pool that is per-thread or a thread-safe per-WServer variation.  I've  
hacked in a memcache and soci connection pool in to Wt, but it'd be  
nice if there was a formal API for grabbing an object that was  
returned to the pool when it went out of scope.

An example of this in action would be to store a pointer to a Memcache  
or database connection, or a Memcache Pool/factory object.  The API  
I've made for myself has all of WApplication and Widget classes  
maintaining a reference to an object pool so that I can do things like  
this:

void
MyWidget::foo() {
   Memcache mc(mc_pool());
   std::string val = mc.get("my_key");
   // Do something with val and mc is automatically returned to the pool
}

I use that same design pattern for database connections, but it seems  
clunky to have to set a reference when all of my model classes,  
Widgets and Applications all require some kind of database access.  I  
agree that Wt shouldn't provide native database connectivity, but the  
ability to grab a series of void* from someplace would very, very  
useful.

I'm very close to using boost::thread_specific_ptr to achieve this,  
but that feels like I'm stepping out of the Wt framework too much and  
am poking at Wt's internals more than I should have to.  Is that  
really the best way for me to do this or is there something really  
obvious that I'm missing (entirely possible)?  -sc


--
Sean Chittenden
[email protected]




------------------------------------------------------------------------------
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to