ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/etp.c
(Generate patch)

Comparing libeio/etp.c (file contents):
Revision 1.8 by root, Thu Jun 25 18:14:19 2015 UTC vs.
Revision 1.9 by root, Thu Jun 25 20:41:03 2015 UTC

1/* 1/*
2 * libetp implementation 2 * libetp implementation
3 * 3 *
4 * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libetp@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2015 Marc Alexander Lehmann <libetp@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
343 343
344 for (;;) 344 for (;;)
345 { 345 {
346 req = reqq_shift (&pool->req_queue); 346 req = reqq_shift (&pool->req_queue);
347 347
348 if (req) 348 if (ecb_expect_true (req))
349 break; 349 break;
350 350
351 if (ts.tv_sec == 1) /* no request, but timeout detected, let's quit */ 351 if (ts.tv_sec == 1) /* no request, but timeout detected, let's quit */
352 { 352 {
353 X_UNLOCK (pool->reqlock); 353 X_UNLOCK (pool->reqlock);
377 377
378 --pool->nready; 378 --pool->nready;
379 379
380 X_UNLOCK (pool->reqlock); 380 X_UNLOCK (pool->reqlock);
381 381
382 if (req->type == ETP_TYPE_QUIT) 382 if (ecb_expect_false (req->type == ETP_TYPE_QUIT))
383 goto quit; 383 goto quit;
384 384
385 ETP_EXECUTE (self, req); 385 ETP_EXECUTE (self, req);
386 386
387 X_LOCK (pool->reslock); 387 X_LOCK (pool->reslock);
388 388
389 ++pool->npending; 389 ++pool->npending;
390 390
391 if (!reqq_push (&pool->res_queue, req)) 391 if (!reqq_push (&pool->res_queue, req))
392 ETP_WANT_POLL (poll); 392 ETP_WANT_POLL (pool);
393 393
394 etp_worker_clear (self); 394 etp_worker_clear (self);
395 395
396 X_UNLOCK (pool->reslock); 396 X_UNLOCK (pool->reslock);
397 } 397 }
485 etp_maybe_start_thread (pool); 485 etp_maybe_start_thread (pool);
486 486
487 X_LOCK (pool->reslock); 487 X_LOCK (pool->reslock);
488 req = reqq_shift (&pool->res_queue); 488 req = reqq_shift (&pool->res_queue);
489 489
490 if (req) 490 if (ecb_expect_true (req))
491 { 491 {
492 --pool->npending; 492 --pool->npending;
493 493
494 if (!pool->res_queue.size) 494 if (!pool->res_queue.size)
495 ETP_DONE_POLL (pool->userdata); 495 ETP_DONE_POLL (pool);
496 } 496 }
497 497
498 X_UNLOCK (pool->reslock); 498 X_UNLOCK (pool->reslock);
499 499
500 if (!req) 500 if (ecb_expect_false (!req))
501 return 0; 501 return 0;
502 502
503 X_LOCK (pool->reqlock); 503 X_LOCK (pool->reqlock);
504 --pool->nreqs; 504 --pool->nreqs;
505 X_UNLOCK (pool->reqlock); 505 X_UNLOCK (pool->reqlock);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines