source: libcfa/src/bits/weakso_locks.hfa @ 6047b00

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 6047b00 was 352cbc2, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Added missing pragma once

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[ab1b971]1//
2// Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// bits/weakso_locks.hfa -- PUBLIC
8// Runtime locks that are compiled out when used without linking the runtime
9// thread system.
10//
11// Author           : Thierry Delisle
12// Created On       : Thu Jan 21 19:46:50 2021
13// Last Modified By :
14// Last Modified On :
15// Update Count     :
16//
17
[352cbc2]18#pragma once
19
[ab1b971]20#include "bits/locks.hfa"
21#include "bits/sequence.hfa"
22#include "bits/containers.hfa"
23
24struct $thread;
25
26//-----------------------------------------------------------------------------
27// Blocking Locks
28struct blocking_lock {
29        // Spin lock used for mutual exclusion
30        __spinlock_t lock;
31
32        // List of blocked threads
33        Sequence( $thread ) blocked_threads;
34
35        // Count of current blocked threads
36        size_t wait_count;
37
38        // Flag if the lock allows multiple acquisition
39        bool multi_acquisition;
40
41        // Flag if lock can be released by non owner
42        bool strict_owner;
43
44        // Current thread owning the lock
45        struct $thread * owner;
46
47        // Number of recursion level
48        size_t recursion_count;
49};
50
51void  ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner ) OPTIONAL_THREAD;
52void ^?{}( blocking_lock & this ) OPTIONAL_THREAD;
53
54void lock( blocking_lock & this ) OPTIONAL_THREAD;
55bool try_lock( blocking_lock & this ) OPTIONAL_THREAD;
56void unlock( blocking_lock & this ) OPTIONAL_THREAD;
57void on_notify( blocking_lock & this, struct $thread * t ) OPTIONAL_THREAD;
58void on_wait( blocking_lock & this ) OPTIONAL_THREAD;
59size_t wait_count( blocking_lock & this ) OPTIONAL_THREAD;
60void set_recursion_count( blocking_lock & this, size_t recursion ) OPTIONAL_THREAD;
61size_t get_recursion_count( blocking_lock & this ) OPTIONAL_THREAD;
62
63//----------
64struct multiple_acquisition_lock {
65        inline blocking_lock;
66};
67
68
69static inline void  ?{}( multiple_acquisition_lock & this ) {((blocking_lock &)this){ true, false };}
70static inline void ^?{}( multiple_acquisition_lock & this ) {}
71static inline void   lock     ( multiple_acquisition_lock & this ) { lock   ( (blocking_lock &)this ); }
72static inline void   unlock   ( multiple_acquisition_lock & this ) { unlock ( (blocking_lock &)this ); }
73static inline void   on_wait  ( multiple_acquisition_lock & this ) { on_wait( (blocking_lock &)this ); }
74static inline void   on_notify( multiple_acquisition_lock & this, struct $thread * t ){ on_notify( (blocking_lock &)this, t ); }
75static inline void   set_recursion_count( multiple_acquisition_lock & this, size_t recursion ){ set_recursion_count( (blocking_lock &)this, recursion ); }
76static inline size_t get_recursion_count( multiple_acquisition_lock & this ){ return get_recursion_count( (blocking_lock &)this ); }
Note: See TracBrowser for help on using the repository browser.