Merge remote branch 'public/nobug201001.2' into backend_devel
* public/nobug201001.2: integrating nobug context passing updates for nobug 201001.2 Conflicts: configure.ac src/lib/condition.h src/lib/reccondition.h tests/backend/test-threads.c
This commit is contained in:
commit
9fc68c9d32
28 changed files with 651 additions and 485 deletions
|
|
@ -92,7 +92,7 @@ AC_CHECK_HEADER([execinfo.h], AC_DEFINE(HAVE_EXECINFO_H))
|
|||
PKG_CHECK_MODULES(VALGRIND, [valgrind], AC_DEFINE(HAVE_VALGRIND_H),
|
||||
AC_MSG_NOTICE([valgrind not found (optional)]))
|
||||
|
||||
PKG_CHECK_MODULES(NOBUGMT, [nobugmt >= 201001.1],
|
||||
PKG_CHECK_MODULES(NOBUGMT, [nobugmt >= 201001.2],
|
||||
AC_DEFINE(HAVE_NOBUGMT_H),
|
||||
AC_MSG_ERROR([Missing required nobug version (http://www.lumiera.org/nobug_manual.html)])
|
||||
)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ lumiera_filedescriptor_registry_init (void)
|
|||
if (!registry)
|
||||
LUMIERA_DIE (NO_MEMORY);
|
||||
|
||||
lumiera_mutex_init (®istry_mutex, "filedescriptor_registry", &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_init (®istry_mutex, "filedescriptor_registry", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -107,7 +107,7 @@ lumiera_filedescriptor_registry_destroy (void)
|
|||
TRACE (filedescriptor_dbg);
|
||||
REQUIRE (!psplay_nelements (registry));
|
||||
|
||||
lumiera_mutex_destroy (®istry_mutex, &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_destroy (®istry_mutex, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
if (registry)
|
||||
psplay_destroy (registry);
|
||||
|
|
@ -277,7 +277,7 @@ lumiera_filedescriptor_new (LumieraFiledescriptor template)
|
|||
self->mmapings = NULL;
|
||||
llist_init (&self->files);
|
||||
|
||||
lumiera_mutex_init (&self->lock, "filedescriptor", &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_init (&self->lock, "filedescriptor", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
@ -310,7 +310,7 @@ lumiera_filedescriptor_delete (LumieraFiledescriptor self, const char* name)
|
|||
|
||||
TODO ("release filehandle");
|
||||
|
||||
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
lumiera_free (self);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ lumiera_filehandlecache_new (int max_entries)
|
|||
lumiera_mrucache_init (&lumiera_fhcache->cache, lumiera_filehandle_destroy_node);
|
||||
lumiera_fhcache->available = max_entries;
|
||||
lumiera_fhcache->checked_out = 0;
|
||||
lumiera_mutex_init (&lumiera_fhcache->lock, "filehandlecache", &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_init (&lumiera_fhcache->lock, "filehandlecache", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ lumiera_filehandlecache_delete (void)
|
|||
{
|
||||
REQUIRE (!lumiera_fhcache->checked_out, "Filehandles in use at shutdown");
|
||||
lumiera_mrucache_destroy (&lumiera_fhcache->cache);
|
||||
lumiera_mutex_destroy (&lumiera_fhcache->lock, &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_destroy (&lumiera_fhcache->lock, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
lumiera_free (lumiera_fhcache);
|
||||
lumiera_fhcache = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ lumiera_mmapcache_new (size_t limit)
|
|||
lumiera_mcache->total = 0;
|
||||
lumiera_mcache->cached = 0;
|
||||
|
||||
lumiera_mutex_init (&lumiera_mcache->lock, "mmapcache", &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_init (&lumiera_mcache->lock, "mmapcache", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ lumiera_mmapcache_delete (void)
|
|||
{
|
||||
REQUIRE (lumiera_mcache->total == lumiera_mcache->cached, "MMaps still checked out at shutdown");
|
||||
lumiera_mrucache_destroy (&lumiera_mcache->cache);
|
||||
lumiera_mutex_destroy (&lumiera_mcache->lock, &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_destroy (&lumiera_mcache->lock, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
free (lumiera_mcache);
|
||||
lumiera_mcache = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ lumiera_mmapings_init (LumieraMMapings self, LumieraFile file, size_t chunksize)
|
|||
self->descriptor = file->descriptor;
|
||||
self->chunksize = chunksize;
|
||||
|
||||
lumiera_mutex_init (&self->lock, "mmapings", &NOBUG_FLAG(mutex_dbg));
|
||||
lumiera_mutex_init (&self->lock, "mmapings", &NOBUG_FLAG(mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ lumiera_mmapings_destroy (LumieraMMapings self)
|
|||
lumiera_mmap_delete (mmap);
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG(mutex_dbg));
|
||||
lumiera_mutex_destroy (&self->lock, &NOBUG_FLAG(mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ lumiera_threadpool_init(void)
|
|||
pthread_attr_init (&threadpool.pool[i].pthread_attrs);
|
||||
//cancel...
|
||||
|
||||
lumiera_condition_init (&threadpool.pool[i].sync,"pool of threads", &NOBUG_FLAG (threadpool));
|
||||
lumiera_condition_init (&threadpool.pool[i].sync,"pool of threads", &NOBUG_FLAG (threadpool), NOBUG_CONTEXT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ lumiera_threadpool_destroy(void)
|
|||
lumiera_thread_delete ((LumieraThread)t);
|
||||
}
|
||||
}
|
||||
lumiera_condition_destroy (&threadpool.pool[i].sync, &NOBUG_FLAG (threadpool));
|
||||
lumiera_condition_destroy (&threadpool.pool[i].sync, &NOBUG_FLAG (threadpool), NOBUG_CONTEXT);
|
||||
pthread_attr_destroy (&threadpool.pool[i].pthread_attrs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ lumiera_thread_new (enum lumiera_thread_class kind,
|
|||
|
||||
LumieraThread self = lumiera_malloc (sizeof (*self));
|
||||
llist_init (&self->node);
|
||||
lumiera_condition_init (&self->signal, "thread-control", flag);
|
||||
lumiera_condition_init (&self->signal, "thread-control", flag, NOBUG_CONTEXT);
|
||||
self->kind = kind;
|
||||
self->state = LUMIERA_THREADSTATE_STARTUP;
|
||||
self->function = NULL;
|
||||
|
|
@ -212,7 +212,7 @@ lumiera_thread_destroy (LumieraThread self)
|
|||
ENSURE (0 == error, "pthread_join returned %d:%s", error, strerror (error));
|
||||
|
||||
// condition has to be destroyed after joining with the thread
|
||||
lumiera_condition_destroy (&self->signal, &NOBUG_FLAG (threads));
|
||||
lumiera_condition_destroy (&self->signal, &NOBUG_FLAG (threads), NOBUG_CONTEXT);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
@ -319,12 +319,12 @@ lumiera_thread_sync (void)
|
|||
REQUIRE(self, "not a lumiera thread");
|
||||
|
||||
self->state = LUMIERA_THREADSTATE_SYNCING;
|
||||
lumiera_condition_signal (&self->signal, &NOBUG_FLAG(threads));
|
||||
lumiera_condition_signal (&self->signal, &NOBUG_FLAG(threads), NOBUG_CONTEXT);
|
||||
|
||||
TODO("error handing, maybe timed mutex (using the threads heartbeat timeout, shortly before timeout)");
|
||||
|
||||
while (self->state == LUMIERA_THREADSTATE_SYNCING) {
|
||||
lumiera_condition_wait (&self->signal, &NOBUG_FLAG(threads), self->rh);
|
||||
lumiera_condition_wait (&self->signal, &NOBUG_FLAG(threads), self->rh, NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ lumiera_config_init (const char* path)
|
|||
lumiera_configitem_init (&lumiera_global_config->files);
|
||||
lumiera_configitem_init (&lumiera_global_config->TODO_unknown);
|
||||
|
||||
lumiera_mutex_init (&lumiera_global_config->lock, "config mutex", &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_init (&lumiera_global_config->lock, "config mutex", &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
lumiera_config_setdefault (lumiera_tmpbuf_snprintf (SIZE_MAX, "config.path = %s", path));
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ lumiera_config_destroy ()
|
|||
TRACE (config_dbg);
|
||||
if (lumiera_global_config)
|
||||
{
|
||||
lumiera_mutex_destroy (&lumiera_global_config->lock, &NOBUG_FLAG (mutex_dbg));
|
||||
lumiera_mutex_destroy (&lumiera_global_config->lock, &NOBUG_FLAG (mutex_dbg), NOBUG_CONTEXT);
|
||||
lumiera_configitem_destroy (&lumiera_global_config->defaults, &lumiera_global_config->keys);
|
||||
lumiera_configitem_destroy (&lumiera_global_config->files, &lumiera_global_config->keys);
|
||||
lumiera_configitem_destroy (&lumiera_global_config->TODO_unknown, &lumiera_global_config->keys);
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ lumiera_interfaceregistry_init (void)
|
|||
if (!lumiera_pluginregistry)
|
||||
LUMIERA_DIE (ERRNO);
|
||||
|
||||
lumiera_recmutex_init (&lumiera_interface_mutex, "interfaceregistry", &NOBUG_FLAG(interfaceregistry));
|
||||
lumiera_recmutex_init (&lumiera_interface_mutex, "interfaceregistry", &NOBUG_FLAG(interfaceregistry), NOBUG_CONTEXT);
|
||||
|
||||
lumiera_interface_init ();
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ lumiera_interfaceregistry_destroy (void)
|
|||
psplay_delete (lumiera_pluginregistry);
|
||||
lumiera_pluginregistry = NULL;
|
||||
|
||||
lumiera_recmutex_destroy (&lumiera_interface_mutex, &NOBUG_FLAG(mutex_dbg));
|
||||
lumiera_recmutex_destroy (&lumiera_interface_mutex, &NOBUG_FLAG(mutex_dbg), NOBUG_CONTEXT);
|
||||
|
||||
REQUIRE (!psplay_nelements (lumiera_interfaceregistry), "some interfaces still registered at shutdown");
|
||||
|
||||
|
|
|
|||
|
|
@ -28,25 +28,30 @@
|
|||
|
||||
|
||||
LumieraCondition
|
||||
lumiera_condition_init (LumieraCondition self, const char* purpose, struct nobug_flag* flag)
|
||||
lumiera_condition_init (LumieraCondition self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
pthread_cond_init (&self->cond, NULL);
|
||||
pthread_mutex_init (&self->cndmutex, NULL);
|
||||
NOBUG_RESOURCE_HANDLE_INIT (self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW (flag, "cond_var", purpose, self, self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "cond_var", purpose, self, self->rh, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
LumieraCondition
|
||||
lumiera_condition_destroy (LumieraCondition self, struct nobug_flag* flag)
|
||||
lumiera_condition_destroy (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_FORGET_RAW (flag, self->rh);
|
||||
NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx);
|
||||
|
||||
if (pthread_mutex_destroy (&self->cndmutex))
|
||||
LUMIERA_DIE (LOCK_DESTROY);
|
||||
|
|
|
|||
|
|
@ -46,39 +46,41 @@
|
|||
* @param nobugflag NoBug flag used to log actions on the condition
|
||||
* @param cnd Condition variable to be locked
|
||||
*/
|
||||
#define LUMIERA_CONDITION_SECTION(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_condition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_condition_lock (cnd, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_CONDITION_SECTION_UNLOCK; \
|
||||
#define LUMIERA_CONDITION_SECTION(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_condition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_condition_lock (cnd, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_CONDITION_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
#define LUMIERA_CONDITION_SECTION_CHAIN(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_condition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_condition_lock (cnd, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_CONDITION_SECTION_UNLOCK; \
|
||||
#define LUMIERA_CONDITION_SECTION_CHAIN(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_condition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_condition_lock (cnd, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_CONDITION_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -96,8 +98,9 @@
|
|||
REQUIRE (lumiera_lock_section_.lock, "Condition mutex not locked"); \
|
||||
lumiera_condition_wait (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag, \
|
||||
&lumiera_lock_section_.rh); \
|
||||
}
|
||||
&lumiera_lock_section_.rh, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (!(expr))
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -113,7 +116,8 @@
|
|||
if (!lumiera_condition_timedwait (lumiera_lock_section_.lock, \
|
||||
timeout, \
|
||||
lumiera_lock_section_.flag, \
|
||||
&lumiera_lock_section_.rh)) \
|
||||
&lumiera_lock_section_.rh, \
|
||||
NOBUG_CONTEXT)) \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +130,8 @@
|
|||
do { \
|
||||
REQUIRE (lumiera_lock_section_.lock, "Condition mutex not locked"); \
|
||||
lumiera_condition_signal (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag); \
|
||||
lumiera_lock_section_.flag, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
|
@ -139,7 +144,8 @@
|
|||
do { \
|
||||
REQUIRE (lumiera_lock_section_.lock, "Condition mutex not locked"); \
|
||||
lumiera_condition_broadcast (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag); \
|
||||
lumiera_lock_section_.flag, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
|
@ -163,7 +169,10 @@ typedef lumiera_condition* LumieraCondition;
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraCondition
|
||||
lumiera_condition_init (LumieraCondition self, const char* purpose, struct nobug_flag* flag);
|
||||
lumiera_condition_init (LumieraCondition self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -172,20 +181,25 @@ lumiera_condition_init (LumieraCondition self, const char* purpose, struct nobug
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraCondition
|
||||
lumiera_condition_destroy (LumieraCondition self, struct nobug_flag* flag);
|
||||
lumiera_condition_destroy (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
static inline LumieraCondition
|
||||
lumiera_condition_lock (LumieraCondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_condition_lock (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire condvar", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire condvar", *handle, ctx);
|
||||
|
||||
if (pthread_mutex_lock (&self->cndmutex))
|
||||
LUMIERA_DIE (LOCK_ACQUIRE); /* never reached (in a correct program) */
|
||||
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -193,22 +207,25 @@ lumiera_condition_lock (LumieraCondition self, struct nobug_flag* flag, struct n
|
|||
|
||||
|
||||
static inline LumieraCondition
|
||||
lumiera_condition_trylock (LumieraCondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_condition_trylock (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire condvar", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire condvar", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_trylock (&self->cndmutex);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -221,22 +238,23 @@ static inline LumieraCondition
|
|||
lumiera_condition_timedlock (LumieraCondition self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire condvar", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire condvar", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_timedlock (&self->cndmutex, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -246,15 +264,18 @@ lumiera_condition_timedlock (LumieraCondition self,
|
|||
|
||||
|
||||
static inline LumieraCondition
|
||||
lumiera_condition_wait (LumieraCondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_condition_wait (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_WAITING, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_WAITING, *handle, ctx);
|
||||
|
||||
pthread_cond_wait (&self->cond, &self->cndmutex);
|
||||
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -264,22 +285,23 @@ static inline LumieraCondition
|
|||
lumiera_condition_timedwait (LumieraCondition self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_WAITING, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_WAITING, *handle, ctx);
|
||||
|
||||
int err;
|
||||
do {
|
||||
err = pthread_cond_timedwait (&self->cond, &self->cndmutex, timeout);
|
||||
} while(err == EINTR);
|
||||
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
|
||||
if (err)
|
||||
{
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -290,27 +312,34 @@ lumiera_condition_timedwait (LumieraCondition self,
|
|||
|
||||
|
||||
static inline void
|
||||
lumiera_condition_signal (LumieraCondition self, struct nobug_flag* flag)
|
||||
lumiera_condition_signal (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
TRACE(NOBUG_FLAG_RAW(flag), "Signal %p", self);
|
||||
NOBUG_TRACE_CTX (NOBUG_FLAG_RAW(flag), ctx, "Signal %p", self);
|
||||
pthread_cond_signal (&self->cond);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
lumiera_condition_broadcast (LumieraCondition self, struct nobug_flag* flag)
|
||||
lumiera_condition_broadcast (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
TRACE(NOBUG_FLAG_RAW(flag), "Broadcast %p", self);
|
||||
NOBUG_TRACE_CTX(NOBUG_FLAG_RAW(flag), ctx, "Broadcast %p", self);
|
||||
pthread_cond_broadcast (&self->cond);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
lumiera_condition_unlock (LumieraCondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_condition_unlock (LumieraCondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
REQUIRE(self);
|
||||
NOBUG_REQUIRE_CTX (self, ctx);
|
||||
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle)
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx)
|
||||
{
|
||||
if (pthread_mutex_unlock (&self->cndmutex))
|
||||
LUMIERA_DIE (LOCK_RELEASE); /* never reached (in a correct program) */
|
||||
|
|
|
|||
|
|
@ -39,32 +39,32 @@ LUMIERA_ERROR_DEFINE (LOCK_AGAIN, "too much recursive locks");
|
|||
|
||||
|
||||
void
|
||||
lumiera_lockerror_set (int err, struct nobug_flag* flag, const char* extra)
|
||||
lumiera_lockerror_set (int err, struct nobug_flag* flag, const struct nobug_context ctx)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case EINVAL:
|
||||
LUMIERA_ERROR_SET_ALERT(NOBUG_FLAG_RAW(flag), LOCK_INVAL, extra);
|
||||
LUMIERA_ERROR_SET_ALERT(NOBUG_FLAG_RAW(flag), LOCK_INVAL, ctx.func);
|
||||
break;
|
||||
case EBUSY:
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_BUSY, extra);
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_BUSY, ctx.func);
|
||||
break;
|
||||
case EDEADLK:
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_DEADLK, extra);
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_DEADLK, ctx.func);
|
||||
break;
|
||||
case EPERM:
|
||||
LUMIERA_ERROR_SET_ALERT(NOBUG_FLAG_RAW(flag), LOCK_PERM, extra);
|
||||
LUMIERA_ERROR_SET_ALERT(NOBUG_FLAG_RAW(flag), LOCK_PERM, ctx.func);
|
||||
break;
|
||||
case ETIMEDOUT:
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_TIMEOUT, extra);
|
||||
LUMIERA_ERROR_SET(NOBUG_FLAG_RAW(flag), LOCK_TIMEOUT, ctx.func);
|
||||
break;
|
||||
case EAGAIN:
|
||||
LUMIERA_ERROR_SET_WARNING(NOBUG_FLAG_RAW(flag), LOCK_AGAIN, extra);
|
||||
LUMIERA_ERROR_SET_WARNING(NOBUG_FLAG_RAW(flag), LOCK_AGAIN, ctx.func);
|
||||
break;
|
||||
default:
|
||||
LUMIERA_ERROR_SET_CRITICAL(NOBUG_FLAG_RAW(flag), UNKNOWN, extra);
|
||||
LUMIERA_ERROR_SET_CRITICAL(NOBUG_FLAG_RAW(flag), UNKNOWN, ctx.func);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ LUMIERA_ERROR_DECLARE (LOCK_AGAIN);
|
|||
* Translate pthread error code into lumiera error
|
||||
*/
|
||||
void
|
||||
lumiera_lockerror_set (int err, struct nobug_flag* flag, const char* extra);
|
||||
lumiera_lockerror_set (int err, struct nobug_flag* flag, const struct nobug_context ctx);
|
||||
|
||||
#endif
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -477,9 +477,7 @@ mpool_reserve (MPool self, unsigned nelements)
|
|||
void
|
||||
nobug_mpool_dump (const_MPool self,
|
||||
const int depth,
|
||||
const char* file,
|
||||
const int line,
|
||||
const char* func)
|
||||
const struct nobug_context dump_context)
|
||||
{
|
||||
if (self && depth)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -234,9 +234,8 @@ mpool_free (MPool self, void* element);
|
|||
void
|
||||
nobug_mpool_dump (const_MPool self,
|
||||
const int depth,
|
||||
const char* file,
|
||||
const int line,
|
||||
const char* func);
|
||||
const struct nobug_context dump_context);
|
||||
|
||||
|
||||
/*
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -27,24 +27,29 @@
|
|||
*/
|
||||
|
||||
LumieraMutex
|
||||
lumiera_mutex_init (LumieraMutex self, const char* purpose, struct nobug_flag* flag)
|
||||
lumiera_mutex_init (LumieraMutex self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
pthread_mutex_init (&self->mutex, NULL);
|
||||
NOBUG_RESOURCE_HANDLE_INIT (self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW (flag, "mutex", purpose, self, self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "mutex", purpose, self, self->rh, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
LumieraMutex
|
||||
lumiera_mutex_destroy (LumieraMutex self, struct nobug_flag* flag)
|
||||
lumiera_mutex_destroy (LumieraMutex self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_FORGET_RAW (flag, self->rh);
|
||||
NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx);
|
||||
if (pthread_mutex_destroy (&self->mutex))
|
||||
LUMIERA_DIE (LOCK_DESTROY);
|
||||
}
|
||||
|
|
|
|||
113
src/lib/mutex.h
113
src/lib/mutex.h
|
|
@ -38,19 +38,20 @@
|
|||
/**
|
||||
* Mutual exclusive section.
|
||||
*/
|
||||
#define LUMIERA_MUTEX_SECTION(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_mutex_lock (mtx, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_MUTEX_SECTION_UNLOCK; \
|
||||
#define LUMIERA_MUTEX_SECTION(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_mutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_MUTEX_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -61,23 +62,24 @@
|
|||
* This macro should only be used inside LUMIERA_MUTEX_SECTION and should be
|
||||
* called on the correct mutexes, period.
|
||||
*/
|
||||
#define LUMIERA_MUTEX_SECTION_CHAIN(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_mutex_lock (mtx, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_MUTEX_SECTION_UNLOCK; \
|
||||
#define LUMIERA_MUTEX_SECTION_CHAIN(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_mutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_MUTEX_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -107,7 +109,10 @@ typedef lumiera_mutex* LumieraMutex;
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraMutex
|
||||
lumiera_mutex_init (LumieraMutex self, const char* purpose, struct nobug_flag* flag);
|
||||
lumiera_mutex_init (LumieraMutex self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
/**
|
||||
* Destroy a mutex variable
|
||||
|
|
@ -116,7 +121,9 @@ lumiera_mutex_init (LumieraMutex self, const char* purpose, struct nobug_flag* f
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraMutex
|
||||
lumiera_mutex_destroy (LumieraMutex self, struct nobug_flag* flag);
|
||||
lumiera_mutex_destroy (LumieraMutex self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -128,16 +135,19 @@ lumiera_mutex_destroy (LumieraMutex self, struct nobug_flag* flag);
|
|||
* @return self as given
|
||||
*/
|
||||
static inline LumieraMutex
|
||||
lumiera_mutex_lock (LumieraMutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_mutex_lock (LumieraMutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire mutex", *handle, ctx);
|
||||
|
||||
if (pthread_mutex_lock (&self->mutex))
|
||||
LUMIERA_DIE (LOCK_ACQUIRE); /* never reached (in a correct program) */
|
||||
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -152,22 +162,25 @@ lumiera_mutex_lock (LumieraMutex self, struct nobug_flag* flag, struct nobug_res
|
|||
* @return self as given or NULL on error, lumiera_error gets set approbiately
|
||||
*/
|
||||
static inline LumieraMutex
|
||||
lumiera_mutex_trylock (LumieraMutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_mutex_trylock (LumieraMutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire mutex", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_trylock (&self->mutex);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -187,22 +200,23 @@ static inline LumieraMutex
|
|||
lumiera_mutex_timedlock (LumieraMutex self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire mutex", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_timedlock (&self->mutex, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -219,11 +233,14 @@ lumiera_mutex_timedlock (LumieraMutex self,
|
|||
* @param handle pointer to nobug user handle (NULL in beta and release builds)
|
||||
*/
|
||||
static inline void
|
||||
lumiera_mutex_unlock (LumieraMutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_mutex_unlock (LumieraMutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
REQUIRE(self);
|
||||
NOBUG_REQUIRE_CTX (self, ctx);
|
||||
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle)
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx)
|
||||
{
|
||||
if (pthread_mutex_unlock (&self->mutex))
|
||||
LUMIERA_DIE (LOCK_RELEASE); /* never reached (in a correct program) */
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ static void recursive_mutexattr_init()
|
|||
|
||||
|
||||
LumieraReccondition
|
||||
lumiera_reccondition_init (LumieraReccondition self, const char* purpose, struct nobug_flag* flag)
|
||||
lumiera_reccondition_init (LumieraReccondition self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
|
|
@ -49,18 +52,20 @@ lumiera_reccondition_init (LumieraReccondition self, const char* purpose, struct
|
|||
pthread_cond_init (&self->cond, NULL);
|
||||
pthread_mutex_init (&self->reccndmutex, &recursive_mutexattr);
|
||||
NOBUG_RESOURCE_HANDLE_INIT (self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW (flag, "reccond_var", purpose, self, self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "reccond_var", purpose, self, self->rh, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
LumieraReccondition
|
||||
lumiera_reccondition_destroy (LumieraReccondition self, struct nobug_flag* flag)
|
||||
lumiera_reccondition_destroy (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_FORGET_RAW (flag, self->rh);
|
||||
NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx);
|
||||
|
||||
if (pthread_mutex_destroy (&self->reccndmutex))
|
||||
LUMIERA_DIE (LOCK_DESTROY);
|
||||
|
|
|
|||
|
|
@ -44,40 +44,42 @@
|
|||
* @param nobugflag NoBug flag used to log actions on the condition
|
||||
* @param cnd Condition variable to be locked
|
||||
*/
|
||||
#define LUMIERA_RECCONDITION_SECTION(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_reccondition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_reccondition_lock (cnd, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECCONDITION_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RECCONDITION_SECTION(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_reccondition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_reccondition_lock (cnd, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECCONDITION_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
||||
#define LUMIERA_RECCONDITION_SECTION_CHAIN(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_reccondition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_reccondition_lock (cnd, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECCONDITION_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RECCONDITION_SECTION_CHAIN(nobugflag, cnd) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
cnd, (lumiera_sectionlock_unlock_fn) lumiera_reccondition_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_reccondition_lock (cnd, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECCONDITION_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -95,8 +97,9 @@
|
|||
REQUIRE (lumiera_lock_section_.lock, "Reccondition mutex not locked"); \
|
||||
lumiera_reccondition_wait (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag, \
|
||||
&lumiera_lock_section_.rh); \
|
||||
}
|
||||
&lumiera_lock_section_.rh, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (!(expr))
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +115,8 @@
|
|||
if (!lumiera_reccondition_timedwait (lumiera_lock_section_.lock, \
|
||||
timeout, \
|
||||
lumiera_lock_section_.flag, \
|
||||
&lumiera_lock_section_.rh)) \
|
||||
&lumiera_lock_section_.rh, \
|
||||
NOBUG_CONTEXT)) \
|
||||
break; \
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +131,8 @@
|
|||
do { \
|
||||
REQUIRE (lumiera_lock_section_.lock, "Reccondition mutex not locked"); \
|
||||
lumiera_reccondition_signal (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag); \
|
||||
lumiera_lock_section_.flag, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
|
@ -140,7 +145,8 @@
|
|||
do { \
|
||||
REQUIRE (lumiera_lock_section_.lock, "Reccondition mutex not locked"); \
|
||||
lumiera_reccondition_broadcast (lumiera_lock_section_.lock, \
|
||||
lumiera_lock_section_.flag); \
|
||||
lumiera_lock_section_.flag, \
|
||||
NOBUG_CONTEXT); \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
|
@ -164,7 +170,10 @@ typedef lumiera_reccondition* LumieraReccondition;
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraReccondition
|
||||
lumiera_reccondition_init (LumieraReccondition self, const char* purpose, struct nobug_flag* flag);
|
||||
lumiera_reccondition_init (LumieraReccondition self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -173,21 +182,26 @@ lumiera_reccondition_init (LumieraReccondition self, const char* purpose, struct
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraReccondition
|
||||
lumiera_reccondition_destroy (LumieraReccondition self, struct nobug_flag* flag);
|
||||
lumiera_reccondition_destroy (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
|
||||
static inline LumieraReccondition
|
||||
lumiera_reccondition_lock (LumieraReccondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_reccondition_lock (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire reccondvar", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire reccondvar", *handle, ctx);
|
||||
|
||||
if (pthread_mutex_lock (&self->reccndmutex))
|
||||
LUMIERA_DIE (LOCK_ACQUIRE); /* never reached (in a correct program) */
|
||||
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -195,22 +209,25 @@ lumiera_reccondition_lock (LumieraReccondition self, struct nobug_flag* flag, st
|
|||
|
||||
|
||||
static inline LumieraReccondition
|
||||
lumiera_reccondition_trylock (LumieraReccondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_reccondition_trylock (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire reccondvar", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire reccondvar", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_trylock (&self->reccndmutex);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -223,22 +240,23 @@ static inline LumieraReccondition
|
|||
lumiera_reccondition_timedlock (LumieraReccondition self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire reccondvar", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire reccondvar", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_timedlock (&self->reccndmutex, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -248,15 +266,18 @@ lumiera_reccondition_timedlock (LumieraReccondition self,
|
|||
|
||||
|
||||
static inline LumieraReccondition
|
||||
lumiera_reccondition_wait (LumieraReccondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_reccondition_wait (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_WAITING, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_WAITING, *handle, ctx);
|
||||
|
||||
pthread_cond_wait (&self->cond, &self->reccndmutex);
|
||||
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -266,22 +287,23 @@ static inline LumieraReccondition
|
|||
lumiera_reccondition_timedwait (LumieraReccondition self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_WAITING, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_WAITING, *handle, ctx);
|
||||
|
||||
int err;
|
||||
do {
|
||||
err = pthread_cond_timedwait (&self->cond, &self->reccndmutex, timeout);
|
||||
} while(err == EINTR);
|
||||
|
||||
NOBUG_RESOURCE_STATE_RAW (flag, NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_RAW_CTX (flag, NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
|
||||
if (err)
|
||||
{
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -292,27 +314,34 @@ lumiera_reccondition_timedwait (LumieraReccondition self,
|
|||
|
||||
|
||||
static inline void
|
||||
lumiera_reccondition_signal (LumieraReccondition self, struct nobug_flag* flag)
|
||||
lumiera_reccondition_signal (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
TRACE(NOBUG_FLAG_RAW(flag), "Signal %p", self);
|
||||
NOBUG_TRACE_CTX (NOBUG_FLAG_RAW (flag), ctx, "Signal %p", self);
|
||||
pthread_cond_signal (&self->cond);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
lumiera_reccondition_broadcast (LumieraReccondition self, struct nobug_flag* flag)
|
||||
lumiera_reccondition_broadcast (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
TRACE(NOBUG_FLAG_RAW(flag), "Broadcast %p", self);
|
||||
NOBUG_TRACE_CTX (NOBUG_FLAG_RAW(flag), ctx, "Broadcast %p", self);
|
||||
pthread_cond_broadcast (&self->cond);
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
lumiera_reccondition_unlock (LumieraReccondition self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_reccondition_unlock (LumieraReccondition self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
REQUIRE(self);
|
||||
NOBUG_REQUIRE_CTX (self, ctx);
|
||||
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle)
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx)
|
||||
{
|
||||
if (pthread_mutex_unlock (&self->reccndmutex))
|
||||
LUMIERA_DIE (LOCK_RELEASE); /* never reached (in a correct program) */
|
||||
|
|
|
|||
|
|
@ -38,7 +38,10 @@ static void recmutexattr_init()
|
|||
|
||||
|
||||
LumieraRecmutex
|
||||
lumiera_recmutex_init (LumieraRecmutex self, const char* purpose, struct nobug_flag* flag)
|
||||
lumiera_recmutex_init (LumieraRecmutex self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
|
|
@ -46,7 +49,7 @@ lumiera_recmutex_init (LumieraRecmutex self, const char* purpose, struct nobug_f
|
|||
|
||||
pthread_mutex_init (&self->recmutex, &recmutexattr);
|
||||
NOBUG_RESOURCE_HANDLE_INIT (self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW (flag, "recmutex", purpose, self, self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "recmutex", purpose, self, self->rh, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -54,11 +57,13 @@ lumiera_recmutex_init (LumieraRecmutex self, const char* purpose, struct nobug_f
|
|||
|
||||
|
||||
LumieraRecmutex
|
||||
lumiera_recmutex_destroy (LumieraRecmutex self, struct nobug_flag* flag)
|
||||
lumiera_recmutex_destroy (LumieraRecmutex self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_FORGET_RAW (flag, self->rh);
|
||||
NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx);
|
||||
if (pthread_mutex_destroy (&self->recmutex))
|
||||
LUMIERA_DIE (LOCK_DESTROY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,39 +38,41 @@
|
|||
/**
|
||||
* Recursive Mutual exclusive section.
|
||||
*/
|
||||
#define LUMIERA_RECMUTEX_SECTION(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RECMUTEX_SECTION(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
#define LUMIERA_RECMUTEX_SECTION_CHAIN(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RECMUTEX_SECTION_CHAIN(nobugflag, mtx) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
mtx, (lumiera_sectionlock_unlock_fn) lumiera_mutex_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_recmutex_lock (mtx, &NOBUG_FLAG(nobugflag), \
|
||||
lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RECMUTEX_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -98,7 +100,10 @@ typedef lumiera_recmutex* LumieraRecmutex;
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraRecmutex
|
||||
lumiera_recmutex_init (LumieraRecmutex self, const char* purpose, struct nobug_flag* flag);
|
||||
lumiera_recmutex_init (LumieraRecmutex self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
/**
|
||||
* Destroy a recursive mutex variable
|
||||
|
|
@ -106,20 +111,25 @@ lumiera_recmutex_init (LumieraRecmutex self, const char* purpose, struct nobug_f
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraRecmutex
|
||||
lumiera_recmutex_destroy (LumieraRecmutex self, struct nobug_flag* flag);
|
||||
lumiera_recmutex_destroy (LumieraRecmutex self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
static inline LumieraRecmutex
|
||||
lumiera_recmutex_lock (LumieraRecmutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_recmutex_lock (LumieraRecmutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire mutex", *handle, ctx);
|
||||
|
||||
if (pthread_mutex_lock (&self->recmutex))
|
||||
LUMIERA_DIE (LOCK_ACQUIRE); /* never reached (in a correct program) */
|
||||
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -127,22 +137,25 @@ lumiera_recmutex_lock (LumieraRecmutex self, struct nobug_flag* flag, struct nob
|
|||
|
||||
|
||||
static inline LumieraRecmutex
|
||||
lumiera_recmutex_trylock (LumieraRecmutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_recmutex_trylock (LumieraRecmutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire mutex", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_trylock (&self->recmutex);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -155,22 +168,23 @@ static inline LumieraRecmutex
|
|||
lumiera_recmutex_timedlock (LumieraRecmutex self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire mutex", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire mutex", *handle, ctx);
|
||||
|
||||
int err = pthread_mutex_timedlock (&self->recmutex, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_RECURSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -180,11 +194,14 @@ lumiera_recmutex_timedlock (LumieraRecmutex self,
|
|||
|
||||
|
||||
static inline void
|
||||
lumiera_recmutex_unlock (LumieraRecmutex self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_recmutex_unlock (LumieraRecmutex self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
REQUIRE (self);
|
||||
NOBUG_REQUIRE_CTX (self, ctx);
|
||||
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle)
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx)
|
||||
{
|
||||
if (pthread_mutex_unlock (&self->recmutex))
|
||||
LUMIERA_DIE (LOCK_RELEASE); /* never reached (in a correct program) */
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ lumiera_resourcecollector_init_ (void)
|
|||
for (int i = 0; i < LUMIERA_RESOURCE_END; ++i)
|
||||
llist_init (&lumiera_resourcecollector_registry[i]);
|
||||
|
||||
lumiera_mutex_init (&lumiera_resourcecollector_lock, "resourcecollector", &NOBUG_FLAG(mutex_dbg));
|
||||
lumiera_mutex_init (&lumiera_resourcecollector_lock, "resourcecollector", &NOBUG_FLAG(mutex_dbg), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ lumiera_resourcecollector_destroy (void)
|
|||
LLIST_WHILE_HEAD (&lumiera_resourcecollector_registry[i], head)
|
||||
lumiera_resourcehandler_unregister ((LumieraResourcehandler)head);
|
||||
|
||||
lumiera_mutex_destroy (&lumiera_resourcecollector_lock, &NOBUG_FLAG(mutex_dbg));
|
||||
lumiera_mutex_destroy (&lumiera_resourcecollector_lock, &NOBUG_FLAG(mutex_dbg), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,24 +29,29 @@
|
|||
*/
|
||||
|
||||
LumieraRWLock
|
||||
lumiera_rwlock_init (LumieraRWLock self, const char* purpose, struct nobug_flag* flag)
|
||||
lumiera_rwlock_init (LumieraRWLock self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
pthread_rwlock_init (&self->rwlock, NULL);
|
||||
NOBUG_RESOURCE_HANDLE_INIT (self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW (flag, "rwlock", purpose, self, self->rh);
|
||||
NOBUG_RESOURCE_ANNOUNCE_RAW_CTX (flag, "rwlock", purpose, self, self->rh, ctx);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
LumieraRWLock
|
||||
lumiera_rwlock_destroy (LumieraRWLock self, struct nobug_flag* flag)
|
||||
lumiera_rwlock_destroy (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_FORGET_RAW (flag, self->rh);
|
||||
NOBUG_RESOURCE_FORGET_RAW_CTX (flag, self->rh, ctx);
|
||||
if (pthread_rwlock_destroy (&self->rwlock))
|
||||
LUMIERA_DIE (LOCK_DESTROY);
|
||||
}
|
||||
|
|
|
|||
213
src/lib/rwlock.h
213
src/lib/rwlock.h
|
|
@ -44,39 +44,41 @@
|
|||
* Read locked section.
|
||||
* readlocks may fail when there are too much readers, one has to check the error afterwards!
|
||||
*/
|
||||
#define LUMIERA_RDLOCK_SECTION(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RDLOCK_SECTION(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
#define LUMIERA_RDLOCK_SECTION_CHAIN(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
#define LUMIERA_RDLOCK_SECTION_CHAIN(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_rdlock (rwlck, &NOBUG_FLAG(nobugflag), \
|
||||
lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -84,39 +86,41 @@
|
|||
/**
|
||||
* Write locked section.
|
||||
*/
|
||||
#define LUMIERA_WRLOCK_SECTION(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), &lumiera_lock_section_.rh); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
#define LUMIERA_WRLOCK_SECTION(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) \
|
||||
lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), \
|
||||
&lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
#define LUMIERA_WRLOCK_SECTION_CHAIN(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), lumiera_lock_section_.rh); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
#define LUMIERA_WRLOCK_SECTION_CHAIN(nobugflag, rwlck) \
|
||||
for (lumiera_sectionlock *lumiera_lock_section_old_ = &lumiera_lock_section_, \
|
||||
NOBUG_CLEANUP(lumiera_sectionlock_ensureunlocked) lumiera_lock_section_ = { \
|
||||
rwlck, (lumiera_sectionlock_unlock_fn) lumiera_rwlock_unlock \
|
||||
NOBUG_ALPHA_COMMA(&NOBUG_FLAG(nobugflag)) NOBUG_ALPHA_COMMA_NULL}; \
|
||||
({ \
|
||||
if (lumiera_lock_section_.lock) \
|
||||
{ \
|
||||
REQUIRE (lumiera_lock_section_old_->lock, "section prematurely unlocked"); \
|
||||
lumiera_lock_section_.lock = \
|
||||
lumiera_rwlock_wrlock (rwlck, &NOBUG_FLAG(nobugflag), \
|
||||
lumiera_lock_section_.rh, NOBUG_CONTEXT); \
|
||||
LUMIERA_SECTION_UNLOCK_(lumiera_lock_section_old_); \
|
||||
} \
|
||||
lumiera_lock_section_.lock; \
|
||||
}); \
|
||||
({ \
|
||||
LUMIERA_RWLOCK_SECTION_UNLOCK; \
|
||||
}))
|
||||
|
||||
|
||||
|
|
@ -142,7 +146,10 @@ typedef lumiera_rwlock* LumieraRWLock;
|
|||
* @return self as given
|
||||
*/
|
||||
LumieraRWLock
|
||||
lumiera_rwlock_init (LumieraRWLock self, const char* purpose, struct nobug_flag* flag);
|
||||
lumiera_rwlock_init (LumieraRWLock self,
|
||||
const char* purpose,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
/**
|
||||
* destroy a rwlock
|
||||
|
|
@ -150,25 +157,31 @@ lumiera_rwlock_init (LumieraRWLock self, const char* purpose, struct nobug_flag*
|
|||
* @return self on success or NULL at error
|
||||
*/
|
||||
LumieraRWLock
|
||||
lumiera_rwlock_destroy (LumieraRWLock self, struct nobug_flag* flag);
|
||||
lumiera_rwlock_destroy (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
|
||||
static inline LumieraRWLock
|
||||
lumiera_rwlock_rdlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_rwlock_rdlock (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire rwlock for reading", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire rwlock for reading", *handle, ctx);
|
||||
|
||||
int err = pthread_rwlock_rdlock (&self->rwlock);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -178,22 +191,25 @@ lumiera_rwlock_rdlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug
|
|||
|
||||
|
||||
static inline LumieraRWLock
|
||||
lumiera_rwlock_tryrdlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_rwlock_tryrdlock (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire rwlock for reading", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire rwlock for reading", *handle, ctx);
|
||||
|
||||
int err = pthread_rwlock_tryrdlock (&self->rwlock);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -206,22 +222,23 @@ static inline LumieraRWLock
|
|||
lumiera_rwlock_timedrdlock (LumieraRWLock self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire rwlock for reading", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire rwlock for reading", *handle, ctx);
|
||||
|
||||
int err = pthread_rwlock_timedrdlock (&self->rwlock, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_SHARED, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -231,16 +248,19 @@ lumiera_rwlock_timedrdlock (LumieraRWLock self,
|
|||
|
||||
|
||||
static inline LumieraRWLock
|
||||
lumiera_rwlock_wrlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_rwlock_wrlock (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
RESOURCE_WAIT (NOBUG_FLAG_RAW(flag), self->rh, "acquire rwlock for writing", *handle);
|
||||
NOBUG_RESOURCE_WAIT_CTX (NOBUG_FLAG_RAW(flag), self->rh, "acquire rwlock for writing", *handle, ctx);
|
||||
|
||||
if (pthread_rwlock_wrlock (&self->rwlock))
|
||||
LUMIERA_DIE (LOCK_ACQUIRE); /* never reached (in a correct program) */
|
||||
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
|
||||
return self;
|
||||
|
|
@ -248,22 +268,25 @@ lumiera_rwlock_wrlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug
|
|||
|
||||
|
||||
static inline LumieraRWLock
|
||||
lumiera_rwlock_trywrlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_rwlock_trywrlock (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "try acquire rwlock for writing", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "try acquire rwlock for writing", *handle, ctx);
|
||||
|
||||
int err = pthread_rwlock_trywrlock (&self->rwlock);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -276,22 +299,23 @@ static inline LumieraRWLock
|
|||
lumiera_rwlock_timedwrlock (LumieraRWLock self,
|
||||
const struct timespec* timeout,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle)
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
if (self)
|
||||
{
|
||||
NOBUG_RESOURCE_TRY (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire rwlock for writing", *handle);
|
||||
NOBUG_RESOURCE_TRY_CTX (NOBUG_FLAG_RAW(flag), self->rh, "timed acquire rwlock for writing", *handle, ctx);
|
||||
|
||||
int err = pthread_rwlock_timedwrlock (&self->rwlock, timeout);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
RESOURCE_STATE (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle);
|
||||
NOBUG_RESOURCE_STATE_CTX (NOBUG_FLAG_RAW(flag), NOBUG_RESOURCE_EXCLUSIVE, *handle, ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, __func__);
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx) /*{}*/;
|
||||
lumiera_lockerror_set (err, flag, ctx);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -301,11 +325,14 @@ lumiera_rwlock_timedwrlock (LumieraRWLock self,
|
|||
|
||||
|
||||
static inline void
|
||||
lumiera_rwlock_unlock (LumieraRWLock self, struct nobug_flag* flag, struct nobug_resource_user** handle)
|
||||
lumiera_rwlock_unlock (LumieraRWLock self,
|
||||
struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx)
|
||||
{
|
||||
REQUIRE(self);
|
||||
NOBUG_REQUIRE_CTX (self, ctx);
|
||||
|
||||
NOBUG_RESOURCE_LEAVE_RAW(flag, *handle)
|
||||
NOBUG_RESOURCE_LEAVE_RAW_CTX (flag, *handle, ctx)
|
||||
{
|
||||
if (pthread_rwlock_unlock (&self->rwlock))
|
||||
LUMIERA_DIE (LOCK_RELEASE); /* never reached (in a correct program) */
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@
|
|||
#include <nobug.h>
|
||||
|
||||
|
||||
typedef int (*lumiera_sectionlock_unlock_fn)(void*, struct nobug_flag* flag, struct nobug_resource_user** handle);
|
||||
typedef int
|
||||
(*lumiera_sectionlock_unlock_fn)(void*, struct nobug_flag* flag,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx);
|
||||
|
||||
/**
|
||||
* sectionlock used to manage the state of mutexes.
|
||||
|
|
@ -55,11 +58,12 @@ lumiera_sectionlock_ensureunlocked (LumieraSectionlock self)
|
|||
* @param sectionname name used for the sectionlock instance
|
||||
* @param ... some extra code to execute
|
||||
*/
|
||||
#define LUMIERA_SECTION_UNLOCK_(section) \
|
||||
do if ((section)->lock) \
|
||||
{ \
|
||||
(section)->unlock((section)->lock, (section)->flag, &(section)->rh); \
|
||||
(section)->lock = NULL; \
|
||||
#define LUMIERA_SECTION_UNLOCK_(section) \
|
||||
do if ((section)->lock) \
|
||||
{ \
|
||||
(section)->unlock((section)->lock, (section)->flag, \
|
||||
&(section)->rh, NOBUG_CONTEXT); \
|
||||
(section)->lock = NULL; \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
|
|
|||
133
src/lib/sync.hpp
133
src/lib/sync.hpp
|
|
@ -97,27 +97,31 @@ namespace lib {
|
|||
lumiera_mutex self;
|
||||
|
||||
protected:
|
||||
Wrapped_LumieraExcMutex() { lumiera_mutex_init (&self, "Obj.Monitor ExclMutex", &NOBUG_FLAG(sync)); }
|
||||
~Wrapped_LumieraExcMutex() { lumiera_mutex_destroy (&self, &NOBUG_FLAG(sync)); }
|
||||
Wrapped_LumieraExcMutex(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{ lumiera_mutex_init (&self, "Obj.Monitor ExclMutex", &NOBUG_FLAG(sync), ctx); }
|
||||
~Wrapped_LumieraExcMutex()
|
||||
{ lumiera_mutex_destroy (&self, &NOBUG_FLAG(sync), NOBUG_CONTEXT); }
|
||||
|
||||
bool lock (struct nobug_resource_user** handle)
|
||||
bool lock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_mutex_lock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_mutex_lock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool trylock (struct nobug_resource_user** handle)
|
||||
bool trylock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_mutex_trylock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_mutex_trylock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedlock (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedlock (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_mutex_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_mutex_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
void unlock (struct nobug_resource_user** handle)
|
||||
void unlock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_mutex_unlock (&self, &NOBUG_FLAG(sync), handle);
|
||||
lumiera_mutex_unlock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
LumieraReccondition myreccond () {throw "bullshit"; return NULL;} // placeholder, brainstorm
|
||||
|
|
@ -128,27 +132,32 @@ namespace lib {
|
|||
{
|
||||
lumiera_recmutex self;
|
||||
protected:
|
||||
Wrapped_LumieraRecMutex() { lumiera_recmutex_init (&self, "Obj.Monitor RecMutex", &NOBUG_FLAG(sync)); }
|
||||
~Wrapped_LumieraRecMutex() { lumiera_recmutex_destroy (&self, &NOBUG_FLAG(sync)); }
|
||||
Wrapped_LumieraRecMutex(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{ lumiera_recmutex_init (&self, "Obj.Monitor RecMutex", &NOBUG_FLAG(sync), ctx); }
|
||||
~Wrapped_LumieraRecMutex()
|
||||
{ lumiera_recmutex_destroy (&self, &NOBUG_FLAG(sync), NOBUG_CONTEXT); }
|
||||
|
||||
bool lock (struct nobug_resource_user** handle)
|
||||
bool lock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_recmutex_lock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_recmutex_lock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool trylock (struct nobug_resource_user** handle)
|
||||
bool trylock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_recmutex_trylock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_recmutex_trylock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedlock (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedlock (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_recmutex_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_recmutex_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
void unlock (struct nobug_resource_user** handle)
|
||||
void unlock (struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_recmutex_unlock (&self, &NOBUG_FLAG(sync), handle);
|
||||
lumiera_recmutex_unlock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
LumieraReccondition myreccond () {throw "bullshit"; return NULL;} // placeholder, brainstorm
|
||||
|
|
@ -159,47 +168,53 @@ namespace lib {
|
|||
{
|
||||
lumiera_condition self;
|
||||
protected:
|
||||
Wrapped_LumieraExcCond() { lumiera_condition_init (&self, "Obj.Monitor ExclCondition", &NOBUG_FLAG(sync) ); }
|
||||
~Wrapped_LumieraExcCond() { lumiera_condition_destroy (&self, &NOBUG_FLAG(sync) ); }
|
||||
Wrapped_LumieraExcCond(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{ lumiera_condition_init (&self, "Obj.Monitor ExclCondition", &NOBUG_FLAG(sync), ctx); }
|
||||
~Wrapped_LumieraExcCond()
|
||||
{ lumiera_condition_destroy (&self, &NOBUG_FLAG(sync), NOBUG_CONTEXT); }
|
||||
|
||||
bool lock (struct nobug_resource_user** handle)
|
||||
bool lock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_condition_lock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_condition_lock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool trylock (struct nobug_resource_user** handle)
|
||||
bool trylock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_condition_trylock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_condition_trylock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedlock (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedlock (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_condition_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_condition_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool wait (struct nobug_resource_user** handle)
|
||||
bool wait (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_condition_wait (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_condition_wait (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedwait (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedwait (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_condition_timedwait (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_condition_timedwait (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
void signal()
|
||||
void signal(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_condition_signal (&self, &NOBUG_FLAG(sync));
|
||||
lumiera_condition_signal (&self, &NOBUG_FLAG(sync), ctx);
|
||||
}
|
||||
|
||||
void broadcast()
|
||||
void broadcast(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_condition_broadcast (&self, &NOBUG_FLAG(sync));
|
||||
lumiera_condition_broadcast (&self, &NOBUG_FLAG(sync), ctx);
|
||||
}
|
||||
|
||||
void unlock (struct nobug_resource_user** handle)
|
||||
void unlock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_condition_unlock (&self, &NOBUG_FLAG(sync), handle);
|
||||
lumiera_condition_unlock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
LumieraReccondition myreccond () {throw "bullshit"; return NULL;} // placeholder, brainstorm
|
||||
|
|
@ -210,47 +225,53 @@ namespace lib {
|
|||
{
|
||||
lumiera_reccondition self;
|
||||
protected:
|
||||
Wrapped_LumieraRecCond() { lumiera_reccondition_init (&self, "Obj.Monitor RecCondition", &NOBUG_FLAG(sync) ); }
|
||||
~Wrapped_LumieraRecCond() { lumiera_reccondition_destroy (&self, &NOBUG_FLAG(sync) ); }
|
||||
Wrapped_LumieraRecCond(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{ lumiera_reccondition_init (&self, "Obj.Monitor RecCondition", &NOBUG_FLAG(sync), ctx); }
|
||||
~Wrapped_LumieraRecCond()
|
||||
{ lumiera_reccondition_destroy (&self, &NOBUG_FLAG(sync), NOBUG_CONTEXT); }
|
||||
|
||||
bool lock (struct nobug_resource_user** handle)
|
||||
bool lock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_reccondition_lock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_reccondition_lock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool trylock (struct nobug_resource_user** handle)
|
||||
bool trylock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_reccondition_trylock (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_reccondition_trylock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedlock (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedlock (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_reccondition_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_reccondition_timedlock (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool wait (struct nobug_resource_user** handle)
|
||||
bool wait (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_reccondition_wait (&self, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_reccondition_wait (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
bool timedwait (const struct timespec* timeout, struct nobug_resource_user** handle)
|
||||
bool timedwait (const struct timespec* timeout,
|
||||
struct nobug_resource_user** handle,
|
||||
const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
return !!lumiera_reccondition_timedwait (&self, timeout, &NOBUG_FLAG(sync), handle);
|
||||
return !!lumiera_reccondition_timedwait (&self, timeout, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
void signal()
|
||||
void signal(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_reccondition_signal (&self, &NOBUG_FLAG(sync));
|
||||
lumiera_reccondition_signal (&self, &NOBUG_FLAG(sync), ctx);
|
||||
}
|
||||
|
||||
void broadcast()
|
||||
void broadcast(const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_reccondition_broadcast (&self, &NOBUG_FLAG(sync));
|
||||
lumiera_reccondition_broadcast (&self, &NOBUG_FLAG(sync), ctx);
|
||||
}
|
||||
|
||||
void unlock (struct nobug_resource_user** handle)
|
||||
void unlock (struct nobug_resource_user** handle, const struct nobug_context ctx = NOBUG_CONTEXT_NOFUNC)
|
||||
{
|
||||
lumiera_reccondition_unlock (&self, &NOBUG_FLAG(sync), handle);
|
||||
lumiera_reccondition_unlock (&self, &NOBUG_FLAG(sync), handle, ctx);
|
||||
}
|
||||
|
||||
LumieraReccondition myreccond () { return &self;} // placeholder, brainstorm
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ TEST ("simple_thread")
|
|||
TEST ("thread_synced")
|
||||
{
|
||||
lumiera_condition cnd;
|
||||
lumiera_condition_init (&cnd, "threadsync", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_init (&cnd, "threadsync", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_CONDITION_SECTION(cond_sync, &cnd)
|
||||
{
|
||||
|
|
@ -125,14 +125,14 @@ TEST ("thread_synced")
|
|||
ECHO ("thread ended %s", NOBUG_THREAD_ID_GET);
|
||||
}
|
||||
|
||||
lumiera_condition_destroy (&cnd, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_destroy (&cnd, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST ("mutex_thread")
|
||||
{
|
||||
lumiera_mutex_init (&testmutex, "test", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&testmutex, "test", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &testmutex)
|
||||
{
|
||||
|
|
@ -149,7 +149,7 @@ TEST ("mutex_thread")
|
|||
fprintf (stderr, "main after thread %s\n", NOBUG_THREAD_ID_GET);
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&testmutex, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&testmutex, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ TESTS_BEGIN
|
|||
TEST ("mutexsection")
|
||||
{
|
||||
lumiera_mutex m;
|
||||
lumiera_mutex_init (&m, "mutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&m, "mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &m)
|
||||
{
|
||||
|
|
@ -47,28 +47,28 @@ TEST ("mutexsection")
|
|||
printf ("mutex locked section 2\n");
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("mutexforgotunlock")
|
||||
{
|
||||
lumiera_mutex m;
|
||||
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &m)
|
||||
{
|
||||
break; // MUTEX_SECTIONS must not be left by a jump
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("mutexexplicitunlock")
|
||||
{
|
||||
lumiera_mutex m;
|
||||
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&m, "mutexforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &m)
|
||||
{
|
||||
|
|
@ -77,17 +77,17 @@ TEST ("mutexexplicitunlock")
|
|||
break;
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("nestedmutexsection")
|
||||
{
|
||||
lumiera_mutex m;
|
||||
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
lumiera_mutex n;
|
||||
lumiera_mutex_init (&n, "n_mutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&n, "n_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &m)
|
||||
{
|
||||
|
|
@ -99,17 +99,17 @@ TEST ("nestedmutexsection")
|
|||
}
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&n, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&n, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
TEST ("chainedmutexsection")
|
||||
{
|
||||
lumiera_mutex m;
|
||||
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&m, "m_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
lumiera_mutex n;
|
||||
lumiera_mutex_init (&n, "n_mutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_init (&n, "n_mutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_MUTEX_SECTION (NOBUG_ON, &m)
|
||||
{
|
||||
|
|
@ -121,8 +121,8 @@ TEST ("chainedmutexsection")
|
|||
}
|
||||
}
|
||||
|
||||
lumiera_mutex_destroy (&n, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_mutex_destroy (&n, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_mutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ TEST ("chainedmutexsection")
|
|||
TEST ("recursivemutexsection")
|
||||
{
|
||||
lumiera_recmutex m;
|
||||
lumiera_recmutex_init (&m, "m_recmutexsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_recmutex_init (&m, "m_recmutexsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
|
||||
LUMIERA_RECMUTEX_SECTION (NOBUG_ON, &m)
|
||||
|
|
@ -143,7 +143,7 @@ TEST ("recursivemutexsection")
|
|||
}
|
||||
}
|
||||
|
||||
lumiera_recmutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_recmutex_destroy (&m, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ TEST ("recursivemutexsection")
|
|||
TEST ("rwlocksection")
|
||||
{
|
||||
lumiera_rwlock rwlock;
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_WRLOCK_SECTION (NOBUG_ON, &rwlock)
|
||||
{
|
||||
|
|
@ -163,21 +163,21 @@ TEST ("rwlocksection")
|
|||
printf ("read locked section 2\n");
|
||||
}
|
||||
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("rwlockforgotunlock")
|
||||
{
|
||||
lumiera_rwlock rwlock;
|
||||
lumiera_rwlock_init (&rwlock, "rwlockforgotunlock", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_init (&rwlock, "rwlockforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RDLOCK_SECTION (NOBUG_ON, &rwlock)
|
||||
{
|
||||
break; // LOCK_SECTIONS must not be left by a jump
|
||||
}
|
||||
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ TEST ("rwlockforgotunlock")
|
|||
TEST ("rwdeadlockwr")
|
||||
{
|
||||
lumiera_rwlock rwlock;
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_WRLOCK_SECTION (NOBUG_ON, &rwlock)
|
||||
{
|
||||
|
|
@ -196,7 +196,7 @@ TEST ("rwdeadlockwr")
|
|||
}
|
||||
}
|
||||
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ TEST ("rwdeadlockwr")
|
|||
TEST ("rwdeadlockrw")
|
||||
{
|
||||
lumiera_rwlock rwlock;
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_init (&rwlock, "rwsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RDLOCK_SECTION (NOBUG_ON, &rwlock)
|
||||
{
|
||||
|
|
@ -215,14 +215,14 @@ TEST ("rwdeadlockrw")
|
|||
}
|
||||
}
|
||||
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_rwlock_destroy (&rwlock, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("conditionops (compiletest only)")
|
||||
{
|
||||
lumiera_condition cond;
|
||||
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_CONDITION_SECTION (NOBUG_ON, &cond)
|
||||
{
|
||||
|
|
@ -231,14 +231,14 @@ TEST ("conditionops (compiletest only)")
|
|||
LUMIERA_CONDITION_BROADCAST;
|
||||
}
|
||||
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("conditionsection")
|
||||
{
|
||||
lumiera_condition cond;
|
||||
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_init (&cond, "conditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_CONDITION_SECTION (NOBUG_ON, &cond)
|
||||
{
|
||||
|
|
@ -250,7 +250,7 @@ TEST ("conditionsection")
|
|||
printf ("condition locked section 2\n");
|
||||
}
|
||||
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -258,14 +258,14 @@ TEST ("conditionsection")
|
|||
TEST ("conditionforgotunlock")
|
||||
{
|
||||
lumiera_condition cond;
|
||||
lumiera_condition_init (&cond, "conditionforgotunlock", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_init (&cond, "conditionforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_CONDITION_SECTION (NOBUG_ON, &cond)
|
||||
{
|
||||
break; // CONDITION_SECTIONS must not be left by a jump
|
||||
}
|
||||
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_condition_destroy (&cond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ TEST ("conditionforgotunlock")
|
|||
TEST ("recconditionops (compiletest only)")
|
||||
{
|
||||
lumiera_reccondition reccond;
|
||||
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION (NOBUG_ON, &reccond)
|
||||
{
|
||||
|
|
@ -282,14 +282,14 @@ TEST ("recconditionops (compiletest only)")
|
|||
LUMIERA_RECCONDITION_BROADCAST;
|
||||
}
|
||||
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("recconditionsection")
|
||||
{
|
||||
lumiera_reccondition reccond;
|
||||
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&reccond, "recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION (NOBUG_ON, &reccond)
|
||||
{
|
||||
|
|
@ -301,28 +301,28 @@ TEST ("recconditionsection")
|
|||
printf ("reccondition locked section 2\n");
|
||||
}
|
||||
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
TEST ("recconditionforgotunlock")
|
||||
{
|
||||
lumiera_reccondition reccond;
|
||||
lumiera_reccondition_init (&reccond, "recconditionforgotunlock", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&reccond, "recconditionforgotunlock", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION (NOBUG_ON, &reccond)
|
||||
{
|
||||
break; // RECCONDITION_SECTIONS must not be left by a jump
|
||||
}
|
||||
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&reccond, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
TEST ("chainedrecconditionsection")
|
||||
{
|
||||
lumiera_reccondition outer, inner;
|
||||
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&inner, "inner_recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_reccondition_init (&inner, "inner_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION (NOBUG_ON, &outer)
|
||||
{
|
||||
|
|
@ -332,15 +332,15 @@ TEST ("chainedrecconditionsection")
|
|||
printf ("inner reccondition locked section\n");
|
||||
}
|
||||
}
|
||||
lumiera_reccondition_destroy (&outer, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&inner, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&outer, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_reccondition_destroy (&inner, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
TEST ("nestedrecconditionsection")
|
||||
{
|
||||
lumiera_reccondition outer, inner;
|
||||
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&inner, "inner_recconditionsection", &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_init (&outer, "outer_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_reccondition_init (&inner, "inner_recconditionsection", &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
|
||||
LUMIERA_RECCONDITION_SECTION (NOBUG_ON, &outer)
|
||||
{
|
||||
|
|
@ -350,8 +350,8 @@ TEST ("nestedrecconditionsection")
|
|||
printf ("inner reccondition locked section\n");
|
||||
}
|
||||
}
|
||||
lumiera_reccondition_destroy (&outer, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&inner, &NOBUG_FLAG(NOBUG_ON));
|
||||
lumiera_reccondition_destroy (&outer, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
lumiera_reccondition_destroy (&inner, &NOBUG_FLAG(NOBUG_ON), NOBUG_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue