UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
resource_manager.cpp File Reference
#include "resource_manager.h"
#include "utils/lock_guard.h"
#include <algorithm>
#include <map>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <utility>
Include dependency graph for resource_manager.cpp:

Go to the source code of this file.

Classes

class  lock
 
class  no_opts
 
class  options_t
 
class  resource
 
class  resource_manager_t
 
class  shm
 
class  shm_opts
 
class  singleton
 
class  singleton_opts
 

Macros

#define TYPE_LOCK   0
 
#define TYPE_SHM   1
 
#define TYPE_SINGLETON   2
 

Typedefs

typedef int type_t
 

Functions

static void func_delete (pair< string, pair< resource *, int > > arg)
 
pthread_mutex_t * rm_acquire_shared_lock (const char *name)
 
void * rm_get_shm (const char *name, int size)
 
void rm_lock ()
 
void rm_release_shared_lock (const char *name)
 
void * rm_singleton (const char *name, singleton_initializer_t initializer, void *data, singleton_deleter_t done)
 
void rm_unlock ()
 

Variables

static resource_manager_t resource_manager
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Seldom used, currently only in x11_common.c. But the managed resources cannot be easily replaced by static variables there because there will be multiple instances of static vars in case of modular UltraGrid build (every library compiled with that file defining the var).

Definition in file resource_manager.cpp.

Macro Definition Documentation

◆ TYPE_LOCK

#define TYPE_LOCK   0

◆ TYPE_SHM

#define TYPE_SHM   1

Definition at line 61 of file resource_manager.cpp.

Referenced by resource::create(), resource::get_suffix(), and rm_get_shm().

◆ TYPE_SINGLETON

#define TYPE_SINGLETON   2

Definition at line 62 of file resource_manager.cpp.

Referenced by resource::create(), resource::get_suffix(), and rm_singleton().

Typedef Documentation

◆ type_t

typedef int type_t

Definition at line 63 of file resource_manager.cpp.

Function Documentation

◆ func_delete()

static void func_delete ( pair< string, pair< resource *, int > > arg)
static

Definition at line 161 of file resource_manager.cpp.

161 {
162 delete arg.second.first;
163}

Referenced by resource_manager_t::~resource_manager_t().

◆ rm_acquire_shared_lock()

pthread_mutex_t * rm_acquire_shared_lock ( const char * name)
Parameters
nameis used to uniquely (!) identify lock. So when requested from 2 locations lock with same name, the same lock handle will be returned

Definition at line 259 of file resource_manager.cpp.

260{
261 lock *l = dynamic_cast<lock *>(resource_manager.acquire(
262 string(name), TYPE_LOCK, no_opts()));
263 if(l) {
264 return l->get();
265 } else {
266 return NULL;
267 }
268}
pthread_mutex_t * get()
resource * acquire(string name, type_t type, options_t const &options)
static resource_manager_t resource_manager
#define TYPE_LOCK
const char * name
Definition settings.cpp:193

References resource_manager_t::acquire(), lock::get(), name, resource_manager, and TYPE_LOCK.

Here is the call graph for this function:

◆ rm_get_shm()

void * rm_get_shm ( const char * name,
int size )

Definition at line 285 of file resource_manager.cpp.

286{
287 shm *s = dynamic_cast<shm *>(resource_manager.acquire(
288 string(name), TYPE_SHM, shm_opts(size)));
289 if(s) {
290 return s->get();
291 } else {
292 return NULL;
293 }
294}
void * get()
#define TYPE_SHM

References resource_manager_t::acquire(), shm::get(), name, resource_manager, and TYPE_SHM.

Referenced by get_state().

Here is the call graph for this function:

◆ rm_lock()

void rm_lock ( )

Definition at line 275 of file resource_manager.cpp.

References resource_manager_t::lock(), and resource_manager.

Referenced by get_state().

Here is the call graph for this function:

◆ rm_release_shared_lock()

void rm_release_shared_lock ( const char * name)

Definition at line 270 of file resource_manager.cpp.

271{
273}
void release(string name, type_t type)

References name, resource_manager_t::release(), resource_manager, and TYPE_LOCK.

Here is the call graph for this function:

◆ rm_singleton()

void * rm_singleton ( const char * name,
singleton_initializer_t initializer,
void * data,
singleton_deleter_t done )

Definition at line 296 of file resource_manager.cpp.

298{
299 singleton *s = dynamic_cast<singleton *>(resource_manager.acquire(
300 string(name), TYPE_SINGLETON, singleton_opts(initializer, data, done)));
301 if(s) {
302 return s->get();
303 } else {
304 return NULL;
305 }
306}
static void done(void *state)
#define TYPE_SINGLETON

References resource_manager_t::acquire(), done(), singleton::get(), name, resource_manager, and TYPE_SINGLETON.

Here is the call graph for this function:

◆ rm_unlock()

void rm_unlock ( )

Definition at line 280 of file resource_manager.cpp.

References resource_manager, and resource_manager_t::unlock().

Referenced by get_state().

Here is the call graph for this function:

Variable Documentation

◆ resource_manager