Dali 3D User Interface Engine
toolkit-event-thread-callback.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 // CLASS HEADER
19 
20 // EXTERNAL INCLUDES
21 #include <cstddef>
22 #include <semaphore.h>
23 #include <math.h>
24 #include <climits>
25 
26 namespace Dali
27 {
28 
29 namespace
30 {
32 }
33 
35 {
37  unsigned int triggeredCount;
38  unsigned int expectedCount;
39  sem_t mySemaphore;
40 };
41 
43 : mImpl( new Impl() )
44 {
45  mImpl->callback = callback;
46  mImpl->triggeredCount = 0u;
47  mImpl->expectedCount = UINT_MAX;
48  sem_init( &(mImpl->mySemaphore), 0, 0 );
49  gEventThreadCallback = this;
50 }
51 
53 {
54  delete mImpl;
55 }
56 
58 {
61  {
62  sem_post( &(mImpl->mySemaphore) );
63  }
64 }
65 
67 {
68  if( mImpl->triggeredCount >= count )
69  {
70  return;
71  }
72  mImpl->expectedCount = count;
73  sem_wait( &(mImpl->mySemaphore) );
74 }
75 
77 {
78  return mImpl->callback;
79 }
80 
82 {
83  return gEventThreadCallback;
84 }
85 
86 }
Dali Docs Home
Read more about Dali