- Timestamp:
- Oct 19, 2009, 10:14:15 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- dbf94e9
- Parents:
- cc1a6d4
- git-author:
- Alejandro R. Sedeño <asedeno@mit.edu> (10/13/09 03:01:31)
- git-committer:
- Alejandro R. Sedeño <asedeno@mit.edu> (10/19/09 22:14:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
select.c
r9f5e847 r4f2166b 2 2 3 3 static int dispatch_active = 0; 4 static int psa_active = 0; 4 5 5 6 int _owl_select_timer_cmp(const owl_timer *t1, const owl_timer *t2) { … … 353 354 } 354 355 356 owl_ps_action *owl_select_add_pre_select_action(int (*cb)(owl_ps_action *, void *), void (*destroy)(owl_ps_action *), void *data) 357 { 358 owl_ps_action *a = owl_malloc(sizeof(owl_ps_action)); 359 owl_list *psa_list = owl_global_get_psa_list(&g); 360 a->needs_gc = 0; 361 a->callback = cb; 362 a->destroy = destroy; 363 a->data = data; 364 owl_list_append_element(psa_list, a); 365 return a; 366 } 367 368 void owl_select_psa_gc(void) 369 { 370 int i; 371 owl_list *psa_list; 372 owl_ps_action *a; 373 374 psa_list = owl_global_get_psa_list(&g); 375 for (i = owl_list_get_size(psa_list) - 1; i >= 0; i--) { 376 a = owl_list_get_element(psa_list, i); 377 if (a->needs_gc) { 378 owl_list_remove_element(psa_list, i); 379 if (a->destroy) { 380 a->destroy(a); 381 } 382 owl_free(a); 383 } 384 } 385 } 386 387 void owl_select_remove_pre_select_action(owl_ps_action *a) 388 { 389 a->needs_gc = 1; 390 if (!psa_active) 391 owl_select_psa_gc(); 392 } 393 394 int owl_select_do_pre_select_actions(void) 395 { 396 int i, len, ret; 397 owl_list *psa_list; 398 399 psa_active = 1; 400 ret = 0; 401 psa_list = owl_global_get_psa_list(&g); 402 len = owl_list_get_size(psa_list); 403 for (i = 0; i < len; i++) { 404 owl_ps_action *a = owl_list_get_element(psa_list, i); 405 if (a->callback != NULL && a->callback(a, a->data)) { 406 ret = 1; 407 } 408 } 409 psa_active = 0; 410 owl_select_psa_gc(); 411 return ret; 412 } 413 355 414 void owl_select(void) 356 415 { … … 400 459 /* END AIM HACK */ 401 460 461 if (owl_select_do_pre_select_actions()) { 462 timeout.tv_sec = 0; 463 timeout.tv_nsec = 0; 464 } 465 402 466 ret = pselect(max_fd+1, &r, &aim_wfds, &e, &timeout, &mask); 403 467
Note: See TracChangeset
for help on using the changeset viewer.