FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codon/stdlib/threading.codon at develop · strider4560/codon · GitHub
strider4560
/
codon
Public
forked from
exaloop/codon
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codon
/
stdlib
/
threading.codon
Copy path
More file actions
More file actions
Latest commit
History
History
History
61 lines (45 loc) · 1.56 KB
Breadcrumbs
codon
/
stdlib
/
threading.codon
Copy path
File metadata and controls
61 lines (45 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyright (C) 2022-2026 Exaloop Inc. <https://exaloop.io>
# Thread-local variable indicator. Used internally by the compiler to mark ThreadLocal variables.
# Semantically identical to T.
@
tuple
class
ThreadLocal
[
T
]:
def
__new__
(
T
:
type
)
->
ThreadLocal
[
T
]:
compile_error
(
"this type cannot be instantiated"
)
@
tuple
class
Lock
:
p
:
cobj
def
__new__
()
->
Lock
:
return
Lock
(
_C
.
seq_lock_new
(),)
def
acquire
(
self
,
block
:
bool
=
True
,
timeout
:
float
=
-
1.0
)
->
bool
:
if
timeout
>=
0.0
and
not
block
:
raise
ValueError
(
"can't specify a timeout for a non-blocking call"
)
return
_C
.
seq_lock_acquire
(
self
.
p
,
block
,
timeout
)
def
release
(
self
):
_C
.
seq_lock_release
(
self
.
p
)
def
__enter__
(
self
):
self
.
acquire
()
def
__exit__
(
self
):
self
.
release
()
@
tuple
class
RLock
:
p
:
cobj
def
__new__
()
->
RLock
:
return
RLock
(
_C
.
seq_rlock_new
(),)
def
acquire
(
self
,
block
:
bool
=
True
,
timeout
:
float
=
-
1.0
)
->
bool
:
if
timeout
>=
0.0
and
not
block
:
raise
ValueError
(
"can't specify a timeout for a non-blocking call"
)
return
_C
.
seq_rlock_acquire
(
self
.
p
,
block
,
timeout
)
def
release
(
self
):
_C
.
seq_rlock_release
(
self
.
p
)
def
__enter__
(
self
):
self
.
acquire
()
def
__exit__
(
self
):
self
.
release
()
def
active_count
()
->
int
:
from
openmp
import
get_num_threads
return
get_num_threads
()
def
get_native_id
()
->
int
:
from
openmp
import
get_thread_num
return
get_thread_num
()
def
get_ident
()
->
int
:
return
get_native_id
()
+
1
Back
|
FazBrowse Home
|
New Git URL