/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to libssts/Thread.c

  • Committer: Gustav Hartvigsson
  • Date: 2016-02-01 14:29:35 UTC
  • mfrom: (121.1.4 simpletypesystem_gc)
  • Revision ID: gustav.hartvigsson@gmail.com-20160201142935-tz7ef63id2g3yfof
* Merged GC branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
SMutex *
39
39
s_mutex_new () {
40
 
  SMutex * self = malloc (sizeof (SMutex));
41
 
  
42
 
  self->mutex = malloc (sizeof (mtx_t));
43
 
  
 
40
  SMutex * self = s_malloc (sizeof (SMutex));
 
41
 
 
42
  self->mutex = s_malloc (sizeof (mtx_t));
 
43
 
44
44
  atomic_init(&(self->locked), FALSE);
45
 
  
 
45
 
46
46
  sint status = mtx_init (self->mutex, mtx_plain);
47
 
  
 
47
 
48
48
  if (status == thrd_success) {
49
49
    return self;
50
50
  }
51
 
  free (self);
 
51
  s_free (self);
52
52
  s_err_print ("Could not create thrad. Error: %s.\n",
53
53
               s_thread_status_get_name (status));
54
54
  print_backtrace ();
58
58
void
59
59
s_mutex_free (SMutex * self) {
60
60
  mtx_destroy (self->mutex);
61
 
  free (self->mutex);
62
 
  free (self);
 
61
  s_free (self->mutex);
 
62
  s_free (self);
63
63
}
64
64
 
65
65
SThreadStatus
100
100
 
101
101
SThread *
102
102
s_thread_new (RunFunc func) {
103
 
  SThread * self = malloc (sizeof (SThread));
104
 
  
 
103
  SThread * self = s_malloc (sizeof (SThread));
 
104
 
105
105
  self->func = func;
106
106
 
107
107
  atomic_store (&(self->is_running), FALSE);
112
112
void
113
113
s_thread_free (SThread * self) {
114
114
  assert (!(atomic_load(&(self->is_running))));
115
 
  free (self);
 
115
  s_free (self);
116
116
}
117
117
 
118
118
sboolean