Hello folks,
Could you please help?
1. Is it possible to add to a thread safe linked list using CAS
without a busy loop?
void add_site(LogSite* log_site) {
LogSite** p_site_head = (LogSite**) &get_logger()->log_site;
LogSite* old_value = *p_site_head;
do {
log_site->next = (LogSite*) old_value;
(LogSite*) old_value = (LogSite*) apr_atomic_casptr((volatile
void **) p_site_head,
(void*) log_site, log_site->next);
} while (old_value != log_site->next); // busy loop
}
2. Is it possible to create an auto-increment macro within a
compilation unit using C preprocessor?
#define INC() ...
INC() // == 1
INC() // == 2
...
Thank you for sharing your expertise.
--
With best regards,
Alexei