mandelbrot.h 806 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <semaphore.h>
  4. #include <unistd.h>
  5. #include "../libpng/img.h"
  6. #include "config.h"
  7. typedef struct queue {
  8. struct queue_node_t *head;
  9. struct queue_node_t *tail;
  10. } queue_t;
  11. typedef struct mandel_t {
  12. int x;
  13. int y;
  14. } mandel_t;
  15. struct queue_node_t {
  16. mandel_t *node;
  17. struct queue_node_t *next;
  18. };
  19. typedef struct mandel_prop_t {
  20. int width;
  21. int height;
  22. int bail_out;
  23. int max_iter;
  24. } mandel_prop_t;
  25. typedef struct mandel_buf_t {
  26. queue_t *q;
  27. int *result_field;
  28. mandel_prop_t prop;
  29. pthread_mutex_t *lock;
  30. int produce_end;
  31. } mandel_buf_t;
  32. queue_t *initialize_queue();
  33. void enqueue(queue_t * q, mandel_t * w, pthread_mutex_t * lock);
  34. mandel_t *dequeue(queue_t * q, pthread_mutex_t * lock);
  35. void destroy_queue(queue_t * q);
  36. int is_empty(queue_t * q);