-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsgl_stack.h
More file actions
34 lines (27 loc) · 694 Bytes
/
Copy pathsgl_stack.h
File metadata and controls
34 lines (27 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifdef __APPLE__
#ifndef SGL_STACK
#define SGL_STACK
#include <iostream>
#include <stack>
#include <pthread.h>
#include "pthread_add.h"
using namespace std;
pthread_mutex_t SGL_stack_lock;
void SGL_s_push(stack<int> *stack, size_t num, bool test){
pthread_mutex_lock(&SGL_stack_lock);
stack->push(num);
// for testing
if(test) printf("+%i ", stack->top());
pthread_mutex_unlock(&SGL_stack_lock);
}
void SGL_s_pop(stack<int> *stack, bool test){
pthread_mutex_lock(&SGL_stack_lock);
while (!stack->empty()) {
// for testing
if(test) printf("-%i ", stack->top());
stack->pop();
}
pthread_mutex_unlock(&SGL_stack_lock);
}
#endif // SGL_STACK
#endif // __APPLE__