tie AssetManager locking to the Asset DB impl object
This commit is contained in:
parent
eaedab90ea
commit
90150b1350
3 changed files with 16 additions and 10 deletions
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "pre_a.hpp"
|
||||
|
||||
#include "lib/sync.hpp"
|
||||
#include "proc/asset.hpp"
|
||||
#include "include/error.hpp"
|
||||
|
||||
|
|
@ -35,11 +36,14 @@
|
|||
#include <boost/utility.hpp>
|
||||
|
||||
|
||||
namespace asset
|
||||
{
|
||||
namespace asset {
|
||||
|
||||
using std::tr1::static_pointer_cast;
|
||||
using std::tr1::dynamic_pointer_cast;
|
||||
|
||||
using lib::Sync;
|
||||
using lib::RecursiveLock_NoWait;
|
||||
|
||||
|
||||
/* ===== hash implementations ===== */
|
||||
|
||||
|
|
@ -83,7 +87,9 @@ namespace asset
|
|||
* instances known to the Asset Manager subsystem.
|
||||
* As of 8/2007 implemented by a hashtable.
|
||||
*/
|
||||
class DB : private boost::noncopyable
|
||||
class DB
|
||||
: private boost::noncopyable,
|
||||
public Sync<RecursiveLock_NoWait>
|
||||
{
|
||||
IdHashtable table;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ using lumiera::Singleton;
|
|||
using lib::Sync;
|
||||
|
||||
|
||||
namespace asset
|
||||
{
|
||||
namespace asset {
|
||||
|
||||
/**
|
||||
* AssetManager error responses, caused by querying
|
||||
|
|
@ -113,14 +112,15 @@ namespace asset
|
|||
throw(lumiera::error::Invalid)
|
||||
{
|
||||
AssetManager& _aMang (AssetManager::instance());
|
||||
DB& registry (_aMang.registry);
|
||||
TODO ("check validity of Ident Category");
|
||||
ID<KIND> asset_id (getID (idi));
|
||||
|
||||
Sync<>::ClassLock<DB> guard();
|
||||
DB::Lock guard(®istry);
|
||||
TODO ("handle duplicate Registrations");
|
||||
P<KIND> smart_ptr (obj, &destroy);
|
||||
|
||||
_aMang.registry.put (asset_id, smart_ptr);
|
||||
registry.put (asset_id, smart_ptr);
|
||||
return asset_id;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,7 @@ using std::list;
|
|||
|
||||
|
||||
|
||||
namespace asset
|
||||
{
|
||||
namespace asset {
|
||||
|
||||
class DB;
|
||||
|
||||
|
|
@ -62,7 +61,8 @@ namespace asset
|
|||
/**
|
||||
* Facade for the Asset subsystem
|
||||
*/
|
||||
class AssetManager : private boost::noncopyable
|
||||
class AssetManager
|
||||
: private boost::noncopyable
|
||||
{
|
||||
asset::DB & registry;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue