本文整理汇总了C++中LOCK_MUTEX函数的典型用法代码示例。如果您正苦于以下问题:C++ LOCK_MUTEX函数的具体用法?C++ LOCK_MUTEX怎么用?C++ LOCK_MUTEX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOCK_MUTEX函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LOCK_MUTEX
/*!
\fn void Win_QextSerialPort::setStopBits(StopBitsType stopBits)
Sets the number of stop bits used by the serial port. Possible values of stopBits are:
\verbatim
STOP_1 1 stop bit
STOP_1_5 1.5 stop bits
STOP_2 2 stop bits
\endverbatim
\note
This function is subject to the following restrictions:
\par
2 stop bits cannot be used with 5 data bits.
\par
1.5 stop bits cannot be used with 6 or more data bits.
\par
POSIX does not support 1.5 stop bits.
*/
void Win_QextSerialPort::setStopBits(StopBitsType stopBits) {
LOCK_MUTEX();
if (Settings.StopBits!=stopBits) {
if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) ||
(stopBits==STOP_1_5 && Settings.DataBits!=DATA_5)) {
}
else {
Settings.StopBits=stopBits;
}
}
if (isOpen()) {
switch (stopBits) {
/*one stop bit*/
case STOP_1:
Win_CommConfig.dcb.StopBits=ONESTOPBIT;
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
break;
/*1.5 stop bits*/
case STOP_1_5:
TTY_PORTABILITY_WARNING("Win_QextSerialPort Portability Warning: 1.5 stop bit operation is not supported by POSIX.");
if (Settings.DataBits!=DATA_5) {
TTY_WARNING("Win_QextSerialPort: 1.5 stop bits can only be used with 5 data bits");
}
else {
Win_CommConfig.dcb.StopBits=ONE5STOPBITS;
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
}
break;
/*two stop bits*/
case STOP_2:
if (Settings.DataBits==DATA_5) {
TTY_WARNING("Win_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
}
else {
Win_CommConfig.dcb.StopBits=TWOSTOPBITS;
SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG));
}
break;
}
}
UNLOCK_MUTEX();
}
开发者ID:Felipeasg,项目名称:serialchart,代码行数:63,代码来源:win_qextserialport.cpp
示例2: LOCK_MUTEX
//suscribe to topic Id. Receive a callback when a message is received
ps_result_enum ps_pubsub_class::subscribe(ps_topic_id_t topicId, message_handler_t *msgHandler)
{
LOCK_MUTEX(pubsubMtx);
//find the client
for (psClient_t *client : clientList)
{
if (client->messageHandler == msgHandler)
{
client->topicList.insert(topicId); //add new subscription
if (topicId >= topic_count)
{
PS_DEBUG("pub: subscribe to topic %i", topicId);
}
else
{
PS_DEBUG("pub: subscribe to topic %s", topic_names[topicId]);
}
UNLOCK_MUTEX(pubsubMtx);
return PS_OK;
}
}
//add new client
{
psClient_t *newClient = new psClient_t();
newClient->messageHandler = msgHandler;
newClient->topicList.insert(topicId); //add new subscription
clientList.insert(newClient);
if (topicId >= topic_count)
{
PS_DEBUG("pub: new client subscribed to topic %i", topicId);
}
else
{
PS_DEBUG("pub: new client subscribed to topic %s", topic_names[topicId]);
}
}
UNLOCK_MUTEX(pubsubMtx);
return PS_OK;
}
开发者ID:wda2945,项目名称:Libraries,代码行数:46,代码来源:ps_pubsub_class.cpp
示例3: loadMusic
int loadMusic( sp_session *session, char *uri , char *name , playqueue_fifo_t *playqueue )
{
TRACE_2( PLAYERMANAGER , "loadMusic().");
int status = PC_SUCCESS;
char response[255] = { 0 };
/* If it's the first time we load a track, we have to init the audio driver and the playqueue */
// if( firstTime++ == 0 )
// initPlayerEnv();
LOCK_MUTEX( PLAYERMANAGER , &mutexSession );
sp_track *track = NULL;
currentTrack = track;
if( createTrackFromUri( uri , name ) == PC_ERROR )
status = PC_ERROR;
if( currentTrack != NULL)
{
TRACE_1( PLAYERMANAGER , "Adding track to the playlist.");
addTracksToPlayqueue( playqueue , currentTrack );
snprintf( response , 255 , "OK");
sendVoid( ( void * )response , strlen( response ) );
}
else
{
TRACE_ERROR( PLAYERMANAGER , "Cannot add track to the playlist because track is NULL.");
status = PC_ERROR;
snprintf( response , 255 , "NOK: Cannot add the track to the playlist because the URI might be invalid.");
sendVoid( ( void * )response , strlen( response ) );
}
UNLOCK_MUTEX( PLAYERMANAGER , &mutexSession );
return status;
}
开发者ID:raphui,项目名称:wMusic,代码行数:45,代码来源:player.c
示例4: LOCK_MUTEX
/*!
\fn qint64 Win_QextSerialPort::bytesAvailable()
Returns the number of bytes waiting in the port's receive queue. This function will return 0 if
the port is not currently open, or -1 on error. Error information can be retrieved by calling
Win_QextSerialPort::getLastError().
*/
qint64 Win_QextSerialPort::bytesAvailable() {
LOCK_MUTEX();
if (isOpen()) {
DWORD Errors;
COMSTAT Status;
bool success=ClearCommError(Win_Handle, &Errors, &Status);
translateError(Errors);
if (success) {
lastErr=E_NO_ERROR;
UNLOCK_MUTEX();
return Status.cbInQue + QIODevice::bytesAvailable();
}
UNLOCK_MUTEX();
return (unsigned int)-1;
}
UNLOCK_MUTEX();
return 0;
}
开发者ID:Anne081031,项目名称:ParkCode,代码行数:24,代码来源:win_qextserialport.cpp
示例5: workqueue_job_running
int workqueue_job_running(struct workqueue_ctx* ctx, int job_id)
{
int ret = 0;
if (!ctx)
return -1;
do {
LOCK_MUTEX(&ctx->mutex);
ret = _is_job_running(ctx, job_id);
UNLOCK_MUTEX(&ctx->mutex);
} while (ret == -EBUSY);
return ret;
}
开发者ID:beyondforever1993,项目名称:libworkqueue,代码行数:18,代码来源:workqueue.c
示例6: LOCK_MUTEX
bool CCAN232Obj::setMask(unsigned long mask)
{
char buf[ 20 ];
char szCmd[ 80 ];
LOCK_MUTEX(m_can232ObjMutex);
// Acceptance Mask
sprintf(buf, "m%8.8lX\r", mask);
m_can232obj.m_comm.comm_puts(buf, strlen(buf), true);
*szCmd = 0;
m_can232obj.m_comm.comm_gets(szCmd, sizeof( szCmd), 100000);
printf("Open: Response: setFilter: [%s]\n", szCmd);
UNLOCK_MUTEX(m_can232ObjMutex);
return true;
}
开发者ID:dinguluer,项目名称:vscp_software,代码行数:18,代码来源:can232obj.cpp
示例7: ncdClosePort
bool CVectorObj::close( void )
{
// Do nothing if already terminated
if ( !m_bRun ) return false;
m_bRun = false;
ncdClosePort( m_portHandle );
m_portHandle = INVALID_PORTHANDLE;
ncdCloseDriver();
UNLOCK_MUTEX( m_vectorMutex );
LOCK_MUTEX( m_vectorMutex );
// terminate the worker thread
#ifdef WIN32
DWORD rv;
// Wait for transmit thread to terminate
while ( true ) {
GetExitCodeThread( m_hTreadTransmit, &rv );
if ( STILL_ACTIVE != rv ) break;
}
// Wait for receive thread to terminate
while ( true ) {
GetExitCodeThread( m_hTreadReceive, &rv );
if ( STILL_ACTIVE != rv ) break;
}
#else
int *trv;
pthread_join( m_threadIdReceive, (void **)&trv );
pthread_join( m_threadIdTransmit, (void **)&trv );
pthread_mutex_destroy( &m_vectorMutex );
#endif
return true;
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:44,代码来源:vectorxlobj.cpp
示例8: end_of_track
void end_of_track( sp_session *session )
{
TRACE_2( PLAYERMANAGER , "end_of_track().");
TRACE_3( PLAYERMANAGER , "End of track...");
// LOCK_MUTEX( PLAYERMANAGER , &mutexSession );
TRACE_3( PLAYERMANAGER , "Removing the track which have been played.");
sp_track_release( currentTrack );
// UNLOCK_MUTEX( PLAYERMANAGER , &mutexSession );
// if( hasNextTrack() == TRUE )
// {
// TRACE_1( PLAYERMANAGER , "Load next music !");
// playMusic( session , "" , currentStreamName );
// }
if( nextTrackInStream( currentStreamName ) == PC_SUCCESS )
{
TRACE_1( PLAYERMANAGER , "Load next music !");
}
else
{
TRACE_WARNING( PLAYERMANAGER , "No more music in the mainplaylist");
audio_fifo_flush( &g_audiofifo );
LOCK_MUTEX( PLAYERMANAGER , &mutexSession );
sp_session_player_play( session , 0 );
sp_session_player_unload( session );
UNLOCK_MUTEX( PLAYERMANAGER , &mutexSession );
playing = FALSE;
}
}
开发者ID:raphui,项目名称:wMusic,代码行数:44,代码来源:player.c
示例9: bytesWaiting
/*!
\fn void Posix_QextSerialPort::setTimeout(ulong sec);
Sets the read and write timeouts for the port to millisec milliseconds.
Note that this is a per-character timeout, i.e. the port will wait this long for each
individual character, not for the whole read operation. This timeout also applies to the
bytesWaiting() function.
\note
POSIX does not support millisecond-level control for I/O timeout values. Any
timeout set using this function will be set to the next lowest tenth of a second for
the purposes of detecting read or write timeouts. For example a timeout of 550 milliseconds
will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and
writing the port. However millisecond-level control is allowed by the select() system call,
so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for
the purpose of detecting available bytes in the read buffer.
*/
void Posix_QextSerialPort::setTimeout(long millisec)
{
LOCK_MUTEX();
Settings.Timeout_Millisec = millisec;
Posix_Copy_Timeout.tv_sec = millisec / 1000;
Posix_Copy_Timeout.tv_usec = millisec % 1000;
if (isOpen()) {
if (millisec == -1)
fcntl(fd, F_SETFL, O_NDELAY);
else
//O_SYNC should enable blocking ::write()
//however this seems not working on Linux 2.6.21 (works on OpenBSD 4.2)
fcntl(fd, F_SETFL, O_SYNC);
tcgetattr(fd, & Posix_CommConfig);
Posix_CommConfig.c_cc[VTIME] = millisec/100;
tcsetattr(fd, TCSAFLUSH, & Posix_CommConfig);
}
UNLOCK_MUTEX();
}
开发者ID:MatthiasEgli,项目名称:qgroundcontrol,代码行数:36,代码来源:posix_qextserialport.cpp
示例10: PS_DEBUG
//suscribe to topic Id. Transport version.
ps_result_enum ps_pubsub_class::subscribe(ps_topic_id_t topicId, ps_transport_class *pst)
{
if (topicId >= topic_count)
{
PS_DEBUG("pub: subscribe to %i from %s", topicId, pst->name.c_str());
}
else
{
PS_DEBUG("pub: subscribe to %s from %s", topic_names[ topicId], pst->name.c_str());
}
LOCK_MUTEX(pubsubMtx);
//insert the topic
pst->topicList.insert(topicId); //add new subscription
UNLOCK_MUTEX(pubsubMtx);
return PS_OK;
}
开发者ID:wda2945,项目名称:Libraries,代码行数:20,代码来源:ps_pubsub_class.cpp
示例11: LOCK_MUTEX
BOOL CDllDrvObj::removeAllObjects()
{
LOCK_MUTEX( m_objMutex );
for ( int i=0; i<CANAL_USB2CAN_DRIVER_MAX_OPEN; i++ )
{
if ( NULL != m_drvObjArray[ i ] )
{
m_drvObjArray[ i ]->close();
delete m_drvObjArray[ i ];
m_drvObjArray[ i ] = NULL;
lpvMem[i] = 0;//inform global space driver on position i closed
}
}
UNLOCK_MUTEX( m_objMutex );
return TRUE;
}
开发者ID:portmankim,项目名称:vscp_software,代码行数:19,代码来源:dlldrvobj.cpp
示例12: buffer_append_action_at
void buffer_append_action_at (buf_t *buf, action_func_t action_func,
void *action_arg, ogg_int64_t position)
{
action_t *action;
action = malloc_action(action_func, action_arg);
pthread_cleanup_push(buffer_mutex_unlock, buf);
LOCK_MUTEX(buf->mutex);
action->position = position;
in_order_add_action(&buf->actions, action, APPEND);
UNLOCK_MUTEX(buf->mutex);
pthread_cleanup_pop(0);
}
开发者ID:Chocobo1,项目名称:vorbis-tools,代码行数:19,代码来源:buffer.c
示例13: setAdapterRunMode
bool CApoxObj::close( void )
{
// Do nothing if already terminated
if ( !m_bRun ) return false;
m_bRun = false;
// Switch to boot mode
setAdapterRunMode( RUNMODE_BOOT );
FT_Close( m_ftHandle );
UNLOCK_MUTEX( m_apoxMutex );
LOCK_MUTEX( m_apoxMutex );
// terminate the worker thread
#ifdef WIN32
DWORD rv;
// Wait for transmit thread to terminate
while ( true ) {
GetExitCodeThread( m_hTreadTransmit, &rv );
if ( STILL_ACTIVE != rv ) break;
}
// Wait for receive thread to terminate
while ( true ) {
GetExitCodeThread( m_hTreadReceive, &rv );
if ( STILL_ACTIVE != rv ) break;
}
#else
int *trv;
pthread_join( m_threadIdReceive, (void **)&trv );
pthread_join( m_threadIdTransmit, (void **)&trv );
pthread_mutex_destroy( &m_apoxMutex );
#endif
return true;
}
开发者ID:davidlcamlin,项目名称:vscp_software,代码行数:43,代码来源:apoxobj.cpp
示例14: open
/*!
\fn qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
Reads a block of data from the serial port. This function will read at most maxlen bytes from
the serial port and place them in the buffer pointed to by data. Return value is the number of
bytes actually read, or -1 on error.
\warning before calling this function ensure that serial port associated with this class
is currently open (use isOpen() function to check if port is open).
*/
qint64 Win_QextSerialPort::readData(char *data, qint64 maxSize)
{
DWORD retVal;
LOCK_MUTEX();
retVal = 0;
if (queryMode() == QextSerialBase::EventDriven)
{
OVERLAPPED overlapRead;
overlapRead.Internal = 0;
overlapRead.InternalHigh = 0;
overlapRead.Offset = 0;
overlapRead.OffsetHigh = 0;
overlapRead.hEvent = CreateEvent(NULL, true, false, NULL);
if (!ReadFile(m_WinHandle, (void*)data, (DWORD)maxSize, & retVal, & overlapRead))
{
if (GetLastError() == ERROR_IO_PENDING)
{
GetOverlappedResult(m_WinHandle, & overlapRead, & retVal, true);
}
else
{
lastErr = E_READ_FAILED;
retVal = (DWORD)-1;
}
}
CloseHandle(overlapRead.hEvent);
}
else if (!ReadFile(m_WinHandle, (void*)data, (DWORD)maxSize, & retVal, NULL))
{
lastErr = E_READ_FAILED;
retVal = (DWORD)-1;
}
UNLOCK_MUTEX();
return (qint64)retVal;
}
开发者ID:dulton,项目名称:53_hero,代码行数:52,代码来源:win_qextserialport.cpp
示例15: LOCK_MUTEX
long
CSocketcanApp::addDriverObject(CSocketcanObj *plog)
{
long h = 0;
LOCK_MUTEX(m_objMutex);
for (int i = 0; i < CANAL_SOCKETCAN_DRIVER_MAX_OPEN; i++) {
if (NULL == m_socketcanArray[ i ]) {
m_socketcanArray[ i ] = plog;
h = i + 1681;
break;
}
}
UNLOCK_MUTEX(m_objMutex);
return h;
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:19,代码来源:socketcandrv.cpp
示例16: LOCK_MUTEX
/*!
\fn bool Posix_QextSerialPort::open(OpenMode mode)
Opens the serial port associated to this class.
This function has no effect if the port associated with the class is already open.
The port is also configured to the current settings, as stored in the Settings structure.
*/
bool Posix_QextSerialPort::open(OpenMode mode)
{
LOCK_MUTEX();
if (mode == QIODevice::NotOpen)
return isOpen();
if (!isOpen()) {
/*open the port*/
Posix_File->setFileName(port);
qDebug("Trying to open File");
if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
qDebug("Opened File succesfully");
/*set open mode*/
QIODevice::open(mode);
/*configure port settings*/
tcgetattr(Posix_File->handle(), &Posix_CommConfig);
/*set up other port settings*/
Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
Posix_CommConfig.c_oflag&=(~OPOST);
Posix_CommConfig.c_cc[VMIN]=0;
Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
setBaudRate(Settings.BaudRate);
setDataBits(Settings.DataBits);
setParity(Settings.Parity);
setStopBits(Settings.StopBits);
setFlowControl(Settings.FlowControl);
// setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
setTimeout(Settings.Timeout_Millisec);
tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
} else {
qDebug("Could not open File! Error code : %d", Posix_File->error());
}
}
UNLOCK_MUTEX();
return isOpen();
}
开发者ID:shutup,项目名称:smart_home,代码行数:49,代码来源:posix_qextserialport.cpp
示例17: LOCK_MUTEX
CVSCPL2App::~CVSCPL2App()
{
LOCK_MUTEX( m_objMutex );
for ( int i = 0; i<VSCP_LEVEL1_INTERFACE_MAX_OPEN; i++ ) {
if ( NULL != m_pvscpifArray[ i ] ) {
Clmsensors *plmif = getDriverObject( i );
if ( NULL != plmif ) {
plmif->close();
delete m_pvscpifArray[ i ];
m_pvscpifArray[ i ] = NULL;
}
}
}
UNLOCK_MUTEX( m_objMutex );
pthread_mutex_destroy( &m_objMutex );
}
开发者ID:BlueAndi,项目名称:vscp_software,代码行数:20,代码来源:vscpl2drv_lmsensors.cpp
示例18: buffer_append_action_at_end
void buffer_append_action_at_end (buf_t *buf, action_func_t action_func,
void *action_arg)
{
action_t *action;
action = malloc_action(action_func, action_arg);
pthread_cleanup_push(buffer_mutex_unlock, buf);
LOCK_MUTEX(buf->mutex);
/* Stick after the last item in the buffer */
action->position = buf->position_end;
in_order_add_action(&buf->actions, action, APPEND);
UNLOCK_MUTEX(buf->mutex);
pthread_cleanup_pop(0);
}
开发者ID:Chocobo1,项目名称:vorbis-tools,代码行数:20,代码来源:buffer.c
示例19: LOCK_MUTEX
CVSCPDrvApp::~CVSCPDrvApp()
{
LOCK_MUTEX( m_objMutex );
for ( int i = 0; i < VSCP_RPILCD_DRIVER_MAX_OPEN; i++ ) {
if ( NULL == m_pPiLCDArray[ i ] ) {
CRpiLCD *prpimax6675 = getDriverObject(i);
if ( NULL != prpimax6675 ) {
prpimax6675->close();
delete m_pPiLCDArray[ i ];
m_pPiLCDArray[ i ] = NULL;
}
}
}
UNLOCK_MUTEX( m_objMutex );
pthread_mutex_destroy( &m_objMutex );
}
开发者ID:davidluca3000,项目名称:vscp_software,代码行数:20,代码来源:vscpl2drv-rpilcd.cpp
示例20: LOCK_MUTEX
CLoggerdllApp::~CLoggerdllApp() {
LOCK_MUTEX(m_objMutex);
for (int i = 0; i < CANAL_LOGGER_DRIVER_MAX_OPEN; i++) {
if (NULL == m_logArray[ i ]) {
CLog *pLog = getDriverObject(i);
if (NULL != pLog) {
pLog->close();
delete m_logArray[ i ];
m_logArray[ i ] = NULL;
}
}
}
UNLOCK_MUTEX(m_objMutex);
pthread_mutex_destroy(&m_objMutex);
}
开发者ID:dinguluer,项目名称:vscp_software,代码行数:20,代码来源:canallogger.cpp
注:本文中的LOCK_MUTEX函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论