* Hacked BSD taskqueues. In lieu of actually running a kproc or something that
* sleeps on a queue of tasks, we'll just blast out a kmsg. We can always
* change the implementation if we need more control.
- *
- *
+ *
+ *
* Linux workqueue wrappers:
*
* Caveats:
* aren't entirely clear.
*/
-#ifndef ROS_KERN_TASKQUEUE_H
-#define ROS_KERN_TASKQUEUE_H
+#pragma once
typedef void (*task_fn_t)(void *context, int pending);
struct taskqueue {};
struct task {
- task_fn_t ta_func; /* task handler */
- void *ta_context; /* argument for handler */
+ task_fn_t ta_func; /* task handler */
+ void *ta_context; /* arg for handler */
};
#define taskqueue_drain(x, y)
#define taskqueue_start_threads(a, b, c, d, e) (1)
int taskqueue_enqueue(struct taskqueue *queue, struct task *task);
-/* We're already fast, no need for another ufnction! (sic) */
+/* We're already fast, no need for another function! */
#define taskqueue_enqueue_fast taskqueue_enqueue
#define TASK_INIT(str, dummy, func, arg) \
- (str)->ta_func = func; \
+ (str)->ta_func = func; \
(str)->ta_context = (void*)arg;
struct workqueue_struct {
/* Delayed work is embedded in other structs. Handlers will expect to get a
* work_struct pointer. */
struct delayed_work {
- struct work_struct work;
+ struct work_struct work;
/* TODO: support for the actual alarm / timer */
};
+static inline struct delayed_work *to_delayed_work(struct work_struct *work)
+{
+ return container_of(work, struct delayed_work, work);
+}
+
#define INIT_DELAYED_WORK(dwp, funcp) (dwp)->work.func = (funcp)
#define INIT_WORK(wp, funcp) (wp)->func = (funcp)
void flush_workqueue(struct workqueue_struct *wq);
bool schedule_delayed_work(struct delayed_work *dwork, unsigned long delay);
bool cancel_delayed_work(struct delayed_work *dwork);
bool cancel_delayed_work_sync(struct delayed_work *dwork);
-
-#endif /* ROS_KERN_TASKQUEUE_H */