本文整理汇总了C++中pthread_spin_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_spin_destroy函数的具体用法?C++ pthread_spin_destroy怎么用?C++ pthread_spin_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_spin_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unvme_session_delete
/**
* Delete a session and its associated queues.
* @param ses session
*/
static void unvme_session_delete(unvme_session_t* ses)
{
if (ses->id > 0) {
pthread_spin_lock(&ses->iomem.lock);
if (ses->iomem.size) {
int i;
for (i = 0; i < ses->iomem.count; i++) {
(void) vfio_dma_free(ses->iomem.map[i]);
}
ses->iomem.size = ses->iomem.count = 0;
free(ses->iomem.map);
}
pthread_spin_unlock(&ses->iomem.lock);
pthread_spin_destroy(&ses->iomem.lock);
}
if (ses == ses->next) {
DEBUG_FN("%x: adminq", unvme_dev.vfiodev->pci);
unvme_adminq_delete(ses->queues);
} else {
DEBUG_FN("%x: q=%d-%d", unvme_dev.vfiodev->pci, ses->id,
ses->id + ses->qcount -1);
while (--ses->qcount >= 0) {
unvme_queue_t* ioq = &ses->queues[ses->qcount];
if (ioq->ses) unvme_ioq_delete(ioq);
}
}
LIST_DEL(unvme_dev.ses, ses);
free(ses);
}
示例2: cleanup_context
void cleanup_context(struct tur_checker_context *ct)
{
pthread_mutex_destroy(&ct->lock);
pthread_cond_destroy(&ct->active);
pthread_spin_destroy(&ct->hldr_lock);
free(ct);
}
示例3: main
int main()
{
pthread_spinlock_t spinlock;
struct sigaction act;
/* Set up child thread to handle SIGALRM */
act.sa_flags = 0;
act.sa_handler = sig_handler;
sigfillset(&act.sa_mask);
sigaction(SIGALRM, &act, 0);
printf("main: attemp to lock an un-initialized spin lock\n");
printf("main: Send SIGALRM to me after 5 secs\n");
alarm(5);
/* Attempt to lock an uninitialized spinlock */
rc = pthread_spin_lock(&spinlock);
/* If we get here, call sig_handler() to check the return code of
* pthread_spin_lock() */
sig_handler();
/* Unlock spinlock */
pthread_spin_unlock(&spinlock);
/* Destroy spinlock */
pthread_spin_destroy(&spinlock);
return PTS_PASS;
}
示例4: xwork_fini
int
xwork_fini (struct xwork *xwork, int stop)
{
int i = 0;
int ret = 0;
void *tret = 0;
pthread_mutex_lock (&xwork->mutex);
{
xwork->stop = (xwork->stop || stop);
pthread_cond_broadcast (&xwork->cond);
}
pthread_mutex_unlock (&xwork->mutex);
for (i = 0; i < xwork->count; i++) {
pthread_join (xwork->cthreads[i], &tret);
tdbg ("CThread id %ld returned %p\n",
xwork->cthreads[i], tret);
}
if (debug) {
assert (xwork->rootjob->refcnt == 1);
dirjob_ret (xwork->rootjob, 0);
}
if (stats)
pthread_spin_destroy(&stats_lock);
return ret;
}
示例5: do_test
static int
do_test (void)
{
pthread_spinlock_t s;
if (pthread_spin_init (&s, PTHREAD_PROCESS_PRIVATE) != 0)
{
puts ("spin_init failed");
return 1;
}
if (pthread_spin_lock (&s) != 0)
{
puts ("spin_lock failed");
return 1;
}
if (pthread_spin_unlock (&s) != 0)
{
puts ("spin_unlock failed");
return 1;
}
if (pthread_spin_destroy (&s) != 0)
{
puts ("spin_destroy failed");
return 1;
}
return 0;
}
示例6: main
int main()
{
pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE);
lockandunlock();
pthread_spin_destroy(&lock);
}
示例7: PADclose
PADclose()
{
while (!ev_fifo.empty())
ev_fifo.pop();
mutex_WasInit = false;
pthread_spin_destroy(&mutex_KeyEvent);
_PADclose();
}
示例8: VOGL_ASSERT
spinlock::~spinlock()
{
#ifdef VOGL_BUILD_DEBUG
VOGL_ASSERT(!m_in_lock);
#endif
pthread_spin_destroy(&m_spinlock);
}
示例9: pthread_spin_destroy
Internal::~Internal(){
#ifdef INTERNAL_USE_SPINLOCKS
pthread_spin_destroy(&_spin);
#else
pthread_mutex_destroy(&_mutex);
pthread_cond_destroy(&_cond);
#endif
}
示例10: init_pipe
int init_pipe(struct pipe* p, int n_dst, int q_depth, int buf_sz)
{
int free_bufs = n_dst * q_depth;
struct pipe_elem* msg_all = (struct pipe_elem*)malloc(
free_bufs * (sizeof(msg_all[0]) + buf_sz));
void* buf_ptr;
int def_dst_n, i;
// allocate bufs
if (!msg_all)
return -1;
p->priv = (void*)msg_all;
// initialize src
if (init_queue(&p->src, free_bufs))
goto free_buf;
// initialize dst
def_dst_n = sizeof(p->_dst) / sizeof(p->_dst[0]);
p->dst = n_dst < def_dst_n ? &p->_dst[0] :
(struct queue*)malloc(n_dst * sizeof(p->dst[0]));
if (!p->dst)
goto free_src;
for (i = 0; i < n_dst; i++) {
if (init_queue(&p->dst[i], q_depth))
goto free_dst;
}
// init spinlock
if (pthread_spin_init(&p->lock, PTHREAD_PROCESS_PRIVATE))
goto free_dst;
// push buffers onto src
buf_ptr = (void*)&msg_all[free_bufs];
for (i = 0; i < free_bufs; i++) {
msg_all[i].buf = buf_ptr;
msg_all[i].seq = 0;
msg_all[i].ref_cnt = 0;
buf_ptr += buf_sz;
assert(!enqueue(&p->src, &msg_all[i]));
}
p->n_dst = n_dst;
return 0;
free_dst :
for (i--; i >= 0; i--)
close_queue(&p->dst[i]);
free_src :
close_queue(&p->src);
free_buf :
free(msg_all);
destroy_lock :
pthread_spin_destroy(&p->lock);
return -1;
}
示例11: pthread_spin_destroy
HawkSpinLock::~HawkSpinLock()
{
if (m_pSpinLock)
{
pthread_spin_destroy((pthread_spinlock_t*)m_pSpinLock);
HawkFree(m_pSpinLock);
m_pSpinLock = 0;
}
}
示例12: dirjob_free
void
dirjob_free (struct dirjob *job)
{
assert (list_empty (&job->list));
pthread_spin_destroy (&job->lock);
free (job->dirname);
free (job);
}
示例13: thread_context_destroy
void thread_context_destroy(struct netsniff_ng_thread_context * thread_ctx)
{
assert(thread_ctx);
pthread_attr_destroy(&thread_ctx->thread_attr);
pthread_mutex_destroy(&thread_ctx->wait_mutex);
pthread_cond_destroy(&thread_ctx->wait_cond);
pthread_spin_destroy(&thread_ctx->config_lock);
}
示例14: spinlock_destroy
bool spinlock_destroy(spinlock_t *lock)
{
const int err = pthread_spin_destroy(lock);
if (err) {
error("spinlock error: %s", errno_error(err));
return false;
}
return true;
}
示例15: nk_port_destroy
void nk_port_destroy(nk_port *port) {
if (!port) {
return;
}
assert(nk_msg_port_empty(&port->msgs));
assert(nk_schob_runq_empty(&port->thds));
pthread_spin_destroy(&port->lock);
nk_freelist_free(&port->host->port_freelist, port);
}