File tree Expand file tree Collapse file tree 4 files changed +31
-23
lines changed Expand file tree Collapse file tree 4 files changed +31
-23
lines changed Original file line number Diff line number Diff line change @@ -1110,7 +1110,6 @@ var LibraryPThread = {
1110
1110
}
1111
1111
worker . postMessage ( { 'cmd' : 'processProxyingQueue' , 'queue' : queue } ) ;
1112
1112
}
1113
- return 1 ;
1114
1113
}
1115
1114
} ;
1116
1115
Original file line number Diff line number Diff line change 5
5
* found in the LICENSE file.
6
6
*/
7
7
8
+ #include <emscripten/threading.h>
9
+ #include <stdatomic.h>
8
10
#include <stdlib.h>
9
11
#include <string.h>
10
12
@@ -102,3 +104,27 @@ task em_task_queue_dequeue(em_task_queue* queue) {
102
104
queue -> head = (queue -> head + 1 ) % queue -> capacity ;
103
105
return t ;
104
106
}
107
+
108
+ // Send a postMessage notification containing the em_task_queue pointer to the
109
+ // target thread so it will execute the queue when it returns to the event loop.
110
+ // Also pass in the current thread and main thread ids to minimize calls back
111
+ // into Wasm.
112
+ void _emscripten_notify_task_queue (pthread_t target_thread ,
113
+ pthread_t curr_thread ,
114
+ pthread_t main_thread ,
115
+ em_task_queue * queue );
116
+
117
+ void em_task_queue_notify (em_task_queue * queue ) {
118
+ // If there is no pending notification for this queue, create one. If an old
119
+ // notification is currently being processed, it may or may not execute this
120
+ // work. In case it does not, the new notification will ensure the work is
121
+ // still executed.
122
+ notification_state previous =
123
+ atomic_exchange (& queue -> notification , NOTIFICATION_PENDING );
124
+ if (previous != NOTIFICATION_PENDING ) {
125
+ _emscripten_notify_task_queue (queue -> thread ,
126
+ pthread_self (),
127
+ emscripten_main_browser_thread_id (),
128
+ queue );
129
+ }
130
+ }
Original file line number Diff line number Diff line change @@ -41,15 +41,6 @@ typedef struct em_task_queue {
41
41
int tail ;
42
42
} em_task_queue ;
43
43
44
- // Send a postMessage notification containing the em_task_queue pointer to the
45
- // target thread so it will execute the queue when it returns to the event loop.
46
- // Also pass in the current thread and main thread ids to minimize calls back
47
- // into Wasm.
48
- extern int _emscripten_notify_task_queue (pthread_t target_thread ,
49
- pthread_t curr_thread ,
50
- pthread_t main_thread ,
51
- em_task_queue * queue );
52
-
53
44
em_task_queue * em_task_queue_create (pthread_t thread );
54
45
55
46
void em_task_queue_destroy (em_task_queue * queue );
@@ -72,3 +63,7 @@ int em_task_queue_enqueue(em_task_queue* queue, task t);
72
63
73
64
// Not thread safe. Assumes the queue is not empty.
74
65
task em_task_queue_dequeue (em_task_queue * queue );
66
+
67
+ // Schedule the queue to be executed next time its owning thread returns to its
68
+ // event loop.
69
+ void em_task_queue_notify (em_task_queue * queue );
Original file line number Diff line number Diff line change 9
9
#include <emscripten/proxying.h>
10
10
#include <emscripten/threading.h>
11
11
#include <pthread.h>
12
- #include <stdatomic.h>
13
12
#include <stdlib.h>
14
13
#include <string.h>
15
14
@@ -268,18 +267,7 @@ int emscripten_proxy_async(em_proxying_queue* q,
268
267
return 0 ;
269
268
}
270
269
271
- // If there is no pending notification for this queue, create one. If an old
272
- // notification is currently being processed, it may or may not execute this
273
- // work. In case it does not, the new notification will ensure the work is
274
- // still executed.
275
- notification_state previous =
276
- atomic_exchange (& tasks -> notification , NOTIFICATION_PENDING );
277
- if (previous != NOTIFICATION_PENDING ) {
278
- _emscripten_notify_task_queue (target_thread ,
279
- pthread_self (),
280
- emscripten_main_browser_thread_id (),
281
- tasks );
282
- }
270
+ em_task_queue_notify (tasks );
283
271
return 1 ;
284
272
}
285
273
You can’t perform that action at this time.
0 commit comments