Skip to content

Commit 9c58605

Browse files
committed
Implement thread lock acquire/release.
1 parent b5ae7a4 commit 9c58605

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

graalpython/com.oracle.graal.python.cext/src/ceval.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ UPCALL_ID(PyThread_allocate_lock);
6161
void* PyThread_allocate_lock() {
6262
return UPCALL_CEXT_O(_jls_PyThread_allocate_lock);
6363
}
64+
65+
UPCALL_ID(PyThread_acquire_lock);
66+
int PyThread_acquire_lock(PyThread_type_lock aLock, int waitflag) {
67+
return UPCALL_CEXT_O(_jls_PyThread_acquire_lock, native_to_java(aLock), waitflag ? -1 : 0);
68+
}
69+
70+
UPCALL_ID(PyThread_release_lock);
71+
void PyThread_release_lock(PyThread_type_lock aLock) {
72+
UPCALL_CEXT_O(_jls_PyThread_release_lock, native_to_java(aLock));
73+
}

graalpython/lib-graalpython/python_cext.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,16 @@ def PyThread_allocate_lock():
13041304
return _thread.allocate_lock()
13051305

13061306

1307+
@may_raise
1308+
def PyThread_acquire_lock(lock, waitflag):
1309+
return lock.acquire(waitflag)
1310+
1311+
1312+
@may_raise
1313+
def PyThread_release_lock(lock):
1314+
return lock.release()
1315+
1316+
13071317
@may_raise
13081318
def PySlice_GetIndicesEx(start, stop, step, length):
13091319
return PyTruffleSlice_GetIndicesEx(start, stop, step, length)

0 commit comments

Comments
 (0)