| 53 | } |
| 54 | |
| 55 | void push(type const &elem) { |
| 56 | // Lock |
| 57 | pthread_mutex_lock (&mutex); |
| 58 | |
| 59 | /* |
| 60 | * Wait/block if limit has been reached |
| 61 | */ |
| 62 | if (limit and size() >= limit) { |
| 63 | pthread_mutex_unlock (&mutex); |
| 64 | |
| 65 | while (size() >= limit) { |
| 66 | usleep(10000); |
| 67 | } |
| 68 | |
| 69 | pthread_mutex_lock (&mutex); |
| 70 | } |
| 71 | |
| 72 | // Add |
| 73 | queue<type>::push(elem); |
| 74 | |
| 75 | // Unlock |
| 76 | pthread_mutex_unlock (&mutex); |
| 77 | } |
| 78 | |
| 79 | void pop() { |
| 80 |
nothing calls this directly
no outgoing calls
no test coverage detected