4
* Copyright Ericsson AB 2009-2010. All Rights Reserved.
6
* The contents of this file are subject to the Erlang Public License,
7
* Version 1.1, (the "License"); you may not use this file except in
8
* compliance with the License. You should have received a copy of the
9
* Erlang Public License along with this software. If not, it can be
10
* retrieved online at http://www.erlang.org/.
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and limitations
21
* Author: Rickard Green
24
#define ETHR_EVENT_OFF_WAITER__ ((long) -1)
25
#define ETHR_EVENT_OFF__ ((long) 1)
26
#define ETHR_EVENT_ON__ ((long) 0)
33
#if defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_EVENT_IMPL__)
35
#pragma intrinsic(_InterlockedExchange)
37
static ETHR_INLINE void
38
ETHR_INLINE_FUNC_NAME_(ethr_event_set)(ethr_event *e)
40
/* _InterlockedExchange() imply a full memory barrier which is important */
41
long state = _InterlockedExchange(&e->state, ETHR_EVENT_ON__);
42
if (state == ETHR_EVENT_OFF_WAITER__) {
43
if (!SetEvent(e->handle))
44
ETHR_FATAL_ERROR__(ethr_win_get_errno__());
48
static ETHR_INLINE void
49
ETHR_INLINE_FUNC_NAME_(ethr_event_reset)(ethr_event *e)
51
/* _InterlockedExchange() imply a full memory barrier which is important */
52
InterlockedExchange(&e->state, ETHR_EVENT_OFF__);
57
int ethr_event_init(ethr_event *e);
58
int ethr_event_destroy(ethr_event *e);
59
int ethr_event_wait(ethr_event *e);
60
int ethr_event_swait(ethr_event *e, int spincount);
61
#if !defined(ETHR_TRY_INLINE_FUNCS) || defined(ETHR_EVENT_IMPL__)
62
void ethr_event_set(ethr_event *e);
63
void ethr_event_reset(ethr_event *e);