Subversion Repositories mdb

Rev

Rev 55 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 55 Rev 59
Line 546... Line 546...
546
		usleep(ms);
546
		usleep(ms);
547
}
547
}
548
 
548
 
549
void waiting(useconds_t ms, waitcall callback, void *data)
549
void waiting(useconds_t ms, waitcall callback, void *data)
550
{
550
{
-
 
551
pthread_attr_t attr;
-
 
552
 
551
	if (ms == 0 || callback == NULL)
553
	if (ms == 0 || callback == NULL)
552
		return;
554
		return;
553
 
555
 
554
	/* Start a thread and call the callback function after the waiting time
556
	/* Start a thread and call the callback function after the waiting time
555
	 * is over.
557
	 * is over.
556
	 */
558
	 */
557
	usleep(ms);
559
	usleep(ms);
558
 
560
 
-
 
561
	// Prepare the thread attributes
-
 
562
	if (pthread_attr_init(&attr) != 0)
-
 
563
	{
-
 
564
		syslog(LOG_DAEMON,"Error getting thread attributes.");
-
 
565
		return;
-
 
566
	}
-
 
567
	
-
 
568
	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
-
 
569
	{
-
 
570
		syslog(LOG_DAEMON,"Error setting thread attributes.");
-
 
571
		return;
-
 
572
	}
-
 
573
 
559
	if (pthread_create(&pthr_wait, NULL, callback, data) != 0)
574
	if (pthread_create(&pthr_wait, &attr, callback, data) != 0)
560
	{
575
	{
561
		 syslog (LOG_DAEMON,"Creation of thread \"pthr_wait\" failed!");
576
		 syslog (LOG_DAEMON,"Creation of thread \"pthr_wait\" failed!");
562
		 return;
577
		 return;
563
	}
578
	}
564
}
579
}