| 1845 | return 0; |
| 1846 | } |
| 1847 | void semaphore::try_resume(uint64_t cnt) { |
| 1848 | assert(cnt); |
| 1849 | while(true) { |
| 1850 | ScopedLockHead h(this); |
| 1851 | if (!h) break; |
| 1852 | auto th = (thread*)h; |
| 1853 | auto& c = th->semaphore_count; |
| 1854 | if (c > cnt) break; |
| 1855 | cnt -= c; |
| 1856 | prelocked_thread_interrupt(th, -1); |
| 1857 | } |
| 1858 | if (!q.th || !cnt || !m_ooo_resume) |
| 1859 | return; |
| 1860 | SCOPED_LOCK(q.lock); |
| 1861 | for (auto th = q.th->next(); |
| 1862 | th!= q.th && cnt; |
| 1863 | th = th->next()) { |
| 1864 | SCOPED_LOCK(th->lock); |
| 1865 | auto& c = th->semaphore_count; |
| 1866 | if (c <= cnt) { |
| 1867 | cnt -= c; |
| 1868 | prelocked_thread_interrupt(th, -1); |
| 1869 | } |
| 1870 | } |
| 1871 | } |
| 1872 | inline bool semaphore::try_subtract(uint64_t count) { |
| 1873 | while(true) { |
| 1874 | auto mc = m_count.load(); |
nothing calls this directly
no test coverage detected