Skip to content

Commit

Permalink
slow task locker
Browse files Browse the repository at this point in the history
  • Loading branch information
HustXrb authored and jobs committed Nov 16, 2016
1 parent b108821 commit 290c8a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions hustdb/db/server/module/hustdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ hustdb_t::hustdb_t ( )
, m_rdb_ok ( false )
, m_timer ( )
, m_slow_tasks ( )
, m_mq_locker ( )
, m_tb_locker ( )
, m_server_conf ( )
, m_store_conf ( )
{
Expand Down
16 changes: 12 additions & 4 deletions hustdb/db/server/module/tasks/slow_task_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void slow_task_thread_t::stop ( )

TASK_THREAD::stop ();

scope_lock_t lock ( m_lock );
scope_wlock_t lock ( m_lock );

if ( ! m_tasks.empty () )
{
Expand Down Expand Up @@ -64,7 +64,8 @@ bool slow_task_thread_t::push (
return false;
}

scope_lock_t lock ( m_lock );
scope_wlock_t lock ( m_lock );

try
{
m_tasks.push_back ( task );
Expand All @@ -81,11 +82,15 @@ bool slow_task_thread_t::push (

bool slow_task_thread_t::empty ( )
{
scope_rlock_t lock ( m_lock );

return m_tasks.empty ();
}

bool slow_task_thread_t::le_one ( )
{
scope_rlock_t lock ( m_lock );

return m_tasks.size () <= 1;
}

Expand All @@ -106,7 +111,8 @@ void slow_task_thread_t::run ( )
task2_t * p = NULL;

{
scope_lock_t lock ( m_lock );
scope_wlock_t lock ( m_lock );

if ( m_tasks.empty () )
{
break;
Expand Down Expand Up @@ -140,6 +146,8 @@ void slow_task_thread_t::info (
std::string & info
)
{
scope_rlock_t lock ( m_lock );

char s[ 128 ] = { };

sprintf ( s,
Expand All @@ -156,7 +164,7 @@ slow_task_type_t slow_task_thread_t::status (
task2_t * task
)
{
scope_lock_t lock ( m_lock );
scope_rlock_t lock ( m_lock );

tasks_t::iterator it;

Expand Down
2 changes: 1 addition & 1 deletion hustdb/db/server/module/tasks/slow_task_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class slow_task_thread_t : public TASK_THREAD
tasks_t m_tasks;
tasks_t m_doing_tasks;
tasks_t m_done_tasks;
lockable_t m_lock;
rwlockable_t m_lock;
event2_t m_event;

private:
Expand Down

0 comments on commit 290c8a3

Please sign in to comment.