diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-04-23 19:06:45 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-04-23 19:06:45 +0000 |
commit | f93b4edd807be1c6102dad09f884828c27c4a58b (patch) | |
tree | 137d9c548c5e8c0dcbd6c3a76c121b5ce06ff663 /thread.h | |
parent | b35b24033ff5a2171d5dc795e027358506aa01ff (diff) | |
download | perl-f93b4edd807be1c6102dad09f884828c27c4a58b.tar.gz |
Added programmer-level condition variables via "condpair" magic.
Added support for detached threads and tweaked a few things.
p4raw-id: //depot/thrperl@8
Diffstat (limited to 'thread.h')
-rw-r--r-- | thread.h | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -121,10 +121,38 @@ struct thread { pthread_mutex_t * Tthreadstart_mutexp; HV * Tcvcache; + U32 Tthrflags; }; typedef struct thread *Thread; +/* Values and macros for thrflags */ +#define THR_STATE_MASK 3 +#define THR_NORMAL 0 +#define THR_DETACHED 1 +#define THR_JOINED 2 +#define THR_DEAD 3 + +#define ThrSTATE(t) (t->Tthrflags & THR_STATE_MASK) +#define ThrSETSTATE(t, s) STMT_START { \ + (t)->Tthrflags &= ~THR_STATE_MASK; \ + (t)->Tthrflags |= (s); \ + DEBUG_L(fprintf(stderr, "thread 0x%lx set to state %d\n", \ + (unsigned long)(t), (s))); \ + } STMT_END + +typedef struct condpair { + pthread_mutex_t mutex; + pthread_cond_t owner_cond; + pthread_cond_t cond; + Thread owner; +} condpair_t; + +#define MgMUTEXP(mg) (&((condpair_t *)(mg->mg_ptr))->mutex) +#define MgOWNERCONDP(mg) (&((condpair_t *)(mg->mg_ptr))->owner_cond) +#define MgCONDP(mg) (&((condpair_t *)(mg->mg_ptr))->cond) +#define MgOWNER(mg) ((condpair_t *)(mg->mg_ptr))->owner + #undef stack_base #undef stack_sp #undef stack_max @@ -202,5 +230,6 @@ typedef struct thread *Thread; #define runlevel (thr->Trunlevel) #define threadstart_mutexp (thr->Tthreadstart_mutexp) -#define cvcache (thr->Tcvcache) +#define cvcache (thr->Tcvcache) +#define thrflags (thr->Tthrflags) #endif /* USE_THREADS */ |