<commit_before>/*  =========================================================================
    zpoller - trivial socket poller class

    Copyright (c) the Contributors as noted in the AUTHORS file.
    This file is part of CZMQ, the high-level C binding for 0MQ:
    http://czmq.zeromq.org.

    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
    file, You can obtain one at http://mozilla.org/MPL/2.0/.
    =========================================================================*/

/*
@header
    The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll
    API, for the very common case of reading from a number of sockets.
    It does not provide polling for output, nor polling on file handles.
    If you need either of these, use the zmq_poll API directly.
@discuss
@end
*/

#include "czmq_classes.h"

#ifdef ZMQ_HAVE_POLLER


//  Structure of our class

struct _zpoller_t {
    void *zmq_poller;           //  ZMQ Poller
    bool expired;               //  Did poll timer expire?
    bool terminated;            //  Did poll call end with EINTR?
    bool ignore_interrupts;     //  Should this poller ignore zsys_interrupted?
};


//  --------------------------------------------------------------------------
//  Constructor
//  Create new poller; the reader can be a libzmq socket (void *), a zsock_t
//  instance, or a zactor_t instance.

zpoller_t *
zpoller_new (void *reader, ...)
{
    zpoller_t *self = (zpoller_t *) zmalloc (sizeof (zpoller_t));
    if (self) {
        self->zmq_poller = zmq_poller_new ();

        va_list args;
        va_start (args, reader);
        while (reader) {
            if (zpoller_add (self, reader)) {
                zpoller_destroy (&self);
                break;
            }
            reader = va_arg (args, void *);
        }
        va_end (args);
    }
    return self;
}


//  --------------------------------------------------------------------------
//  Destroy a poller

void
zpoller_destroy (zpoller_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zpoller_t *self = *self_p;
        zmq_poller_close (self->zmq_poller);
        free (self);
        *self_p = NULL;
    }
}


//  --------------------------------------------------------------------------<commit_msg>Problem: libzmq master changed zmq_poller_close -> destroy<commit_after>/*  =========================================================================
    zpoller - trivial socket poller class

    Copyright (c) the Contributors as noted in the AUTHORS file.
    This file is part of CZMQ, the high-level C binding for 0MQ:
    http://czmq.zeromq.org.

    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
    file, You can obtain one at http://mozilla.org/MPL/2.0/.
    =========================================================================*/

/*
@header
    The zpoller class provides a minimalist interface to ZeroMQ's zmq_poll
    API, for the very common case of reading from a number of sockets.
    It does not provide polling for output, nor polling on file handles.
    If you need either of these, use the zmq_poll API directly.
@discuss
@end
*/

#include "czmq_classes.h"

#ifdef ZMQ_HAVE_POLLER


//  Structure of our class

struct _zpoller_t {
    void *zmq_poller;           //  ZMQ Poller
    bool expired;               //  Did poll timer expire?
    bool terminated;            //  Did poll call end with EINTR?
    bool ignore_interrupts;     //  Should this poller ignore zsys_interrupted?
};


//  --------------------------------------------------------------------------
//  Constructor
//  Create new poller; the reader can be a libzmq socket (void *), a zsock_t
//  instance, or a zactor_t instance.

zpoller_t *
zpoller_new (void *reader, ...)
{
    zpoller_t *self = (zpoller_t *) zmalloc (sizeof (zpoller_t));
    if (self) {
        self->zmq_poller = zmq_poller_new ();

        va_list args;
        va_start (args, reader);
        while (reader) {
            if (zpoller_add (self, reader)) {
                zpoller_destroy (&self);
                break;
            }
            reader = va_arg (args, void *);
        }
        va_end (args);
    }
    return self;
}


//  --------------------------------------------------------------------------
//  Destroy a poller

void
zpoller_destroy (zpoller_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zpoller_t *self = *self_p;
        zmq_poller_destroy (&self->zmq_poller);
        free (self);
        *self_p = NULL;
    }
}


//  --------------------------------------------------------------------------
{'fraction_non_alphanumeric': 0.23338940285954585, 'fraction_numerical': 0.0021026072329688814, 'mean_word_length': 1.7721445221445222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5657920', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1325, 'n_words': 449}