/* internal functions */
#ifdef WIN32
-THREAD_RET_TYPE thread_run(LPVOID arg);
+THREAD_RET_TYPE Perl_thread_run(LPVOID arg);
#else
-void thread_run(ithread* thread);
+void Perl_thread_run(ithread* thread);
#endif
-void thread_destruct(ithread* thread);
+void Perl_thread_destruct(ithread* thread);
/* Perl mapped functions to iThread:: */
-SV* thread_create(char* class, SV* function_to_call, SV* params);
-I32 thread_tid (SV* obj);
-void thread_join(SV* obj);
-void thread_detach(SV* obj);
-SV* thread_self (char* class);
+SV* Perl_thread_create(char* class, SV* function_to_call, SV* params);
+I32 Perl_thread_tid (SV* obj);
+void Perl_thread_join(SV* obj);
+void Perl_thread_detach(SV* obj);
+SV* Perl_thread_self (char* class);
*/
#ifdef WIN32
-THREAD_RET_TYPE thread_run(LPVOID arg) {
+THREAD_RET_TYPE Perl_thread_run(LPVOID arg) {
ithread* thread = (ithread*) arg;
#else
-void thread_run(ithread* thread) {
+void Perl_thread_run(ithread* thread) {
#endif
SV* thread_tid_ptr;
SV* thread_ptr;
perl_free(thread->interp);
if(thread->detached == 1) {
MUTEX_UNLOCK(&thread->mutex);
- thread_destruct(thread);
+ Perl_thread_destruct(thread);
} else {
MUTEX_UNLOCK(&thread->mutex);
}
iThread->create();
*/
-SV* thread_create(char* class, SV* init_function, SV* params) {
+SV* Perl_thread_create(char* class, SV* init_function, SV* params) {
ithread* thread = malloc(sizeof(ithread));
SV* obj_ref;
SV* obj;
/* lets init the thread */
-// thread->mutex = (perl_mutex) malloc(sizeof(perl_mutex));
+
MUTEX_INIT(&thread->mutex);
#ifdef WIN32
- thread->handle = CreateThread(NULL, 0, thread_run,
+ thread->handle = CreateThread(NULL, 0, Perl_thread_run,
(LPVOID)thread, 0, &thread->thr);
#else
- pthread_create( &thread->thr, NULL, (void *) thread_run, thread);
+ pthread_create( &thread->thr, NULL, (void *) Perl_thread_run, thread);
#endif
MUTEX_UNLOCK(&create_mutex);
/*
returns the id of the thread
*/
-I32 thread_tid (SV* obj) {
+I32 Perl_thread_tid (SV* obj) {
ithread* thread;
if(!SvROK(obj)) {
- obj = thread_self(SvPV_nolen(obj));
+ obj = Perl_thread_self(SvPV_nolen(obj));
thread = (ithread*)SvIV(SvRV(obj));
SvREFCNT_dec(obj);
} else {
return thread->tid;
}
-SV* thread_self (char* class) {
+SV* Perl_thread_self (char* class) {
dTHX;
SV* obj_ref;
SV* obj;
this code needs to take the returnvalue from the call_sv and send it back
*/
-void thread_join(SV* obj) {
+void Perl_thread_join(SV* obj) {
ithread* thread = (ithread*)SvIV(SvRV(obj));
#ifdef WIN32
DWORD waitcode;
needs to better clean up memory
*/
-void thread_detach(SV* obj) {
+void Perl_thread_detach(SV* obj) {
ithread* thread = (ithread*)SvIV(SvRV(obj));
MUTEX_LOCK(&thread->mutex);
thread->detached = 1;
-void thread_DESTROY (SV* obj) {
+void Perl_thread_DESTROY (SV* obj) {
ithread* thread = (ithread*)SvIV(SvRV(obj));
MUTEX_LOCK(&thread->mutex);
thread->count--;
MUTEX_UNLOCK(&thread->mutex);
- thread_destruct(thread);
+ Perl_thread_destruct(thread);
}
-void thread_destruct (ithread* thread) {
+void Perl_thread_destruct (ithread* thread) {
return;
MUTEX_LOCK(&thread->mutex);
if(thread->count != 0) {
av_push(params, ST(i));
}
}
- RETVAL = thread_create(class, function_to_call, newRV_noinc((SV*) params));
+ RETVAL = Perl_thread_create(class, function_to_call, newRV_noinc((SV*) params));
OUTPUT:
RETVAL
self (class)
char* class
CODE:
- RETVAL = thread_self(class);
+ RETVAL = Perl_thread_self(class);
OUTPUT:
RETVAL
tid (obj)
SV * obj;
CODE:
- RETVAL = thread_tid(obj);
+ RETVAL = Perl_thread_tid(obj);
OUTPUT:
RETVAL
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
- thread_join(obj);
+ Perl_thread_join(obj);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
- thread_detach(obj);
+ Perl_thread_detach(obj);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;
I32* temp;
PPCODE:
temp = PL_markstack_ptr++;
- thread_DESTROY(obj);
+ Perl_thread_DESTROY(obj);
if (PL_markstack_ptr != temp) {
/* truly void, because dXSARGS not invoked */
PL_markstack_ptr = temp;