1 #ifndef _URCU_WORKQUEUE_H
2 #define _URCU_WORKQUEUE_H
7 * Userspace RCU header - Userspace workqueues
9 * Copyright (c) 2009,2017 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <urcu/wfcqueue.h>
36 /* Note that struct urcu_workqueue is opaque to callers. */
38 struct urcu_workqueue
;
39 struct urcu_workqueue_completion
;
43 #define URCU_WORKQUEUE_RT (1U << 0)
44 #define URCU_WORKQUEUE_STOP (1U << 1)
45 #define URCU_WORKQUEUE_PAUSE (1U << 2)
46 #define URCU_WORKQUEUE_PAUSED (1U << 3)
49 * The urcu_work data structure is placed in the structure to be acted
50 * upon via urcu_workqueue_queue_work().
54 struct cds_wfcq_node next
;
55 void (*func
)(struct urcu_work
*head
);
62 struct urcu_workqueue
*urcu_workqueue_create(unsigned long flags
,
63 int cpu_affinity
, void *priv
,
64 void (*grace_period_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
65 void (*initialize_worker_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
66 void (*finalize_worker_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
67 void (*worker_before_wait_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
68 void (*worker_after_wake_up_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
69 void (*worker_before_pause_fct
)(struct urcu_workqueue
*workqueue
, void *priv
),
70 void (*worker_after_resume_fct
)(struct urcu_workqueue
*workqueue
, void *priv
));
71 void urcu_workqueue_destroy(struct urcu_workqueue
*workqueue
);
74 * Never fails. Should not be used to enqueue work from worker threads
75 * after the application invokes urcu_workqueue_free.
77 void urcu_workqueue_queue_work(struct urcu_workqueue
*workqueue
,
78 struct urcu_work
*work
,
79 void (*func
)(struct urcu_work
*work
));
81 struct urcu_workqueue_completion
*urcu_workqueue_create_completion(void);
82 void urcu_workqueue_destroy_completion(struct urcu_workqueue_completion
*completion
);
84 void urcu_workqueue_queue_completion(struct urcu_workqueue
*workqueue
,
85 struct urcu_workqueue_completion
*completion
);
86 void urcu_workqueue_wait_completion(struct urcu_workqueue_completion
*completion
);
88 void urcu_workqueue_flush_queued_work(struct urcu_workqueue
*workqueue
);
91 * pause/resume/create worker threads. Can be used to pause worker
92 * threads across fork/clone while keeping the workqueue in place.
93 * Pause is used in parent pre-fork, resume in parent post-fork, create
94 * in child after-fork.
96 void urcu_workqueue_pause_worker(struct urcu_workqueue
*workqueue
);
97 void urcu_workqueue_resume_worker(struct urcu_workqueue
*workqueue
);
98 void urcu_workqueue_create_worker(struct urcu_workqueue
*workqueue
);
104 #endif /* _URCU_WORKQUEUE_H */