Changes between Version 1 and Version 5 of Ticket #37
- Timestamp:
- Aug 2, 2010, 10:59:06 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37
-
Property
Milestone
changed from
to
Preempt merge
-
Property
Milestone
changed from
-
Ticket #37 – Description
v1 v5 6 6 #!c 7 7 8 // Skipped GPCT stuff to declare a queue as "worker_internal".9 10 8 /** 11 9 @this is an item pushable to a worker queue. … … 13 11 struct worker_item_s 14 12 { 15 worker_internal_item_t item;13 CONTAINER_ENTRY_TYPE(DLIST) list_entry; 16 14 }; 15 16 /** @intenral */ 17 CONTAINER_TYPE(worker_internal, DLIST, struct worker_item_s, list_entry); 17 18 18 19 … … 21 22 pointer 22 23 */ 23 #define WORKER_ITEM_TO_STRUCT(struct_type, field, item) 24 #define WORKER_ITEM_TO_STRUCT(struct_type, field, item) \ 25 (struct_type *)((uintptr_t)(item) - __builtin_offsetof(struct_type, field)) 26 27 28 /** 29 @this is a worker function prototype macro. 30 */ 31 #define WORKER_FUNC(n) void (n)(struct worker_thread_s *worker, \ 32 struct worker_item_s *item, \ 33 void *priv) 24 34 25 35 /** … … 27 37 28 38 Function must return once it handled the reason of wakeup. 39 40 @param worker Worker thread context, may be used to stop self 41 @param item Item to work on 42 @param priv Private data passed on init 29 43 */ 30 typedef void worker_func_t(struct worker_item_s *item, void *priv);44 typedef WORKER_FUNC(worker_func_t); 31 45 32 46 struct worker_thread_s 33 47 { 48 worker_internal_root_t to_handle; 49 50 struct sched_context_s context; 51 bool_t killed; 52 lock_t lock; 34 53 worker_func_t *func; 35 void *priv; 36 // lock, queue, whatever 54 void *func_priv; 37 55 }; 38 56 39 57 /***/ 40 58 void worker_thread_init(struct worker_thread_s*, 59 void *stack, 60 size_t stack_size, 41 61 worker_func_t *func, 42 62 void *func_priv); … … 44 64 /** 45 65 @this runs a context, i.e. this makes the worker ready for wake 46 up. This does not make function to be called66 up. This waits until a work is pushed. 47 67 */ 48 68 void worker_thread_start(struct worker_thread_s*); … … 60 80 61 81 @param item The item to pass to the woken-up function 82 @returns -EAGAIN if the thread is not started yet, -EINVAL if the 83 thread already got killed, 0 if OK. 62 84 */ 63 voidworker_thread_wakeup(struct worker_thread_s*, struct worker_item_s *item);85 error_t worker_thread_wakeup(struct worker_thread_s*, struct worker_item_s *item); 64 86 }}} 65 66 Open questions:67 * Allow function to sucide worker context