diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-04-11 13:47:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-04-11 13:47:05 +0000 |
commit | 71ad1b0c3807f6097c8da083d9dcbd8c03af5f43 (patch) | |
tree | 12c9b0a815e473eaaa9934f5faacba27b9447e30 /hv.h | |
parent | d39614506f118e8a474f0a8c4b7f7cd7e0e74f51 (diff) | |
download | perl-71ad1b0c3807f6097c8da083d9dcbd8c03af5f43.tar.gz |
Need to migrate the refcounted_he structure to be properly shared.
Add a mutex for manipulated their reference counts.
Unwrap the structure, so that for ithreads it can store SVs in pads.
p4raw-id: //depot/perl@27764
Diffstat (limited to 'hv.h')
-rw-r--r-- | hv.h | 37 |
1 files changed, 32 insertions, 5 deletions
@@ -36,11 +36,6 @@ struct shared_he { struct hek shared_he_hek; }; -struct refcounted_he { - struct he refcounted_he_he; - U32 refcounted_he_refcnt; -}; - /* Subject to change. Don't access this directly. */ @@ -383,6 +378,38 @@ C<SV*>. ->shared_he_he.he_valu.hent_refcount), \ hek) +/* This refcounted he structure is used for storing the hints used for lexical + pragmas. Without threads, it's basically struct he + refcount. + With threads, life gets more complex as the structure needs to be shared + between threads (because it hangs from OPs, which are shared), hence the + alternate definition and mutex. */ + +#ifdef PERL_CORE + +struct refcounted_he { + struct refcounted_he *refcounted_he_next; /* next entry in chain */ + HEK *refcounted_he_hek; /* hint key */ + SV *refcounted_he_val; /* hint value */ + U32 refcounted_he_refcnt; /* reference count */ +}; + +# ifdef USE_ITHREADS +# define HINTS_REFCNT_LOCK MUTEX_LOCK(&PL_hints_mutex) +# define HINTS_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_hints_mutex) +# else +# define HINTS_REFCNT_LOCK NOOP +# define HINTS_REFCNT_UNLOCK NOOP +# endif +#endif + +#ifdef USE_ITHREADS +# define HINTS_REFCNT_INIT MUTEX_INIT(&PL_hints_mutex) +# define HINTS_REFCNT_TERM MUTEX_DESTROY(&PL_hints_mutex) +#else +# define HINTS_REFCNT_INIT NOOP +# define HINTS_REFCNT_TERM NOOP +#endif + /* * Local variables: * c-indentation-style: bsd |