"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/lib/isc/include/isc/ondestroy.h" (7 Sep 2020, 2798 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ondestroy.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef ISC_ONDESTROY_H
   13 #define ISC_ONDESTROY_H 1
   14 
   15 #include <isc/lang.h>
   16 #include <isc/types.h>
   17 
   18 ISC_LANG_BEGINDECLS
   19 
   20 /*! \file isc/ondestroy.h
   21  * ondestroy handling.
   22  *
   23  * Any class ``X'' of objects that wants to send out notifications
   24  * on its destruction should declare a field of type isc_ondestroy_t
   25  * (call it 'ondest').
   26  *
   27  * \code
   28  *  typedef struct {
   29  *      ...
   30  *      isc_ondestroy_t ondest;
   31  *      ...
   32  *  } X;
   33  * \endcode
   34  *
   35  * When an object ``A'' of type X is created
   36  * it must initialize the field ondest with a call to
   37  *
   38  * \code
   39  *  isc_ondestroy_init(&A->ondest).
   40  * \endcode
   41  *
   42  * X should also provide a registration function for third-party
   43  * objects to call to register their interest in being told about
   44  * the destruction of a particular instance of X.
   45  *
   46  * \code
   47  *  isc_result_t
   48  *  X_ondestroy(X *instance, isc_task_t *task,
   49  *           isc_event_t **eventp) {
   50  *      return(isc_ondestroy_register(&instance->ondest, task,eventp));
   51  *  }
   52  * \endcode
   53  *
   54  *  Note: locking of the ondestory structure embedded inside of X, is
   55  *  X's responsibility.
   56  *
   57  * When an instance of X is destroyed, a call to  isc_ondestroy_notify()
   58  * sends the notifications:
   59  *
   60  * \code
   61  *  X *instance;
   62  *  isc_ondestroy_t ondest = instance->ondest;
   63  *
   64  *  ... completely cleanup 'instance' here...
   65  *
   66  *  isc_ondestroy_notify(&ondest, instance);
   67  * \endcode
   68  *
   69  *
   70  * see lib/dns/zone.c for an ifdef'd-out example.
   71  */
   72 
   73 struct isc_ondestroy {
   74     unsigned int magic;
   75     isc_eventlist_t events;
   76 };
   77 
   78 void
   79 isc_ondestroy_init(isc_ondestroy_t *ondest);
   80 /*%<
   81  * Initialize the on ondest structure. *must* be called before first call
   82  * to isc_ondestroy_register().
   83  */
   84 
   85 isc_result_t
   86 isc_ondestroy_register(isc_ondestroy_t *ondest, isc_task_t *task,
   87                isc_event_t **eventp);
   88 
   89 /*%<
   90  * Stores task and *eventp away inside *ondest.  Ownership of **event is
   91  * taken from the caller (and *eventp is set to NULL). The task is attached
   92  * to.
   93  */
   94 
   95 void
   96 isc_ondestroy_notify(isc_ondestroy_t *ondest, void *sender);
   97 /*%<
   98  * Dispatches the event(s) to the task(s) that were given in
   99  * isc_ondestroy_register call(s) (done via calls to
  100  * isc_task_sendanddetach()).  Before dispatch, the sender value of each
  101  * event structure is set to the value of the sender parameter. The
  102  * internal structures of the ondest parameter are cleaned out, so no other
  103  * cleanup is needed.
  104  */
  105 
  106 ISC_LANG_ENDDECLS
  107 
  108 #endif /* ISC_ONDESTROY_H */