etpan-thread-manager-types.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
  3. * Copyright (C) 2005-2012 DINH Viet Hoa and the Claws Mail team
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. */
  19. #ifndef ETPAN_THREAD_MANAGER_TYPES_H
  20. #define ETPAN_THREAD_MANAGER_TYPES_H
  21. #include <pthread.h>
  22. #include <libetpan/libetpan.h>
  23. struct etpan_thread_manager {
  24. /* thread pool */
  25. carray * thread_pool;
  26. carray * thread_pending;
  27. int can_create_thread;
  28. int unbound_count;
  29. int notify_fds[2];
  30. };
  31. struct etpan_thread {
  32. struct etpan_thread_manager * manager;
  33. pthread_t th_id;
  34. pthread_mutex_t lock;
  35. carray * op_list;
  36. carray * op_done_list;
  37. int bound_count;
  38. int terminate_state;
  39. struct mailsem * start_sem;
  40. struct mailsem * stop_sem;
  41. struct mailsem * op_sem;
  42. };
  43. struct etpan_thread_op {
  44. struct etpan_thread * thread;
  45. void (* run)(struct etpan_thread_op * op);
  46. void (* callback)(int cancelled, void * result, void * callback_data);
  47. void * callback_data;
  48. void (* cleanup)(struct etpan_thread_op * op);
  49. pthread_mutex_t lock;
  50. int callback_called;
  51. int cancellable;
  52. int cancelled;
  53. void * param;
  54. void * result;
  55. int finished;
  56. mailimap *imap;
  57. newsnntp *nntp;
  58. };
  59. #endif