This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
f92a94a08ea166d7aeee3b0db7e2edcc721624ce
[perl5.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 extern PerlInterpreter* sharedsv_space;
14 extern perl_mutex  sharedsv_space_mutex;
15
16 void Perl_sharedsv_unlock_scope(pTHX_ shared_sv* ssv);
17 void Perl_sharedsv_unlock(pTHX_ shared_sv* ssv);
18 void Perl_sharedsv_lock(pTHX_ shared_sv* ssv);
19 void Perl_sharedsv_init(pTHX);
20 shared_sv* Perl_sharedsv_new(pTHX);
21 shared_sv* Perl_sharedsv_find(pTHX_ SV* sv);
22 void Perl_sharedsv_thrcnt_inc(pTHX_ shared_sv* ssv);
23 void Perl_sharedsv_thrcnt_dec(pTHX_ shared_sv* ssv);
24
25
26 #define SHAREDSvGET(a)     (a->sv)
27 #define SHAREDSvEDIT(a)    { MUTEX_LOCK(&sharedsv_space_mutex);\
28 SHAREDSvLOCK((a));\
29 PERL_SET_CONTEXT(sharedsv_space);\
30 }
31 #define SHAREDSvRELEASE(a) { PERL_SET_CONTEXT((a)->owner);\
32 SHAREDSvUNLOCK((a));\
33 MUTEX_UNLOCK(&sharedsv_space_mutex);\
34 }
35 #define SHAREDSvLOCK(a)    Perl_sharedsv_lock(aTHX_ a)
36 #define SHAREDSvUNLOCK(a)  Perl_sharedsv_unlock(aTHX_ a)
37
38 #endif /* USE_ITHREADS */
39