232
232
233
233
#ifndef __ASSEMBLY__
234
234
235
+ /* Work queue forward declaration */
236
+
237
+ struct kwork_wqueue_s ;
238
+
235
239
/* Defines the work callback */
236
240
237
241
typedef CODE void (* worker_t )(FAR void * arg );
@@ -247,13 +251,14 @@ struct work_s
247
251
{
248
252
struct
249
253
{
250
- struct dq_entry_s dq ; /* Implements a double linked list */
251
- clock_t qtime ; /* Time work queued */
254
+ struct dq_entry_s dq ; /* Implements a double linked list */
255
+ clock_t qtime ; /* Time work queued */
252
256
} s ;
253
- struct wdog_s timer ; /* Delay expiry timer */
257
+ struct wdog_s timer ; /* Delay expiry timer */
254
258
} u ;
255
- worker_t worker ; /* Work callback */
256
- FAR void * arg ; /* Callback argument */
259
+ worker_t worker ; /* Work callback */
260
+ FAR void * arg ; /* Callback argument */
261
+ FAR struct kwork_wqueue_s * wq ; /* Work queue */
257
262
};
258
263
259
264
/* This is an enumeration of the various events that may be
@@ -330,7 +335,50 @@ int work_usrstart(void);
330
335
#endif
331
336
332
337
/****************************************************************************
333
- * Name: work_queue
338
+ * Name: work_queue_create
339
+ *
340
+ * Description:
341
+ * Create a new work queue. The work queue is identified by its work
342
+ * queue ID, which is used to queue works to the work queue and to
343
+ * perform other operations on the work queue.
344
+ * This function will create a work thread pool with nthreads threads.
345
+ * The work queue ID is returned on success.
346
+ *
347
+ * Input Parameters:
348
+ * name - Name of the new task
349
+ * priority - Priority of the new task
350
+ * stack_size - size (in bytes) of the stack needed
351
+ * nthreads - Number of work thread should be created
352
+ *
353
+ * Returned Value:
354
+ * The work queue handle returned on success. Otherwise, NULL
355
+ *
356
+ ****************************************************************************/
357
+
358
+ FAR struct kwork_wqueue_s * work_queue_create (FAR const char * name ,
359
+ int priority ,
360
+ int stack_size , int nthreads );
361
+
362
+ /****************************************************************************
363
+ * Name: work_queue_free
364
+ *
365
+ * Description:
366
+ * Destroy a work queue. The work queue is identified by its work queue ID.
367
+ * All worker threads will be destroyed and the work queue will be freed.
368
+ * The work queue ID is invalid after this function returns.
369
+ *
370
+ * Input Parameters:
371
+ * wqueue - The work queue handle
372
+ *
373
+ * Returned Value:
374
+ * Zero on success, a negated errno value on failure.
375
+ *
376
+ ****************************************************************************/
377
+
378
+ int work_queue_free (FAR struct kwork_wqueue_s * wqueue );
379
+
380
+ /****************************************************************************
381
+ * Name: work_queue/work_queue_wq
334
382
*
335
383
* Description:
336
384
* Queue work to be performed at a later time. All queued work will be
@@ -344,7 +392,8 @@ int work_usrstart(void);
344
392
* pending work will be canceled and lost.
345
393
*
346
394
* Input Parameters:
347
- * qid - The work queue ID
395
+ * qid - The work queue ID (must be HPWORK or LPWORK)
396
+ * wqueue - The work queue handle
348
397
* work - The work structure to queue
349
398
* worker - The worker callback to be invoked. The callback will be
350
399
* invoked on the worker thread of execution.
@@ -360,17 +409,21 @@ int work_usrstart(void);
360
409
361
410
int work_queue (int qid , FAR struct work_s * work , worker_t worker ,
362
411
FAR void * arg , clock_t delay );
412
+ int work_queue_wq (FAR struct kwork_wqueue_s * wqueue ,
413
+ FAR struct work_s * work , worker_t worker ,
414
+ FAR void * arg , clock_t delay );
363
415
364
416
/****************************************************************************
365
- * Name: work_cancel
417
+ * Name: work_cancel/work_cancel_wq
366
418
*
367
419
* Description:
368
420
* Cancel previously queued work. This removes work from the work queue.
369
421
* After work has been cancelled, it may be requeued by calling
370
422
* work_queue() again.
371
423
*
372
424
* Input Parameters:
373
- * qid - The work queue ID
425
+ * qid - The work queue ID (must be HPWORK or LPWORK)
426
+ * wqueue - The work queue handle
374
427
* work - The previously queued work structure to cancel
375
428
*
376
429
* Returned Value:
@@ -382,9 +435,11 @@ int work_queue(int qid, FAR struct work_s *work, worker_t worker,
382
435
****************************************************************************/
383
436
384
437
int work_cancel (int qid , FAR struct work_s * work );
438
+ int work_cancel_wq (FAR struct kwork_wqueue_s * wqueue ,
439
+ FAR struct work_s * work );
385
440
386
441
/****************************************************************************
387
- * Name: work_cancel_sync
442
+ * Name: work_cancel_sync/work_cancel_sync_wq
388
443
*
389
444
* Description:
390
445
* Blocked cancel previously queued user-mode work. This removes work
@@ -393,6 +448,7 @@ int work_cancel(int qid, FAR struct work_s *work);
393
448
*
394
449
* Input Parameters:
395
450
* qid - The work queue ID (must be HPWORK or LPWORK)
451
+ * wqueue - The work queue handle
396
452
* work - The previously queued work structure to cancel
397
453
*
398
454
* Returned Value:
@@ -405,6 +461,8 @@ int work_cancel(int qid, FAR struct work_s *work);
405
461
****************************************************************************/
406
462
407
463
int work_cancel_sync (int qid , FAR struct work_s * work );
464
+ int work_cancel_sync_wq (FAR struct kwork_wqueue_s * wqueue ,
465
+ FAR struct work_s * work );
408
466
409
467
/****************************************************************************
410
468
* Name: work_available
0 commit comments