~rdoering/ubuntu/karmic/erlang/fix-535090

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_async.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090215164252-q5x4rcf8a5pbesb1
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
    erts_mtx_unlock(&q->mtx);
161
161
}
162
162
 
163
 
static void
164
 
prepare_for_block(void *vmtxp)
165
 
{
166
 
    erts_mtx_unlock((erts_mtx_t *) vmtxp);
167
 
}
168
 
 
169
 
static void
170
 
resume_after_block(void *vmtxp)
171
 
{
172
 
    erts_mtx_lock((erts_mtx_t *) vmtxp);
173
 
}
174
 
 
175
 
 
176
163
static ErlAsync* async_get(AsyncQueue* q)
177
164
{
178
165
    ErlAsync* a;
179
166
 
180
167
    erts_mtx_lock(&q->mtx);
181
 
    erts_smp_activity_change(ERTS_ACTIVITY_IO,
182
 
                             ERTS_ACTIVITY_WAIT,
183
 
                             prepare_for_block,
184
 
                             resume_after_block,
185
 
                             (void *) &q->mtx);
186
168
    while((a = q->tail) == NULL) {
187
169
        erts_cnd_wait(&q->cv, &q->mtx);
188
170
    }
189
 
    erts_smp_activity_change(ERTS_ACTIVITY_WAIT,
190
 
                             ERTS_ACTIVITY_IO,
191
 
                             prepare_for_block,
192
 
                             resume_after_block,
193
 
                             (void *) &q->mtx);
194
171
#ifdef ERTS_SMP
195
172
    ASSERT(a && q->tail == a);
196
173
#endif
254
231
    }
255
232
#endif
256
233
 
257
 
#ifdef ERTS_SMP
258
 
    erts_register_blockable_thread();
259
 
#endif
260
 
 
261
 
    erts_smp_activity_begin(ERTS_ACTIVITY_IO, NULL, NULL, NULL);
262
 
 
263
234
    while(1) {
264
235
        ErlAsync* a = async_get(q);
265
236
 
304
275
        }
305
276
    }
306
277
 
307
 
    erts_smp_activity_end(ERTS_ACTIVITY_IO, NULL, NULL, NULL);
308
 
 
309
278
    return NULL;
310
279
}
311
280