Mercurial > love-experiments
annotate src/modules/thread/wrap_Channel.cpp @ 1448:108ee2e81f65 default tip
Fix a case typo, imageData.h -> ImageData.h
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sat, 18 Jan 2014 13:57:44 +0100 |
| parents | f6ff61fc266f |
| children |
| rev | line source |
|---|---|
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
1 /** |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2006-2010 LOVE Development Team |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
3 * |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
4 * This software is provided 'as-is', without any express or implied |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
5 * warranty. In no event will the authors be held liable for any damages |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
6 * arising from the use of this software. |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
7 * |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
8 * Permission is granted to anyone to use this software for any purpose, |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
9 * including commercial applications, and to alter it and redistribute it |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
10 * freely, subject to the following restrictions: |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
11 * |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
12 * 1. The origin of this software must not be misrepresented; you must not |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
13 * claim that you wrote the original software. If you use this software |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
14 * in a product, an acknowledgment in the product documentation would be |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
15 * appreciated but is not required. |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
16 * 2. Altered source versions must be plainly marked as such, and must not be |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
17 * misrepresented as being the original software. |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
18 * 3. This notice may not be removed or altered from any source distribution. |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
19 **/ |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
20 |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
21 #include "wrap_Channel.h" |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
22 |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
23 namespace love |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
24 { |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
25 namespace thread |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
26 { |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
27 void retainVariant(Channel *c, Variant *v) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
28 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
29 c->lockMutex(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
30 v->retain(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
31 c->unlockMutex(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
32 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
33 |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
34 void releaseVariant(Channel *c, Variant *v) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
35 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
36 c->lockMutex(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
37 v->release(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
38 c->unlockMutex(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
39 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
40 |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
41 Channel *luax_checkchannel(lua_State *L, int idx) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
42 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
43 return luax_checktype<Channel>(L, idx, "Channel", THREAD_CHANNEL_T); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
44 } |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
45 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
46 int w_Channel_push(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
47 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
48 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
49 Variant *var = Variant::fromLua(L, 2); |
|
1413
f6ff61fc266f
Added argument type checking to Channel:push (nil now errors instead of crashing)
Alex Szpakowski <slime73@gmail.com>
parents:
1304
diff
changeset
|
50 if (!var) |
|
f6ff61fc266f
Added argument type checking to Channel:push (nil now errors instead of crashing)
Alex Szpakowski <slime73@gmail.com>
parents:
1304
diff
changeset
|
51 return luaL_argerror(L, 2, "boolean, number, string, or love userdata expected"); |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
52 c->push(var); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
53 releaseVariant(c, var); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
54 return 0; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
55 } |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
56 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
57 int w_Channel_supply(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
58 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
59 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
60 Variant *var = Variant::fromLua(L, 2); |
|
1413
f6ff61fc266f
Added argument type checking to Channel:push (nil now errors instead of crashing)
Alex Szpakowski <slime73@gmail.com>
parents:
1304
diff
changeset
|
61 if (!var) |
|
f6ff61fc266f
Added argument type checking to Channel:push (nil now errors instead of crashing)
Alex Szpakowski <slime73@gmail.com>
parents:
1304
diff
changeset
|
62 return luaL_argerror(L, 2, "boolean, number, string, or love userdata expected"); |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
63 c->supply(var); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
64 releaseVariant(c, var); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
65 return 0; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
66 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
67 |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
68 int w_Channel_pop(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
69 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
70 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
71 Variant *var = c->pop(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
72 if (var) |
|
1197
1a59c21cd2f3
Add Channel:supply(), a blocking version of Channel:push()
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1098
diff
changeset
|
73 { |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
74 var->toLua(L); |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
75 releaseVariant(c, var); |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
76 } |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
77 else |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
78 lua_pushnil(L); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
79 return 1; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
80 } |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
81 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
82 int w_Channel_demand(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
83 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
84 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
85 Variant *var = c->demand(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
86 var->toLua(L); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
87 releaseVariant(c, var); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
88 return 1; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
89 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
90 |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
91 int w_Channel_peek(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
92 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
93 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
94 Variant *var = c->peek(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
95 if (var) |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
96 { |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
97 var->toLua(L); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
98 releaseVariant(c, var); |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
99 } |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
100 else |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
101 lua_pushnil(L); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
102 return 1; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
103 } |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
104 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
105 int w_Channel_count(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
106 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
107 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
108 lua_pushnumber(L, c->count()); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
109 return 1; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
110 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
111 |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
112 int w_Channel_clear(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
113 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
114 Channel *c = luax_checkchannel(L, 1); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
115 c->clear(); |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
116 return 0; |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
117 } |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
118 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
119 static const luaL_Reg type_functions[] = { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
120 { "push", w_Channel_push }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
121 { "supply", w_Channel_supply }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
122 { "pop", w_Channel_pop }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
123 { "demand", w_Channel_demand }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
124 { "peek", w_Channel_peek }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
125 { "count", w_Channel_count }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
126 { "clear", w_Channel_clear }, |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
127 { 0, 0 } |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
128 }; |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
129 |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
130 extern "C" int luaopen_channel(lua_State *L) |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
131 { |
|
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
132 return luax_register_type(L, "Channel", type_functions); |
|
1098
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
133 } |
|
a74672ba1320
Merge in channels from love-experiments
Bart van Strien <bart.bes+projects@gmail.com>
parents:
diff
changeset
|
134 } |
|
1304
ee1448bb9680
Fix race conditions and deadlocks in Channels (hopefully) (issue #554)
Bart van Strien <bart.bes+projects@gmail.com>
parents:
1197
diff
changeset
|
135 } |
