本文整理汇总了C++中APR_RING_NEXT函数的典型用法代码示例。如果您正苦于以下问题:C++ APR_RING_NEXT函数的具体用法?C++ APR_RING_NEXT怎么用?C++ APR_RING_NEXT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了APR_RING_NEXT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove_tasks
static apr_status_t remove_tasks(apr_thread_pool_t *me, void *owner)
{
apr_thread_pool_task_t *t_loc;
apr_thread_pool_task_t *next;
int seg;
t_loc = APR_RING_FIRST(me->tasks);
while (t_loc != APR_RING_SENTINEL(me->tasks, apr_thread_pool_task, link)) {
next = APR_RING_NEXT(t_loc, link);
if (t_loc->owner == owner) {
--me->task_cnt;
seg = TASK_PRIORITY_SEG(t_loc);
if (t_loc == me->task_idx[seg]) {
me->task_idx[seg] = APR_RING_NEXT(t_loc, link);
if (me->task_idx[seg] == APR_RING_SENTINEL(me->tasks,
apr_thread_pool_task,
link)
|| TASK_PRIORITY_SEG(me->task_idx[seg]) != seg) {
me->task_idx[seg] = NULL;
}
}
APR_RING_REMOVE(t_loc, link);
}
t_loc = next;
}
return APR_SUCCESS;
}
示例2: mmap_cleanup
static apr_status_t mmap_cleanup(void *themmap)
{
apr_mmap_t *mm = themmap;
apr_mmap_t *next = APR_RING_NEXT(mm,link);
int rv = 0;
/* we no longer refer to the mmaped region */
APR_RING_REMOVE(mm,link);
APR_RING_NEXT(mm,link) = NULL;
APR_RING_PREV(mm,link) = NULL;
if (next != mm) {
/* more references exist, so we're done */
return APR_SUCCESS;
}
#ifdef BEOS
rv = delete_area(mm->area);
#else
rv = munmap(mm->mm, mm->size);
#endif
mm->mm = (void *)-1;
if (rv == 0) {
return APR_SUCCESS;
}
return errno;
}
示例3: APR_DECLARE
APR_DECLARE(apr_status_t) apr_pollset_remove(apr_pollset_t *pollset,
const apr_pollfd_t *descriptor)
{
apr_os_sock_t fd;
pfd_elem_t *ep;
apr_status_t rv = APR_SUCCESS;
int res;
pollset_lock_rings();
if (descriptor->desc_type == APR_POLL_SOCKET) {
fd = descriptor->desc.s->socketdes;
}
else {
fd = descriptor->desc.f->filedes;
}
res = port_dissociate(pollset->port_fd, PORT_SOURCE_FD, fd);
if (res < 0) {
rv = APR_NOTFOUND;
}
if (!APR_RING_EMPTY(&(pollset->query_ring), pfd_elem_t, link)) {
for (ep = APR_RING_FIRST(&(pollset->query_ring));
ep != APR_RING_SENTINEL(&(pollset->query_ring),
pfd_elem_t, link);
ep = APR_RING_NEXT(ep, link)) {
if (descriptor->desc.s == ep->pfd.desc.s) {
APR_RING_REMOVE(ep, link);
APR_RING_INSERT_TAIL(&(pollset->dead_ring),
ep, pfd_elem_t, link);
break;
}
}
}
if (!APR_RING_EMPTY(&(pollset->add_ring), pfd_elem_t, link)) {
for (ep = APR_RING_FIRST(&(pollset->add_ring));
ep != APR_RING_SENTINEL(&(pollset->add_ring),
pfd_elem_t, link);
ep = APR_RING_NEXT(ep, link)) {
if (descriptor->desc.s == ep->pfd.desc.s) {
APR_RING_REMOVE(ep, link);
APR_RING_INSERT_TAIL(&(pollset->dead_ring),
ep, pfd_elem_t, link);
break;
}
}
}
pollset_unlock_rings();
return rv;
}
示例4: apr_thread_mutex_lock
/*
* This function stop extra idle threads to the cnt.
* @return the number of threads stopped
* NOTE: There could be busy threads become idle during this function
*/
static struct apr_thread_list_elt *trim_threads(apr_thread_pool_t *me,
apr_size_t *cnt, int idle)
{
struct apr_thread_list *thds;
apr_size_t n, n_dbg, i;
struct apr_thread_list_elt *head, *tail, *elt;
apr_thread_mutex_lock(me->lock);
if (idle) {
thds = me->idle_thds;
n = me->idle_cnt;
}
else {
thds = me->busy_thds;
n = me->thd_cnt - me->idle_cnt;
}
if (n <= *cnt) {
apr_thread_mutex_unlock(me->lock);
*cnt = 0;
return NULL;
}
n -= *cnt;
head = APR_RING_FIRST(thds);
for (i = 0; i < *cnt; i++) {
head = APR_RING_NEXT(head, link);
}
tail = APR_RING_LAST(thds);
if (idle) {
APR_RING_UNSPLICE(head, tail, link);
me->idle_cnt = *cnt;
}
n_dbg = 0;
for (elt = head; elt != tail; elt = APR_RING_NEXT(elt, link)) {
elt->state = TH_STOP;
n_dbg++;
}
elt->state = TH_STOP;
n_dbg++;
assert(n == n_dbg);
*cnt = n;
apr_thread_mutex_unlock(me->lock);
APR_RING_PREV(head, link) = NULL;
APR_RING_NEXT(tail, link) = NULL;
return head;
}
示例5: trim_idle_threads
static apr_size_t trim_idle_threads(apr_thread_pool_t *me, apr_size_t cnt)
{
apr_size_t n_dbg;
struct apr_thread_list_elt *elt, *head, *tail;
apr_status_t rv;
elt = trim_threads(me, &cnt, 1);
apr_thread_mutex_lock(me->lock);
apr_thread_cond_broadcast(me->cond);
apr_thread_mutex_unlock(me->lock);
n_dbg = 0;
if (NULL != (head = elt)) {
while (elt) {
tail = elt;
apr_thread_join(&rv, elt->thd);
elt = APR_RING_NEXT(elt, link);
++n_dbg;
}
apr_thread_mutex_lock(me->lock);
APR_RING_SPLICE_TAIL(me->recycled_thds, head, tail,
apr_thread_list_elt, link);
apr_thread_mutex_unlock(me->lock);
}
assert(cnt == n_dbg);
return cnt;
}
示例6: ap_mpm_end_gen_helper
apr_status_t ap_mpm_end_gen_helper(void *unused) /* cleanup on pconf */
{
int gen = ap_config_generation - 1; /* differs from MPM generation */
mpm_gen_info_t *cur;
if (geninfo == NULL) {
/* initial pconf teardown, MPM hasn't run */
return APR_SUCCESS;
}
cur = APR_RING_FIRST(geninfo);
while (cur != APR_RING_SENTINEL(geninfo, mpm_gen_info_t, link) &&
cur->gen != gen) {
cur = APR_RING_NEXT(cur, link);
}
if (cur == APR_RING_SENTINEL(geninfo, mpm_gen_info_t, link)) {
/* last child of generation already exited */
ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
"no record of generation %d", gen);
}
else {
cur->done = 1;
if (cur->active == 0) {
end_gen(cur);
}
}
return APR_SUCCESS;
}
示例7: TASK_PRIORITY_SEG
/*
* Test it the task is the only one within the priority segment.
* If it is not, return the first element with same or lower priority.
* Otherwise, add the task into the queue and return NULL.
*
* NOTE: This function is not thread safe by itself. Caller should hold the lock
*/
static apr_thread_pool_task_t *add_if_empty(apr_thread_pool_t * me,
apr_thread_pool_task_t * const t)
{
int seg;
int next;
apr_thread_pool_task_t *t_next;
seg = TASK_PRIORITY_SEG(t);
if (me->task_idx[seg]) {
assert(APR_RING_SENTINEL(me->tasks, apr_thread_pool_task, link) !=
me->task_idx[seg]);
t_next = me->task_idx[seg];
while (t_next->dispatch.priority > t->dispatch.priority) {
t_next = APR_RING_NEXT(t_next, link);
if (APR_RING_SENTINEL(me->tasks, apr_thread_pool_task, link) ==
t_next) {
return t_next;
}
}
return t_next;
}
for (next = seg - 1; next >= 0; next--) {
if (me->task_idx[next]) {
APR_RING_INSERT_BEFORE(me->task_idx[next], t, link);
break;
}
}
if (0 > next) {
APR_RING_INSERT_TAIL(me->tasks, t, apr_thread_pool_task, link);
}
me->task_idx[seg] = t;
return NULL;
}
示例8: bmx_bean_print_text_plain
/**
* Called by other modules to print their "jmx beans" to the response in
* whatever format was requested by the client.
*/
static apr_status_t bmx_bean_print_text_plain(request_rec *r,
const struct bmx_bean *bean)
{
apr_size_t objectname_strlen = bmx_objectname_strlen(bean->objectname) + 1;
char *objectname_str = apr_palloc(r->pool, objectname_strlen);
(void)bmx_objectname_str(bean->objectname, objectname_str,
objectname_strlen);
(void)ap_rputs("Name: ", r);
(void)ap_rputs(objectname_str, r);
(void)ap_rputs("\n", r);
/* for each element in bean->bean_properties, print it */
if (!APR_RING_EMPTY(&(bean->bean_props), bmx_property, link)) {
struct bmx_property *p = NULL;
const char *value;
for (p = APR_RING_FIRST(&(bean->bean_props));
p != APR_RING_SENTINEL(&(bean->bean_props), bmx_property, link);
p = APR_RING_NEXT(p, link)) {
(void)ap_rputs(p->key, r);
(void)ap_rputs(": ", r);
value = property_print(r->pool, p);
if (value)
(void)ap_rputs(value, r);
(void)ap_rputs("\n", r);
}
}
(void)ap_rputs("\n", r);
return APR_SUCCESS;
}
示例9: wait_on_busy_threads
static void wait_on_busy_threads(apr_thread_pool_t *me, void *owner)
{
#ifndef NDEBUG
apr_os_thread_t *os_thread;
#endif
struct apr_thread_list_elt *elt;
apr_thread_mutex_lock(me->lock);
elt = APR_RING_FIRST(me->busy_thds);
while (elt != APR_RING_SENTINEL(me->busy_thds, apr_thread_list_elt, link)) {
if (elt->current_owner != owner) {
elt = APR_RING_NEXT(elt, link);
continue;
}
#ifndef NDEBUG
/* make sure the thread is not the one calling tasks_cancel */
apr_os_thread_get(&os_thread, elt->thd);
#ifdef WIN32
/* hack for apr win32 bug */
assert(!apr_os_thread_equal(apr_os_thread_current(), os_thread));
#else
assert(!apr_os_thread_equal(apr_os_thread_current(), *os_thread));
#endif
#endif
while (elt->current_owner == owner) {
apr_thread_mutex_unlock(me->lock);
apr_sleep(200 * 1000);
apr_thread_mutex_lock(me->lock);
}
elt = APR_RING_FIRST(me->busy_thds);
}
apr_thread_mutex_unlock(me->lock);
return;
}
示例10: MRCP_DECLARE
/** Get (copy) MRCP header fields */
MRCP_DECLARE(apt_bool_t) mrcp_header_fields_get(mrcp_message_header_t *header, const mrcp_message_header_t *src_header, const mrcp_message_header_t *mask_header, apr_pool_t *pool)
{
apt_header_field_t *header_field;
const apt_header_field_t *src_header_field;
const apt_header_field_t *mask_header_field;
for(mask_header_field = APR_RING_FIRST(&mask_header->header_section.ring);
mask_header_field != APR_RING_SENTINEL(&mask_header->header_section.ring, apt_header_field_t, link);
mask_header_field = APR_RING_NEXT(mask_header_field, link)) {
header_field = apt_header_section_field_get(&header->header_section,mask_header_field->id);
if(header_field) {
/* this header field has already been set, skip to the next one */
continue;
}
src_header_field = apt_header_section_field_get(&src_header->header_section,mask_header_field->id);
if(src_header_field) {
/* copy the entire header field */
header_field = apt_header_field_copy(src_header_field,pool);
mrcp_header_accessor_value_duplicate(header,header_field,src_header,src_header_field,pool);
}
else {
/* copy only the name of the header field */
header_field = apt_header_field_copy(mask_header_field,pool);
}
/* add the header field to the header section */
apt_header_section_field_add(&header->header_section,header_field);
}
return TRUE;
}
示例11: APT_DECLARE
APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(apt_obj_list_t *list, apt_list_elem_t *elem)
{
apt_list_elem_t *next_elem = APR_RING_NEXT(elem,link);
if(next_elem == APR_RING_SENTINEL(&list->head,apt_list_elem_t,link)) {
next_elem = NULL;
}
return next_elem;
}
示例12: add_task
static apr_status_t add_task(apr_thread_pool_t *me, apr_thread_start_t func,
void *param, apr_byte_t priority, int push,
void *owner)
{
apr_thread_pool_task_t *t;
apr_thread_pool_task_t *t_loc;
apr_thread_t *thd;
apr_status_t rv = APR_SUCCESS;
apr_thread_mutex_lock(me->lock);
t = task_new(me, func, param, priority, owner, 0);
if (NULL == t) {
apr_thread_mutex_unlock(me->lock);
return APR_ENOMEM;
}
t_loc = add_if_empty(me, t);
if (NULL == t_loc) {
goto FINAL_EXIT;
}
if (push) {
while (APR_RING_SENTINEL(me->tasks, apr_thread_pool_task, link) !=
t_loc && t_loc->dispatch.priority >= t->dispatch.priority) {
t_loc = APR_RING_NEXT(t_loc, link);
}
}
APR_RING_INSERT_BEFORE(t_loc, t, link);
if (!push) {
if (t_loc == me->task_idx[TASK_PRIORITY_SEG(t)]) {
me->task_idx[TASK_PRIORITY_SEG(t)] = t;
}
}
FINAL_EXIT:
me->task_cnt++;
if (me->task_cnt > me->tasks_high)
me->tasks_high = me->task_cnt;
if (0 == me->thd_cnt || (0 == me->idle_cnt && me->thd_cnt < me->thd_max &&
me->task_cnt > me->threshold)) {
rv = apr_thread_create(&thd, NULL, thread_pool_func, me, me->pool);
if (APR_SUCCESS == rv) {
++me->thd_cnt;
if (me->thd_cnt > me->thd_high)
me->thd_high = me->thd_cnt;
}
}
apr_thread_mutex_unlock(me->lock);
apr_thread_mutex_lock(me->cond_lock);
apr_thread_cond_signal(me->cond);
apr_thread_mutex_unlock(me->cond_lock);
return rv;
}
示例13: APT_DECLARE
/** Generate header section */
APT_DECLARE(apt_bool_t) apt_header_section_generate(const apt_header_section_t *header, apt_text_stream_t *stream)
{
apt_header_field_t *header_field;
for(header_field = APR_RING_FIRST(&header->ring);
header_field != APR_RING_SENTINEL(&header->ring, apt_header_field_t, link);
header_field = APR_RING_NEXT(header_field, link)) {
apt_header_field_generate(header_field,stream);
}
return apt_text_eol_insert(stream);
}
示例14: MPF_DECLARE
MPF_DECLARE(apt_bool_t) mpf_context_factory_process(mpf_context_factory_t *factory)
{
mpf_context_t *context;
for(context = APR_RING_FIRST(&factory->head);
context != APR_RING_SENTINEL(&factory->head, mpf_context_t, link);
context = APR_RING_NEXT(context, link)) {
mpf_context_process(context);
}
return TRUE;
}
示例15: impl_pollset_remove
static apr_status_t impl_pollset_remove(apr_pollset_t *pollset,
const apr_pollfd_t *descriptor)
{
pfd_elem_t *ep;
apr_status_t rv = APR_SUCCESS;
#ifdef HAVE_MTCP
struct mtcp_epoll_event ev = {0};
#else
struct epoll_event ev = {0}; /* ignored, but must be passed with
* kernel < 2.6.9
*/
#endif
int ret = -1;
if (descriptor->desc_type == APR_POLL_SOCKET) {
#ifdef HAVE_MTCP
int cpu = sched_getcpu();
ret = mtcp_epoll_ctl(g_mctx[cpu], pollset->p->epoll_fd, EPOLL_CTL_DEL,
descriptor->desc.s->socketdes, &ev);
#else
ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_DEL,
descriptor->desc.s->socketdes, &ev);
#endif
}
else {
ret = epoll_ctl(pollset->p->epoll_fd, EPOLL_CTL_DEL,
descriptor->desc.f->filedes, &ev);
}
if (ret < 0) {
rv = APR_NOTFOUND;
}
if (!(pollset->flags & APR_POLLSET_NOCOPY)) {
pollset_lock_rings();
for (ep = APR_RING_FIRST(&(pollset->p->query_ring));
ep != APR_RING_SENTINEL(&(pollset->p->query_ring),
pfd_elem_t, link);
ep = APR_RING_NEXT(ep, link)) {
if (descriptor->desc.s == ep->pfd.desc.s) {
APR_RING_REMOVE(ep, link);
APR_RING_INSERT_TAIL(&(pollset->p->dead_ring),
ep, pfd_elem_t, link);
break;
}
}
pollset_unlock_rings();
}
return rv;
}