本文整理汇总了C++中pthread_mutex_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_mutex_unlock函数的具体用法?C++ pthread_mutex_unlock怎么用?C++ pthread_mutex_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_mutex_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pthread_mutex_lock
const struct sensors_input_cache_entry_t *sensors_input_cache_get(
const char *name)
{
int rc;
int fd;
DIR *dir;
struct dirent * item;
struct list_node *member;
struct input_dev_list *temp;
pthread_t id[MAX_EVENT_DRIVERS];
unsigned int i = 0;
unsigned int threads = 0;
const struct sensors_input_cache_entry_t *found = NULL;
pthread_mutex_lock(&util_mutex);
if (!list_initialized) {
node_init(&head);
list_initialized = 1;
}
temp = lookup(name, NULL);
if (temp) {
found = &temp->entry;
goto exit;
}
dir = opendir(INPUT_EVENT_DIR);
if (!dir) {
ALOGE("%s: error opening '%s'\n", __func__,
INPUT_EVENT_DIR);
goto exit;
}
while ((item = readdir(dir)) != NULL) {
if (strncmp(item->d_name, INPUT_EVENT_BASENAME,
sizeof(INPUT_EVENT_BASENAME) - 1) != 0) {
continue;
}
temp = (temp ? temp : malloc(sizeof(*temp)));
if (temp == NULL) {
ALOGE("%s: malloc error!\n", __func__);
break;
}
/* skip already cached entries */
snprintf(temp->entry.event_path, sizeof(temp->entry.event_path),
"%s%s", INPUT_EVENT_DIR, item->d_name);
if (lookup(NULL, temp->entry.event_path))
continue;
/* make sure we have access */
fd = open(temp->entry.event_path, O_RDONLY);
if (fd < 0) {
ALOGE("%s: cant open %s", __func__,
item->d_name);
continue;
}
rc = ioctl(fd, EVIOCGNAME(sizeof(temp->entry.dev_name)),
temp->entry.dev_name);
/* close in parallell to optimize boot time */
pthread_create(&id[threads++], NULL,
close_input_dev_fd, (void*) fd);
if (rc < 0) {
ALOGE("%s: cant get name from %s", __func__,
item->d_name);
continue;
}
temp->entry.nr = atoi(item->d_name +
sizeof(INPUT_EVENT_BASENAME) - 1);
node_add(&head, &temp->node);
if (!found && !strncmp(temp->entry.dev_name, name,
sizeof(temp->entry.dev_name) - 1))
found = &temp->entry;
temp = NULL;
}
closedir(dir);
for(i = 0; i < threads; ++i)
pthread_join(id[i], NULL);
exit:
pthread_mutex_unlock(&util_mutex);
return found;
}
示例2: unlock
static void unlock()
{
pthread_mutex_unlock(&lock_loggable);
}
示例3: pthread_mutex_unlock
inline void interprocess_recursive_mutex::unlock()
{
int res = 0;
res = pthread_mutex_unlock(&m_mut);
assert(res == 0);
}
示例4: slabs_rebalancer_resume
void slabs_rebalancer_resume(void) {
pthread_mutex_unlock(&slabs_rebalance_lock);
}
示例5: listen_loop
/* The main listening loop for the object. */
static alib_error listen_loop(ClientListener* listener)
{
if(!listener)return(ALIB_BAD_ARG);
int rval;
int event_count;
struct epoll_event* event_it;
long data_in_count;
void* data_in_buff = malloc(DEFAULT_INPUT_BUFF_SIZE);
/* Ensure we were able to allocate the data in buffer. */
if(!data_in_buff)
{
rval = ALIB_MEM_ERR;
goto f_return;
}
/* While our socket is open, then we will keep running. */
while(!(listener->flag_pole & THREAD_STOP))
{
/* If the array list is empty, then we simply wait until something is added
* to it or our thread is called to stop. */
if(!ArrayList_get_count(listener->client_list))
{
/* Call the empty list callback. */
if(listener->client_list_empty)
{
int rval = listener->client_list_empty(listener);
if(rval & SCB_RVAL_STOP_SERVER)
break;
}
pthread_mutex_lock(&listener->mutex);
while(!ArrayList_get_count(listener->client_list) && !(listener->flag_pole & THREAD_STOP))
pthread_cond_wait(&listener->t_cond, &listener->mutex);
pthread_mutex_unlock(&listener->mutex);
continue;
}
/* Wait for an event to come. */
event_count = epoll_wait(listener->ep.efd, listener->ep.triggered_events, DEFAULT_BACKLOG_SIZE,
1000);
if(!event_count)continue;
/* The the event_count is less than zero, then an error occurred. */
if(event_count < 0)
{
if(listener->flag_pole & THREAD_STOP)
rval = ALIB_OK;
else
{
if(listener->ep.efd > -1)
continue;
rval = ALIB_CHECK_ERRNO;
}
goto f_return;
}
/* Iterate through the events. */
if(pthread_mutex_lock(&listener->mutex))
{
rval = ALIB_MUTEX_ERR;
goto f_return;
}
for(event_it = listener->ep.triggered_events; event_count > 0; ++event_it, --event_count)
{
/* Use compare_int_ptr as the first member in the socket package
* is an integer. */
socket_package* client = (socket_package*)ArrayList_find_item_by_value_tsafe(
listener->client_list, &event_it->data.fd, compare_int_ptr);
if(!client)
{
close(listener->ep.triggered_events->data.fd);
continue;
}
/* Error occurred on the socket. */
if((event_it->events & (EPOLLERR | EPOLLHUP)) ||
!(event_it->events & EPOLLIN))
{
ArrayList_remove_tsafe(listener->client_list, client);
continue;
}
/* Call the client_data_ready callback. */
if(listener->data_ready)
{
rval = listener->data_ready(listener, client, &data_in_buff,
&data_in_count);
if(rval & SCB_RVAL_CLOSE_CLIENT)
ArrayList_remove_tsafe(listener->client_list, client);
if(rval & SCB_RVAL_STOP_SERVER)
{
rval = ALIB_OK;
flag_raise(&listener->flag_pole, THREAD_STOP);
if(pthread_mutex_unlock(&listener->mutex))
rval = ALIB_MUTEX_ERR;
goto f_return;
//.........这里部分代码省略.........
示例6: slabs_free
void slabs_free(void *ptr, size_t size, unsigned int id) {
pthread_mutex_lock(&slabs_lock);
do_slabs_free(ptr, size, id);
pthread_mutex_unlock(&slabs_lock);
}
示例7: slab_rebalance_move
/* refcount == 0 is safe since nobody can incr while cache_lock is held.
* refcount != 0 is impossible since flags/etc can be modified in other
* threads. instead, note we found a busy one and bail. logic in do_item_get
* will prevent busy items from continuing to be busy
*/
static int slab_rebalance_move(void) {
slabclass_t *s_cls;
int x;
int was_busy = 0;
int refcount = 0;
enum move_status status = MOVE_PASS;
pthread_mutex_lock(&cache_lock);
pthread_mutex_lock(&slabs_lock);
s_cls = &slabclass[slab_rebal.s_clsid];
for (x = 0; x < slab_bulk_check; x++) {
item *it = slab_rebal.slab_pos;
status = MOVE_PASS;
if (it->slabs_clsid != 255) {
void *hold_lock = NULL;
uint32_t hv = hash(ITEM_key(it), it->nkey, 0);
if ((hold_lock = item_trylock(hv)) == NULL) {
status = MOVE_LOCKED;
} else {
refcount = refcount_incr(&it->refcount);
if (refcount == 1) { /* item is unlinked, unused */
if (it->it_flags & ITEM_SLABBED) {
/* remove from slab freelist */
if (s_cls->slots == it) {
s_cls->slots = it->next;
}
if (it->next) it->next->prev = it->prev;
if (it->prev) it->prev->next = it->next;
s_cls->sl_curr--;
status = MOVE_DONE;
} else {
status = MOVE_BUSY;
}
} else if (refcount == 2) { /* item is linked but not busy */
if ((it->it_flags & ITEM_LINKED) != 0) {
do_item_unlink_nolock(it, hv);
status = MOVE_DONE;
} else {
/* refcount == 1 + !ITEM_LINKED means the item is being
* uploaded to, or was just unlinked but hasn't been freed
* yet. Let it bleed off on its own and try again later */
status = MOVE_BUSY;
}
} else {
if (settings.verbose > 2) {
fprintf(stderr, "Slab reassign hit a busy item: refcount: %d (%d -> %d)\n",
it->refcount, slab_rebal.s_clsid, slab_rebal.d_clsid);
}
status = MOVE_BUSY;
}
item_trylock_unlock(hold_lock);
}
}
switch (status) {
case MOVE_DONE:
it->refcount = 0;
it->it_flags = 0;
it->slabs_clsid = 255;
break;
case MOVE_BUSY:
refcount_decr(&it->refcount);
case MOVE_LOCKED:
slab_rebal.busy_items++;
was_busy++;
break;
case MOVE_PASS:
break;
}
slab_rebal.slab_pos = (char *)slab_rebal.slab_pos + s_cls->size;
if (slab_rebal.slab_pos >= slab_rebal.slab_end)
break;
}
if (slab_rebal.slab_pos >= slab_rebal.slab_end) {
/* Some items were busy, start again from the top */
if (slab_rebal.busy_items) {
slab_rebal.slab_pos = slab_rebal.slab_start;
slab_rebal.busy_items = 0;
} else {
slab_rebal.done++;
}
}
pthread_mutex_unlock(&slabs_lock);
pthread_mutex_unlock(&cache_lock);
return was_busy;
}
示例8: mlt_properties_get_int
static void *video_thread( void *arg )
{
// Identify the arg
consumer_sdl self = arg;
// Obtain time of thread start
struct timeval now;
int64_t start = 0;
int64_t elapsed = 0;
struct timespec tm;
mlt_frame next = NULL;
mlt_properties properties = NULL;
double speed = 0;
// Get real time flag
int real_time = mlt_properties_get_int( self->properties, "real_time" );
// Get the current time
gettimeofday( &now, NULL );
// Determine start time
start = ( int64_t )now.tv_sec * 1000000 + now.tv_usec;
while ( self->running )
{
// Pop the next frame
pthread_mutex_lock( &self->video_mutex );
next = mlt_deque_pop_front( self->queue );
while ( next == NULL && self->running )
{
pthread_cond_wait( &self->video_cond, &self->video_mutex );
next = mlt_deque_pop_front( self->queue );
}
pthread_mutex_unlock( &self->video_mutex );
if ( !self->running || next == NULL ) break;
// Get the properties
properties = MLT_FRAME_PROPERTIES( next );
// Get the speed of the frame
speed = mlt_properties_get_double( properties, "_speed" );
// Get the current time
gettimeofday( &now, NULL );
// Get the elapsed time
elapsed = ( ( int64_t )now.tv_sec * 1000000 + now.tv_usec ) - start;
// See if we have to delay the display of the current frame
if ( mlt_properties_get_int( properties, "rendered" ) == 1 && self->running )
{
// Obtain the scheduled playout time
int64_t scheduled = mlt_properties_get_int( properties, "playtime" );
// Determine the difference between the elapsed time and the scheduled playout time
int64_t difference = scheduled - elapsed;
// Smooth playback a bit
if ( real_time && ( difference > 20000 && speed == 1.0 ) )
{
tm.tv_sec = difference / 1000000;
tm.tv_nsec = ( difference % 1000000 ) * 500;
nanosleep( &tm, NULL );
}
// Show current frame if not too old
if ( !real_time || ( difference > -10000 || speed != 1.0 || mlt_deque_count( self->queue ) < 2 ) )
consumer_play_video( self, next );
// If the queue is empty, recalculate start to allow build up again
if ( real_time && ( mlt_deque_count( self->queue ) == 0 && speed == 1.0 ) )
{
gettimeofday( &now, NULL );
start = ( ( int64_t )now.tv_sec * 1000000 + now.tv_usec ) - scheduled + 20000;
}
}
// This frame can now be closed
mlt_frame_close( next );
next = NULL;
}
if ( next != NULL )
mlt_frame_close( next );
mlt_consumer_stopped( &self->parent );
return NULL;
}
示例9: MLT_CONSUMER_PROPERTIES
static void *consumer_thread( void *arg )
{
// Identify the arg
consumer_sdl self = arg;
// Get the consumer
mlt_consumer consumer = &self->parent;
// Get the properties
mlt_properties consumer_props = MLT_CONSUMER_PROPERTIES( consumer );
// Video thread
pthread_t thread;
// internal intialization
int init_audio = 1;
int init_video = 1;
mlt_frame frame = NULL;
mlt_properties properties = NULL;
int duration = 0;
int64_t playtime = 0;
struct timespec tm = { 0, 100000 };
// int last_position = -1;
pthread_mutex_lock( &self->refresh_mutex );
self->refresh_count = 0;
pthread_mutex_unlock( &self->refresh_mutex );
// Loop until told not to
while( self->running )
{
// Get a frame from the attached producer
frame = mlt_consumer_rt_frame( consumer );
// Ensure that we have a frame
if ( frame )
{
// Get the frame properties
properties = MLT_FRAME_PROPERTIES( frame );
// Get the speed of the frame
double speed = mlt_properties_get_double( properties, "_speed" );
// Get refresh request for the current frame
int refresh = mlt_properties_get_int( consumer_props, "refresh" );
// Clear refresh
mlt_events_block( consumer_props, consumer_props );
mlt_properties_set_int( consumer_props, "refresh", 0 );
mlt_events_unblock( consumer_props, consumer_props );
// Play audio
init_audio = consumer_play_audio( self, frame, init_audio, &duration );
// Determine the start time now
if ( self->playing && init_video )
{
// Create the video thread
pthread_create( &thread, NULL, video_thread, self );
// Video doesn't need to be initialised any more
init_video = 0;
}
// Set playtime for this frame
mlt_properties_set_int( properties, "playtime", playtime );
while ( self->running && speed != 0 && mlt_deque_count( self->queue ) > 15 )
nanosleep( &tm, NULL );
// Push this frame to the back of the queue
if ( self->running && speed )
{
pthread_mutex_lock( &self->video_mutex );
if ( self->is_purge && speed == 1.0 )
{
mlt_frame_close( frame );
self->is_purge = 0;
}
else
{
mlt_deque_push_back( self->queue, frame );
pthread_cond_broadcast( &self->video_cond );
}
pthread_mutex_unlock( &self->video_mutex );
// Calculate the next playtime
playtime += ( duration * 1000 );
}
else if ( self->running )
{
pthread_mutex_lock( &self->refresh_mutex );
if ( ( refresh == 0 && self->refresh_count <= 0 ) || self->refresh_count > 1 )
{
consumer_play_video( self, frame );
pthread_cond_wait( &self->refresh_cond, &self->refresh_mutex );
}
mlt_frame_close( frame );
self->refresh_count --;
pthread_mutex_unlock( &self->refresh_mutex );
//.........这里部分代码省略.........
示例10: CRITICAL_END
void CRITICAL_END() {
pthread_mutex_unlock(&MULTITHREAD_MUT);
}
示例11: consumer_play_audio
static int consumer_play_audio( consumer_sdl self, mlt_frame frame, int init_audio, int *duration )
{
// Get the properties of this consumer
mlt_properties properties = self->properties;
mlt_audio_format afmt = mlt_audio_s16;
// Set the preferred params of the test card signal
int channels = mlt_properties_get_int( properties, "channels" );
int frequency = mlt_properties_get_int( properties, "frequency" );
int scrub = mlt_properties_get_int( properties, "scrub_audio" );
static int counter = 0;
int samples = mlt_sample_calculator( mlt_properties_get_double( self->properties, "fps" ), frequency, counter++ );
int16_t *pcm;
int bytes;
mlt_frame_get_audio( frame, (void**) &pcm, &afmt, &frequency, &channels, &samples );
*duration = ( ( samples * 1000 ) / frequency );
if ( mlt_properties_get_int( properties, "audio_off" ) )
{
self->playing = 1;
init_audio = 1;
return init_audio;
}
if ( init_audio == 1 )
{
SDL_AudioSpec request;
SDL_AudioSpec got;
int audio_buffer = mlt_properties_get_int( properties, "audio_buffer" );
// specify audio format
memset( &request, 0, sizeof( SDL_AudioSpec ) );
self->playing = 0;
request.freq = frequency;
request.format = AUDIO_S16SYS;
request.channels = channels;
request.samples = audio_buffer;
request.callback = sdl_fill_audio;
request.userdata = (void *)self;
if ( SDL_OpenAudio( &request, &got ) != 0 )
{
mlt_log_error( MLT_CONSUMER_SERVICE( self ), "SDL failed to open audio: %s\n", SDL_GetError() );
init_audio = 2;
}
else if ( got.size != 0 )
{
SDL_PauseAudio( 0 );
init_audio = 0;
}
}
if ( init_audio == 0 )
{
mlt_properties properties = MLT_FRAME_PROPERTIES( frame );
bytes = ( samples * channels * 2 );
pthread_mutex_lock( &self->audio_mutex );
while ( self->running && bytes > ( sizeof( self->audio_buffer) - self->audio_avail ) )
pthread_cond_wait( &self->audio_cond, &self->audio_mutex );
if ( self->running )
{
if ( scrub || mlt_properties_get_double( properties, "_speed" ) == 1 )
memcpy( &self->audio_buffer[ self->audio_avail ], pcm, bytes );
else
memset( &self->audio_buffer[ self->audio_avail ], 0, bytes );
self->audio_avail += bytes;
}
pthread_cond_broadcast( &self->audio_cond );
pthread_mutex_unlock( &self->audio_mutex );
}
else
{
self->playing = 1;
}
return init_audio;
}
示例12: ldap_pvt_thread_mutex_unlock
int
ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
{
return ERRVAL( pthread_mutex_unlock( mutex ) );
}
示例13: tty2_thread
void* tty2_thread()
{
while(1)
{
FILE* f;
char fileName[30];
int numlines = 0;
int i; //Standard iterator.
fprintf(tty2, "in: ");
fscanf(tty2, "%s", fileName);
f = fopen(fileName, "r");
if(!f)
{
printf("Arquivo inválido!\n");
exit(-1);
}
p2->tty = tty2;
p2->ready = 0;
pthread_mutex_lock(&allocatorMutex);
if(allocate_block() == OUT_OF_MEMORY)
{
printf("SEM MEMÓRIA\n");
continue;
}
pthread_mutex_unlock(&allocatorMutex);
//Carregar programa na memória.
while(!feof(f))
{
fscanf(f, "%d %d", &mem[numlines + p2->cs].inst, &mem[numlines + p2->cs].op);
printf("inst= %d\t\top= %d\n", mem[numlines + p2->cs].inst, mem[numlines + p2->cs].op);
numlines++;
}
p2->ready = 1;
printf("Rodando!\n\n");
/* while(1)
{
//MUTEX
pthread_mutex_lock(&runningMutex);
if(running == p2)
{
printf("PC: %d\t CS: %d\t DS: %d\t ACC: %d\n", running->pc, running->cs, running->ds, running->acc);
if(run_line() == PROG_END) break;
running->pc++;
}
pthread_mutex_unlock(&runningMutex);
//MUTEX END
}
//Terminou execução
*/
while(p2->ready == 1) {} //Fica parado enquanto o processo está em execução.
pthread_mutex_lock(&allocatorMutex);
if(p2->ready == 0)
{
if(free_memory_block(running->block) == UNALLOCATED_MEM)
{
printf("Memória já foi desalocada. Algo muito errado aconteceu.\n");
continue;
}
}
pthread_mutex_unlock(&allocatorMutex);
}
}
示例14: videoenc_port_FlushProcessingBuffers
/** @brief Releases buffers under processing.
* This function must be implemented in the derived classes, for the
* specific processing
*/
OMX_ERRORTYPE videoenc_port_FlushProcessingBuffers(omx_base_PortType *openmaxStandPort)
{
omx_videoenc_PortType *omx_videoenc_Port = (omx_videoenc_PortType *)openmaxStandPort;
OMX_VCE_Buffers_List *pBuffersMng_List= &(omx_videoenc_Port->BuffersMng_List);
omx_base_component_PrivateType *omx_base_component_Private;
OMX_BUFFERHEADERTYPE *pBuffer;
int errQue;
DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for port %p\n", __func__, openmaxStandPort);
omx_base_component_Private = (omx_base_component_PrivateType *)openmaxStandPort->standCompContainer->pComponentPrivate;
if(omx_videoenc_Port->ringbuffer == OMX_TRUE && omx_videoenc_Port->bufferpool)
{
clearBufferPool(omx_videoenc_Port->bufferpool);
}
if(openmaxStandPort->sPortParam.eDomain != OMX_PortDomainOther)
{
/* clock buffers not used in the clients buffer managment function */
pthread_mutex_lock(&omx_base_component_Private->flush_mutex);
openmaxStandPort->bIsPortFlushed = OMX_TRUE;
/*Signal the buffer management thread of port flush,if it is waiting for buffers*/
if(omx_base_component_Private->bMgmtSem->semval==0)
{
tsem_up(omx_base_component_Private->bMgmtSem);
}
if(omx_base_component_Private->state != OMX_StateExecuting )
{
/*Waiting at paused state*/
tsem_signal(omx_base_component_Private->bStateSem);
}
DEBUG(DEB_LEV_FULL_SEQ, "In %s waiting for flush all condition port index =%d\n", __func__,
(int)openmaxStandPort->sPortParam.nPortIndex);
/* Wait until flush is completed */
pthread_mutex_unlock(&omx_base_component_Private->flush_mutex);
tsem_down(omx_base_component_Private->flush_all_condition);
}
DEBUG(DEB_LEV_FUNCTION_NAME, "In %s flushed all the buffers under processing\n", __func__);
tsem_reset(omx_base_component_Private->bMgmtSem);
/* Flush all the buffers not under processing */
while (openmaxStandPort->pBufferSem->semval > 0)
{
DEBUG(DEB_LEV_FULL_SEQ, "In %s TFlag=%x Flusing Port=%d,Semval=%d Qelem=%d\n",
__func__, (int)openmaxStandPort->nTunnelFlags, (int)openmaxStandPort->sPortParam.nPortIndex,
(int)openmaxStandPort->pBufferSem->semval, (int)openmaxStandPort->pBufferQueue->nelem);
tsem_down(openmaxStandPort->pBufferSem);
pBuffer = dequeue(openmaxStandPort->pBufferQueue);
//FlushProcessingBuffers_BuffersMng(pBuffersMng_List,pBuffer,omx_videoenc_Port->bIsStoreMediaData);
if (PORT_IS_TUNNELED(openmaxStandPort) && !PORT_IS_BUFFER_SUPPLIER(openmaxStandPort))
{
DEBUG(DEB_LEV_FULL_SEQ, "In %s: Comp %s is returning io:%d buffer\n",
__func__, omx_base_component_Private->name,(int)openmaxStandPort->sPortParam.nPortIndex);
if (openmaxStandPort->sPortParam.eDir == OMX_DirInput)
{
((OMX_COMPONENTTYPE*)(openmaxStandPort->hTunneledComponent))->FillThisBuffer(openmaxStandPort->hTunneledComponent, pBuffer);
}
else
{
((OMX_COMPONENTTYPE*)(openmaxStandPort->hTunneledComponent))->EmptyThisBuffer(openmaxStandPort->hTunneledComponent, pBuffer);
}
}
else if (PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort))
{
errQue = queue(openmaxStandPort->pBufferQueue, pBuffer);
if (errQue)
{
/* /TODO the queue is full. This can be handled in a fine way with
* some retrials, or other checking. For the moment this is a critical error
* and simply causes the failure of this call
*/
return OMX_ErrorInsufficientResources;
}
}
else
{
(*(openmaxStandPort->BufferProcessedCallback))(
openmaxStandPort->standCompContainer,
omx_base_component_Private->callbackData,
pBuffer);
}
}
/*Port is tunneled and supplier and didn't received all it's buffer then wait for the buffers*/
if (PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort))
{
while(openmaxStandPort->pBufferQueue->nelem != (int)openmaxStandPort->nNumAssignedBuffers)
{
//.........这里部分代码省略.........
示例15: pthread_mutex_lock
void AsyncLogger::addMessageTokens(const std::string& line,const std::string& line2) {
pthread_mutex_lock(&_mutex);
msg_q->push_back(line);
msg_q->push_back(line2);
pthread_mutex_unlock(&_mutex);
}