Changeset de53138 in mainline for uspace/lib/cpp/include/internal/thread.hpp
- Timestamp:
- 2018-07-05T21:41:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c71c171
- Parents:
- 6d8a63a
- git-author:
- Dzejrou <dzejrou@…> (2018-04-20 00:11:54)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/thread.hpp
r6d8a63a rde53138 30 30 #define LIBCPP_INTERNAL_THREAD 31 31 32 namespace std 33 { // TODO: fix cheaders32 namespace std::hel 33 { 34 34 extern "C" { 35 35 #include <fibril.h> … … 54 54 struct threading_policy<fibril_tag> 55 55 { 56 using mutex_type = fibril_mutex_t;57 using thread_type = fid_t;58 using condvar_type = fibril_condvar_t;59 using time_unit = suseconds_t;60 using shared_mutex_type = fibril_rwlock_t;56 using mutex_type = hel::fibril_mutex_t; 57 using thread_type = hel::fid_t; 58 using condvar_type = hel::fibril_condvar_t; 59 using time_unit = hel::suseconds_t; 60 using shared_mutex_type = hel::fibril_rwlock_t; 61 61 62 62 struct thread … … 65 65 static thread_type create(Callable clbl, Payload& pld) 66 66 { 67 return fibril_create(clbl, (void*)&pld);67 return hel::fibril_create(clbl, (void*)&pld); 68 68 } 69 69 70 70 static void start(thread_type thr) 71 71 { 72 fibril_add_ready(thr);72 hel::fibril_add_ready(thr); 73 73 } 74 74 75 75 static thread_type this_thread() 76 76 { 77 return fibril_get_id();77 return hel::fibril_get_id(); 78 78 } 79 79 80 80 static void yield() 81 81 { 82 fibril_yield();82 hel::fibril_yield(); 83 83 } 84 84 … … 94 94 static void init(mutex_type& mtx) 95 95 { 96 fibril_mutex_initialize(&mtx);96 hel::fibril_mutex_initialize(&mtx); 97 97 } 98 98 99 99 static void lock(mutex_type& mtx) 100 100 { 101 fibril_mutex_lock(&mtx);101 hel::fibril_mutex_lock(&mtx); 102 102 } 103 103 104 104 static void unlock(mutex_type& mtx) 105 105 { 106 fibril_mutex_unlock(&mtx);106 hel::fibril_mutex_unlock(&mtx); 107 107 } 108 108 109 109 static bool try_lock(mutex_type& mtx) 110 110 { 111 return fibril_mutex_trylock(&mtx);111 return hel::fibril_mutex_trylock(&mtx); 112 112 } 113 113 … … 123 123 static void init(condvar_type& cv) 124 124 { 125 fibril_condvar_initialize(&cv);125 hel::fibril_condvar_initialize(&cv); 126 126 } 127 127 128 128 static void wait(condvar_type& cv, mutex_type& mtx) 129 129 { 130 fibril_condvar_wait(&cv, &mtx);130 hel::fibril_condvar_wait(&cv, &mtx); 131 131 } 132 132 133 133 static int wait_for(condvar_type& cv, mutex_type& mtx, time_unit timeout) 134 134 { 135 return fibril_condvar_wait_timeout(&cv, &mtx, timeout);135 return hel::fibril_condvar_wait_timeout(&cv, &mtx, timeout); 136 136 } 137 137 138 138 static void signal(condvar_type& cv) 139 139 { 140 fibril_condvar_signal(&cv);140 hel::fibril_condvar_signal(&cv); 141 141 } 142 142 143 143 static void broadcast(condvar_type& cv) 144 144 { 145 fibril_condvar_broadcast(&cv);145 hel::fibril_condvar_broadcast(&cv); 146 146 } 147 147 }; … … 157 157 static void sleep(time_unit time) 158 158 { 159 fibril_usleep(time);159 hel::fibril_usleep(time); 160 160 } 161 161 }; … … 165 165 static void init(shared_mutex_type& mtx) 166 166 { 167 fibril_rwlock_initialize(&mtx);167 hel::fibril_rwlock_initialize(&mtx); 168 168 } 169 169 170 170 static void lock(shared_mutex_type& mtx) 171 171 { 172 fibril_rwlock_write_lock(&mtx);172 hel::fibril_rwlock_write_lock(&mtx); 173 173 } 174 174 175 175 static void unlock(shared_mutex_type& mtx) 176 176 { 177 fibril_rwlock_write_unlock(&mtx);177 hel::fibril_rwlock_write_unlock(&mtx); 178 178 } 179 179 180 180 static void lock_shared(shared_mutex_type& mtx) 181 181 { 182 fibril_rwlock_read_lock(&mtx);182 hel::fibril_rwlock_read_lock(&mtx); 183 183 } 184 184 185 185 static void unlock_shared(shared_mutex_type& mtx) 186 186 { 187 fibril_rwlock_read_unlock(&mtx);187 hel::fibril_rwlock_read_unlock(&mtx); 188 188 } 189 189
Note:
See TracChangeset
for help on using the changeset viewer.