Changeset 5559712 in mainline for uspace/srv/sysman/sysman.c
- Timestamp:
- 2019-08-03T09:28:50Z (5 years ago)
- Children:
- c0e4fc50
- Parents:
- 2dda1d4
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-05-07 11:49:47)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 09:28:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/sysman.c
r2dda1d4 r5559712 35 35 #include "log.h" 36 36 #include "sysman.h" 37 #include "unit.h" 37 38 38 39 … … 150 151 151 152 /* Process event */ 152 sysman_log(LVL_DEBUG2, "process(%p, %p)", event->handler, event->data); 153 sysman_log(LVL_DEBUG2, "process_event(%p, %p)", 154 event->handler, event->data); 153 155 event->handler(event->data); 154 156 free(event); 155 157 } 158 } 159 160 /** Create and queue job for unit 161 * 162 * @param[in] callback callback must explicitly delete reference to job 163 */ 164 int sysman_queue_job(unit_t *unit, unit_state_t target_state, 165 callback_handler_t callback, void *callback_arg) 166 { 167 job_t *job = job_create(unit, target_state); 168 if (job == NULL) { 169 return ENOMEM; 170 } 171 172 job_add_ref(job); 173 sysman_object_observer(job, callback, callback_arg); 174 175 job_add_ref(job); 176 sysman_raise_event(&sysman_event_job_process, job); 177 178 job_del_ref(&job); 179 return EOK; 156 180 } 157 181 … … 226 250 227 251 // NOTE must run in main event loop fibril 228 void sysman_event_job_process(void * arg)229 { 230 job_t *job = arg;252 void sysman_event_job_process(void *data) 253 { 254 job_t *job = data; 231 255 dyn_array_t job_closure; 232 256 dyn_array_initialize(&job_closure, job_ptr_t, 0); … … 250 274 job_del_ref(&job); 251 275 252 // TODO explain why calling asynchronously 253 sysman_raise_event(&sysman_event_job_queue_run, NULL); 276 job_queue_process(); 254 277 return; 255 278 … … 265 288 } 266 289 267 268 void sysman_event_job_queue_run(void *unused) 269 { 270 job_t *job; 271 while ((job = job_queue_pop_runnable())) { 272 job_run(job); 273 job_del_ref(&job); 274 } 275 } 276 277 void sysman_event_job_changed(void *object) 278 { 279 notify_observers(object); 290 void sysman_event_job_finished(void *data) 291 { 292 notify_observers(data); 280 293 /* Unreference the event data */ 281 job_t *job = object;294 job_t *job = data; 282 295 job_del_ref(&job); 283 } 296 297 /* The finished job, might have been blocking */ 298 job_queue_process(); 299 } 300 301 void sysman_event_unit_exposee_created(void *data) 302 { 303 unit_t *unit = data; 304 unit_exposee_created(unit); 305 } 306 307 void sysman_event_unit_failed(void *data) 308 { 309 unit_t *unit = data; 310 unit_fail(unit); 311 } 312 313 void sysman_event_unit_state_changed(void *data) 314 { 315 notify_observers(data); 316 }
Note:
See TracChangeset
for help on using the changeset viewer.