Add the shared sv space to the global vars.
[p5sagit/p5-mst-13.2.git] / sharedsv.h
1
2 #ifdef USE_ITHREADS
3
4 typedef struct {
5     SV*              sv;    /* The actual data */
6     perl_mutex       mutex; /* Our mutex */
7     perl_cond        cond;  /* Our condition variable */
8     perl_cond        user_cond;  /* For user level conditions */
9     IV               locks; /* Number of locks held */
10     PerlInterpreter* owner; /* who owns the lock */
11 } shared_sv;
12
13
14
15 void Perl_sharedsv_unlock_scope(pTHX_ shared_sv* ssv);
16 void Perl_sharedsv_unlock(pTHX_ shared_sv* ssv);
17 void Perl_sharedsv_lock(pTHX_ shared_sv* ssv);
18 void Perl_sharedsv_init(pTHX);
19 shared_sv* Perl_sharedsv_new(pTHX);
20 shared_sv* Perl_sharedsv_find(pTHX_ SV* sv);
21 void Perl_sharedsv_thrcnt_inc(pTHX_ shared_sv* ssv);
22 void Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv);
23
24
25 #define SHAREDSvGET(a)     (a->sv)
26 #define SHAREDSvEDIT(a)    { MUTEX_LOCK(&PL_sharedsv_space_mutex);\
27 SHAREDSvLOCK((a));\
28 PERL_SET_CONTEXT(PL_sharedsv_space);\
29 }
30 #define SHAREDSvRELEASE(a) { PERL_SET_CONTEXT((a)->owner);\
31 SHAREDSvUNLOCK((a));\
32 MUTEX_UNLOCK(&PL_sharedsv_space_mutex);\
33 }
34 #define SHAREDSvLOCK(a)    Perl_sharedsv_lock(aTHX_ a)
35 #define SHAREDSvUNLOCK(a)  Perl_sharedsv_unlock(aTHX_ a)
36
37 #endif /* USE_ITHREADS */
38