Blender  V2.93
BLI_linklist_lockfree.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2018 Blender Foundation.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 typedef struct LockfreeLinkNode {
32  /* NOTE: "Subclass" this structure to add custom-defined data. */
34 
35 typedef struct LockfreeLinkList {
36  /* We keep a dummy node at the beginning of the list all the time.
37  * This allows us to make sure head and tail pointers are always
38  * valid, and saves from annoying exception cases in insert().
39  */
41  /* NOTE: This fields might point to a dummy node. */
44 
45 typedef void (*LockfreeeLinkNodeFreeFP)(void *link);
46 
47 /* ************************************************************************** */
48 /* NOTE: These functions are NOT safe for use from threads. */
49 /* NOTE: !!! I REPEAT: DO NOT USE THEM WITHOUT EXTERNAL LOCK !!! */
50 
51 /* Make list ready for lock-free access. */
53 
54 /* Completely free the whole list, it is NOT re-usable after this. */
56 
57 /* Remove all the elements from the list, keep it usable for further
58  * inserts.
59  */
61 
62 /* Begin iteration of lock-free linked list, starting with a
63  * first user=defined node. Will ignore the dummy node.
64  */
66 
67 /* ************************************************************************** */
68 /* NOTE: These functions are safe for use from threads. */
69 
71 
72 #ifdef __cplusplus
73 }
74 #endif
static PyObject * free_func(PyObject *, PyObject *value)
OperationNode * node
struct LockfreeLinkNode * next