[Licq-devel] Resource handling in Licq 2

"Erik Johansson" <[email protected]>
Newsgroups gmane.network.licq.devel
Message-ID <[email protected]>
I've been experimenting with how we could handle locking/unlocking of
resources in Licq 2. I've uploaded the files to
http://ejohansson.se/files/licq/resources/ for you all to take a look
at. It's not complete in any way, but it compiles (for me at least).

An example may help to make it easier to understand. Take the current
class ICQUser. In this scheme it would implement ReadableResource and
WriteableResource (probably just by inheriting from some other class
that implements the two interfaces). The daemon would have a number of
ICQUser instances, all kept as boost::shared_ptr<ICQUser>.

When a plugin would like to read/write some info about a user it calls
daemon->getUser(...) which returns a ResourceHandle<ICQUser>. Then,
when the plugin is ready to read it does:
{
  ReadLocker<ICQUser> user(theHandle);
  user->getSomeData();
}

and to write it would do:
{
  WriteLocker<ICQUser> user(theHandle);
  user->setSomeData();
}

The locker classes ensures that the resource is properly locked and unlocked.

Comments?

// Erik

-- 
Erik Johansson
http://ejohansson.se/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.