diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2021-05-28 14:10:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-28 14:10:51 (GMT) |
commit | 2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8 (patch) | |
tree | 40975e0846d101360a838d42e16f4687fed77f4a /src/H5ESlist.c | |
parent | e22687912dbc6fcf4fff57e86e2cd5d75c81f81e (diff) | |
download | hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.zip hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.gz hdf5-2ddf5fbd92ebdb0d59e208d88f159eec8a1ffbf8.tar.bz2 |
Much normalization with develop (#701)
* Brings CMake updates from develop
* Brings reduction in pedantic casts from develop
* Purges UFAIL from the library (#637)
* Committing clang-format changes
* Purges UFAIL from the library
* H5HL_insert change requested in PR
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Removes gratuitous (double)x.yF casts (#632)
* Committing clang-format changes
* Removes gratuitous (double)x.yF casts
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Committing clang-format changes
* Cleans up a const warning left over from previous constification (#633)
* Committing clang-format changes
* Adds consts to a few global variables
* Cleans up a const warning left over from previous constification
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
* Formatted source
* Bring over some VOL registration changes
* VOL cleanup
* H5VL_request_status_t substitutions
* H5F.c cleanup
* Minor API tweaks from develop
* Moves H5G package init/teardown to H5Gint.c
* H5G cleanup
* H5M cleanup
* H5SM cleanup
* H5T cleanup
* H5R cleanup
* H5Lpublic.h cleanup
* H5L cleanup
* H5O cleanup
* H5A, H5CS, and H5AC cleanup
* Moved H5A init/teardown code to H5Aint.c
* Moves H5D I/O functions to H5D.c
* H5D cleanup
* Misc minor cleanup
* H5P close cleanup
* H5Tpublic.h cleanup
* Fixes err_compat test
* H5PLpublic.h cleanup
* Updates H5Ppublic.h
* H5Fpublic.h updates
* H5A.c cleanup
* Brings over H5Aexists and related changes
* Brings CMake shell testing changes from develop
* Close callback changes
* H5R and H5Tcommit normalization
* err_compat test works now
* H5O tweaks
* Updates VOL registration code
* Brings over H5VL_create_object
* H5Tconv.c reformatting
* H5T.c tweaks
* Brings datatype and reference updates from develop
* Brings VOL plugin loading changes from develop
* Brings event sets from develop
* Brings async functions over
* Tools changes
* Brings over many tools changes from develop
* Brings VOL flags from develop
* Fixes h5dump double/float tests
* Updates h5repack tests
* Brings h5diff test changes from develop
* Last h5dump changes
* Brings test changes from develop
* Committing clang-format changes
* Tidied h5_testing()
* Brings chunk iteration code + misc from develop
* Updates vds test
* Enables external link parallel test
* Brings updated property lists from develop
* H5G changes from develop
* H5MF cleanup
* Brings vfd_swmr test back into CMake
* Updates threadsafe test
* Updates plist test
* Brings recent changes from develop
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/H5ESlist.c')
-rw-r--r-- | src/H5ESlist.c | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/src/H5ESlist.c b/src/H5ESlist.c new file mode 100644 index 0000000..c0e24cc --- /dev/null +++ b/src/H5ESlist.c @@ -0,0 +1,215 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://www.hdfgroup.org/licenses. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5ESlist.c + * Nov 7 2020 + * Quincey Koziol + * + * Purpose: Operations on "event lists" for managing asynchronous + * operations. + * + * Please see the asynchronous I/O RFC document + * for a full description of how they work, etc. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5ESmodule.h" /* This source code file is part of the H5ES module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5ESpkg.h" /* Event Sets */ +#include "H5FLprivate.h" /* Free Lists */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/*------------------------------------------------------------------------- + * Function: H5ES__list_insert + * + * Purpose: Append an event into an event list + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Saturday, November 7, 2020 + * + *------------------------------------------------------------------------- + */ +void +H5ES__list_append(H5ES_event_list_t *el, H5ES_event_t *ev) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(el); + HDassert(ev); + + /* Append event onto the event list */ + if (NULL == el->tail) + el->head = el->tail = ev; + else { + ev->prev = el->tail; + el->tail->next = ev; + el->tail = ev; + } /* end else */ + + /* Increment the # of events in list */ + el->count++; + + FUNC_LEAVE_NOAPI_VOID +} /* end H5ES__list_append() */ + +/*------------------------------------------------------------------------- + * Function: H5ES__list_count + * + * Purpose: Retrieve # of events in an event list + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Saturday, November 7, 2020 + * + *------------------------------------------------------------------------- + */ +H5_ATTR_PURE size_t +H5ES__list_count(const H5ES_event_list_t *el) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(el); + + FUNC_LEAVE_NOAPI(el->count) +} /* end H5ES__list_count() */ + +/*------------------------------------------------------------------------- + * Function: H5ES__list_iterate + * + * Purpose: Iterate over events in a list, calling callback for + * each event. + * + * Note: Iteration is safe for deleting the current event. Modifying + * the list in other ways is likely unsafe. + * + * Return: SUCCEED / FAIL + * + * Programmer: Quincey Koziol + * Saturday, November 7, 2020 + * + *------------------------------------------------------------------------- + */ +int +H5ES__list_iterate(H5ES_event_list_t *el, H5ES_list_iter_func_t cb, void *ctx) +{ + H5ES_event_t *ev; /* Event in list */ + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(el); + HDassert(cb); + + /* Iterate over events in list */ + ev = el->head; + while (ev) { + H5ES_event_t *tmp; /* Temporary event */ + + /* Get pointer to next node, so it's safe if this one is removed */ + tmp = ev->next; + + /* Perform iterator callback */ + if ((ret_value = (*cb)(ev, ctx)) != H5_ITER_CONT) { + if (ret_value < 0) + HERROR(H5E_EVENTSET, H5E_CANTNEXT, "iteration operator failed"); + break; + } /* end if */ + + /* Advance to next node */ + ev = tmp; + } /* end while */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5ES__list_iterate() */ + +/*------------------------------------------------------------------------- + * Function: H5ES__list_remove + * + * Purpose: Remove an event from an event list + * + * Return: SUCCEED / FAIL + * + * Programmer: Houjun Tang + * Thursday, July 30, 2020 + * + *------------------------------------------------------------------------- + */ +void +H5ES__list_remove(H5ES_event_list_t *el, const H5ES_event_t *ev) +{ + FUNC_ENTER_PACKAGE_NOERR + + /* Sanity check */ + HDassert(el); + HDassert(el->head); + HDassert(ev); + + /* Stitch event out of list */ + if (ev == el->head) + el->head = ev->next; + if (NULL != ev->next) + ev->next->prev = ev->prev; + if (NULL != ev->prev) + ev->prev->next = ev->next; + if (NULL == el->head) + el->tail = NULL; + + /* Decrement the # of events in list */ + el->count--; + + FUNC_LEAVE_NOAPI_VOID +} /* end H5ES__list_remove() */ |