Changeset bc73be3 in mainline for uspace/lib/cpp/include/__bits/thread/threading.hpp
- Timestamp:
- 2019-06-27T08:51:20Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8add15e0
- Parents:
- ad40b74b (diff), aeba767 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/__bits/thread/threading.hpp
rad40b74b rbc73be3 30 30 #define LIBCPP_BITS_THREAD_THREADING 31 31 32 namespace std::hel33 {34 extern "C" {35 #include <async.h>36 #include <fibril.h>37 #include <fibril_synch.h>38 }39 }40 41 32 #include <chrono> 33 34 #include <fibril.h> 35 #include <fibril_synch.h> 42 36 43 37 namespace std::aux … … 55 49 struct threading_policy<fibril_tag> 56 50 { 57 using mutex_type = hel::fibril_mutex_t;58 using thread_type = hel::fid_t;59 using condvar_type = hel::fibril_condvar_t;60 using time_unit = hel::usec_t;61 using shared_mutex_type = hel::fibril_rwlock_t;51 using mutex_type = ::helenos::fibril_mutex_t; 52 using thread_type = ::helenos::fid_t; 53 using condvar_type = ::helenos::fibril_condvar_t; 54 using time_unit = ::helenos::usec_t; 55 using shared_mutex_type = ::helenos::fibril_rwlock_t; 62 56 63 57 struct thread … … 66 60 static thread_type create(Callable clbl, Payload& pld) 67 61 { 68 return hel::fibril_create(clbl, (void*)&pld);62 return ::helenos::fibril_create(clbl, (void*)&pld); 69 63 } 70 64 71 65 static void start(thread_type thr) 72 66 { 73 hel::fibril_add_ready(thr);67 ::helenos::fibril_add_ready(thr); 74 68 } 75 69 76 70 static thread_type this_thread() 77 71 { 78 return hel::fibril_get_id();72 return ::helenos::fibril_get_id(); 79 73 } 80 74 81 75 static void yield() 82 76 { 83 hel::fibril_yield();77 ::helenos::fibril_yield(); 84 78 } 85 79 … … 95 89 static void init(mutex_type& mtx) 96 90 { 97 hel::fibril_mutex_initialize(&mtx);91 ::helenos::fibril_mutex_initialize(&mtx); 98 92 } 99 93 100 94 static void lock(mutex_type& mtx) 101 95 { 102 hel::fibril_mutex_lock(&mtx);96 ::helenos::fibril_mutex_lock(&mtx); 103 97 } 104 98 105 99 static void unlock(mutex_type& mtx) 106 100 { 107 hel::fibril_mutex_unlock(&mtx);101 ::helenos::fibril_mutex_unlock(&mtx); 108 102 } 109 103 110 104 static bool try_lock(mutex_type& mtx) 111 105 { 112 return hel::fibril_mutex_trylock(&mtx);106 return ::helenos::fibril_mutex_trylock(&mtx); 113 107 } 114 108 … … 124 118 static void init(condvar_type& cv) 125 119 { 126 hel::fibril_condvar_initialize(&cv);120 ::helenos::fibril_condvar_initialize(&cv); 127 121 } 128 122 129 123 static void wait(condvar_type& cv, mutex_type& mtx) 130 124 { 131 hel::fibril_condvar_wait(&cv, &mtx);125 ::helenos::fibril_condvar_wait(&cv, &mtx); 132 126 } 133 127 134 128 static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout) 135 129 { 136 return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout);130 return ::helenos::fibril_condvar_wait_timeout(&cv, &mtx, timeout); 137 131 } 138 132 139 133 static void signal(condvar_type& cv) 140 134 { 141 hel::fibril_condvar_signal(&cv);135 ::helenos::fibril_condvar_signal(&cv); 142 136 } 143 137 144 138 static void broadcast(condvar_type& cv) 145 139 { 146 hel::fibril_condvar_broadcast(&cv);140 ::helenos::fibril_condvar_broadcast(&cv); 147 141 } 148 142 }; … … 158 152 static void sleep(time_unit time) 159 153 { 160 hel::fibril_usleep(time);154 ::helenos::fibril_usleep(time); 161 155 } 162 156 }; … … 166 160 static void init(shared_mutex_type& mtx) 167 161 { 168 hel::fibril_rwlock_initialize(&mtx);162 ::helenos::fibril_rwlock_initialize(&mtx); 169 163 } 170 164 171 165 static void lock(shared_mutex_type& mtx) 172 166 { 173 hel::fibril_rwlock_write_lock(&mtx);167 ::helenos::fibril_rwlock_write_lock(&mtx); 174 168 } 175 169 176 170 static void unlock(shared_mutex_type& mtx) 177 171 { 178 hel::fibril_rwlock_write_unlock(&mtx);172 ::helenos::fibril_rwlock_write_unlock(&mtx); 179 173 } 180 174 181 175 static void lock_shared(shared_mutex_type& mtx) 182 176 { 183 hel::fibril_rwlock_read_lock(&mtx);177 ::helenos::fibril_rwlock_read_lock(&mtx); 184 178 } 185 179 186 180 static void unlock_shared(shared_mutex_type& mtx) 187 181 { 188 hel::fibril_rwlock_read_unlock(&mtx);182 ::helenos::fibril_rwlock_read_unlock(&mtx); 189 183 } 190 184
Note:
See TracChangeset
for help on using the changeset viewer.