Add shared memory apis to redbean

You can now do things like implement mutexes using futexes in your
redbean lua code. This provides the fastest possible inter-process
communication for your production systems when SQLite alone as ipc
or things like pipes aren't sufficient.
This commit is contained in:
Justine Tunney 2022-10-06 04:55:26 -07:00
parent 81ee11a16e
commit 7822917fc2
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
21 changed files with 988 additions and 23 deletions

View file

@ -106,7 +106,7 @@ int nsync_futex_wait_ (int *p, int expect, char pshare, struct timespec *timeout
uint32_t ms;
int rc, op, fop;
if (!FUTEX_IS_SUPPORTED) {
if (!FUTEX_IS_SUPPORTED || (IsWindows() && pshare)) {
nsync_yield_ ();
if (timeout) {
return -EINTR;
@ -166,12 +166,12 @@ int nsync_futex_wait_ (int *p, int expect, char pshare, struct timespec *timeout
}
int nsync_futex_wake_ (int *p, int count, char pshare) {
int rc, op, fop;
int e, rc, op, fop;
int wake (void *, int, int) asm ("_futex");
ASSERT (count == 1 || count == INT_MAX);
if (!FUTEX_IS_SUPPORTED) {
if (!FUTEX_IS_SUPPORTED || (IsWindows() && pshare)) {
nsync_yield_ ();
return 0;
}