Back to index

courier  0.68.2
Functions
havepthread.h File Reference

Go to the source code of this file.

Functions

struct cthreadinfocthread_init (unsigned, unsigned, void(*)(void *), void(*)(void *))
void cthread_wait (struct cthreadinfo *)
int cthread_go (struct cthreadinfo *, void(*)(void *, void *), void *)
struct cthreadlockcthread_lockcreate (void)
void cthread_lockdestroy (struct cthreadlock *)
int cthread_lock (struct cthreadlock *, int(*)(void *), void *)

Function Documentation

int cthread_go ( struct cthreadinfo ,
void(*)(void *, void *)  ,
void *   
)
struct cthreadinfo* cthread_init ( unsigned  ,
unsigned  ,
void(*)(void *)  ,
void(*)(void *)   
) [read]

Definition at line 17 of file nopthread.c.

{
cthreadinfo_t *cit;

       if ((cit=(cthreadinfo_t *)malloc(sizeof(cthreadinfo_t))) == 0)
              return (0);

       cit->cleanupfunc=cleanupfunc_;
       cit->workfunc=workfunc_;

       if ( (cit->metadata_buf=malloc(metasize)) == 0)
       {
              free( (char *)cit );
              return (0);
       }
       return (cit);
}

Here is the caller graph for this function:

int cthread_lock ( struct cthreadlock ,
int(*)(void *)  ,
void *   
)

Definition at line 413 of file pthread.c.

{
int    rc;

       while (pthread_mutex_lock(&p->mutex))
       {
              perror("pthread_mutex_lock");
              sleep(3);
       }

       pthread_cleanup_push(&mutexcleanup, (void *)&p->mutex);

       rc= (*func)(arg);

       if (PTHREAD_CHK(pthread_mutex_unlock( &p->mutex )))
              perror("pthread_mutex_unlock");
       pthread_cleanup_pop(0);
       return (rc);
}
struct cthreadlock* cthread_lockcreate ( void  ) [read]

Definition at line 382 of file pthread.c.

{
struct cthreadlock *p= (struct cthreadlock *)malloc(sizeof(struct cthreadlock));
pthread_mutexattr_t mattr;

       if (!p)       return (0);

       if (PTHREAD_CHK(pthread_mutexattr_init(&mattr)))
       {
              errno=EIO;
              free( (char *)p );
              return (0);
       }

       if (PTHREAD_CHK(pthread_mutex_init(&p->mutex, &mattr)))
       {
              pthread_mutexattr_destroy(&mattr);
              errno=EIO;
              free( (char *)p );
              return (0);
       }
       pthread_mutexattr_destroy(&mattr);
       return (p);
}
void cthread_lockdestroy ( struct cthreadlock )

Definition at line 407 of file pthread.c.

{
       pthread_mutex_destroy(&p->mutex);
       free( (char *)p );
}
void cthread_wait ( struct cthreadinfo )

Here is the caller graph for this function: