Currently only used with threadpool, one can "suspend" and "resume" a THD. Suspend only means leaving do_command earlier, after saving some state. Resume is continuing suspended THD's do_command(), from where it finished last time. */
| 3184 | Resume is continuing suspended THD's do_command(), from where it finished last time. |
| 3185 | */ |
| 3186 | bool try_suspend() |
| 3187 | { |
| 3188 | bool ret; |
| 3189 | mysql_mutex_lock(&m_mtx); |
| 3190 | DBUG_ASSERT(m_state == enum_async_state::NONE); |
| 3191 | DBUG_ASSERT(m_pending_ops >= 0); |
| 3192 | |
| 3193 | if(m_pending_ops) |
| 3194 | { |
| 3195 | ret=true; |
| 3196 | m_state= enum_async_state::SUSPENDED; |
| 3197 | } |
| 3198 | else |
| 3199 | { |
| 3200 | /* |
| 3201 | If there is no pending operations, can't suspend, since |
| 3202 | nobody can resume it. |
| 3203 | */ |
| 3204 | ret=false; |
| 3205 | } |
| 3206 | mysql_mutex_unlock(&m_mtx); |
| 3207 | return ret; |
| 3208 | } |
| 3209 | |
| 3210 | ~thd_async_state() |
| 3211 | { |