optimise generation counters

This pull request does 2 things:
 - it optimise the use of generation counters: object file are refreshed only when isValid() method is called

 - it implements Directory internal mutex so concurrent calls to a Directory object method (from OSToken::index()) are serialised and no longer can return garbage

I have found an issue with CKA_EXTRACTABLE attribute (bug in the caller, SoftHSMv2 follows the specs) so I leave this now (vs waiting for a discussion about the second point).