@@ -11,10 +11,8 @@ import core.internal.abort : abort;
11
11
12
12
struct OsEvent
13
13
{
14
- void create (bool manualReset, bool initialState) nothrow @trusted @nogc
14
+ this (bool manualReset, bool initialState) nothrow @trusted @nogc
15
15
{
16
- if (m_initalized)
17
- return ;
18
16
pthread_mutex_init(cast (pthread_mutex_t * ) &m_mutex, null ) == 0 ||
19
17
abort(" Error: pthread_mutex_init failed." );
20
18
static if ( is ( typeof ( pthread_condattr_setclock ) ) )
@@ -37,40 +35,29 @@ struct OsEvent
37
35
38
36
m_state = initialState;
39
37
m_manualReset = manualReset;
40
- m_initalized = true ;
41
38
}
42
39
43
- void destroy () nothrow @trusted @nogc
40
+ ~this () nothrow @trusted @nogc
44
41
{
45
- if (m_initalized)
46
- {
47
- pthread_mutex_destroy(&m_mutex) == 0 ||
48
- abort(" Error: pthread_mutex_destroy failed." );
49
- pthread_cond_destroy(&m_cond) == 0 ||
50
- abort(" Error: pthread_cond_destroy failed." );
51
- m_initalized = false ;
52
- }
42
+ pthread_mutex_destroy(&m_mutex) == 0 ||
43
+ abort(" Error: pthread_mutex_destroy failed." );
44
+ pthread_cond_destroy(&m_cond) == 0 ||
45
+ abort(" Error: pthread_cond_destroy failed." );
53
46
}
54
47
55
- void setIfInitialized () nothrow @trusted @nogc
48
+ void set () nothrow @trusted @nogc
56
49
{
57
- if (m_initalized)
58
- {
59
- pthread_mutex_lock(&m_mutex);
60
- m_state = true ;
61
- pthread_cond_broadcast(&m_cond);
62
- pthread_mutex_unlock(&m_mutex);
63
- }
50
+ pthread_mutex_lock(&m_mutex);
51
+ m_state = true ;
52
+ pthread_cond_broadcast(&m_cond);
53
+ pthread_mutex_unlock(&m_mutex);
64
54
}
65
55
66
56
void reset () nothrow @trusted @nogc
67
57
{
68
- if (m_initalized)
69
- {
70
- pthread_mutex_lock(&m_mutex);
71
- m_state = false ;
72
- pthread_mutex_unlock(&m_mutex);
73
- }
58
+ pthread_mutex_lock(&m_mutex);
59
+ m_state = false ;
60
+ pthread_mutex_unlock(&m_mutex);
74
61
}
75
62
76
63
bool wait () nothrow @trusted @nogc
@@ -80,9 +67,6 @@ struct OsEvent
80
67
81
68
bool wait (Duration tmout) nothrow @trusted @nogc
82
69
{
83
- if (! m_initalized)
84
- return false ;
85
-
86
70
pthread_mutex_lock(&m_mutex);
87
71
88
72
int result = 0 ;
@@ -114,7 +98,6 @@ private:
114
98
115
99
pthread_mutex_t m_mutex;
116
100
pthread_cond_t m_cond;
117
- bool m_initalized;
118
101
bool m_state;
119
102
bool m_manualReset;
120
103
}
0 commit comments