Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ipaaca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramin Yaghoubzadeh Torky
ipaaca
Commits
3c049fa4
Commit
3c049fa4
authored
12 years ago
by
Ramin Yaghoubzadeh
Browse files
Options
Downloads
Patches
Plain Diff
Added a Locker class for already existing raw pthread_mutexes
parent
86d54e1b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ipaacalib/cpp/include/ipaaca/ipaaca.h
+35
-13
35 additions, 13 deletions
ipaacalib/cpp/include/ipaaca/ipaaca.h
with
35 additions
and
13 deletions
ipaacalib/cpp/include/ipaaca/ipaaca.h
+
35
−
13
View file @
3c049fa4
...
@@ -129,6 +129,18 @@ class RemotePushIUStore: public std::map<std::string, boost::shared_ptr<RemotePu
...
@@ -129,6 +129,18 @@ class RemotePushIUStore: public std::map<std::string, boost::shared_ptr<RemotePu
{
{
};
};
class
Exception
:
public
std
::
exception
//{{{
{
protected:
std
::
string
_description
;
public:
inline
Exception
(
const
std
::
string
&
description
=
""
)
:
_description
(
description
)
{
}
inline
~
Exception
()
throw
()
{
}
const
char
*
what
()
const
throw
()
{
return
_description
.
c_str
();
}
};
//}}}
/// a reentrant lock/mutex
/// a reentrant lock/mutex
class
Lock
class
Lock
{
{
...
@@ -163,8 +175,29 @@ class Locker
...
@@ -163,8 +175,29 @@ class Locker
private:
private:
inline
Locker
()
:
_lock
(
NULL
)
{
}
// not available
inline
Locker
()
:
_lock
(
NULL
)
{
}
// not available
public
:
public
:
inline
Locker
(
Lock
&
lock
)
:
_lock
(
&
lock
)
{
_lock
->
lock
();
}
inline
Locker
(
Lock
&
lock
)
:
_lock
(
&
lock
)
{
inline
~
Locker
()
{
_lock
->
unlock
();
}
//std::cout << "-- Locker: lock" << std::endl;
_lock
->
lock
();
}
inline
~
Locker
()
{
//std::cout << "-- Locker: unlock" << std::endl;
_lock
->
unlock
();
}
};
class
PthreadMutexLocker
{
protected:
pthread_mutex_t
*
_lock
;
private:
inline
PthreadMutexLocker
()
:
_lock
(
NULL
)
{
}
// not available
public
:
inline
PthreadMutexLocker
(
pthread_mutex_t
*
lock
)
:
_lock
(
lock
)
{
if
(
!
lock
)
throw
Exception
(
"PthreadMutexLocker got a NULL mutex!"
);
pthread_mutex_lock
(
_lock
);
}
inline
~
PthreadMutexLocker
()
{
pthread_mutex_unlock
(
_lock
);
}
};
};
typedef
std
::
set
<
std
::
string
>
LinkSet
;
typedef
std
::
set
<
std
::
string
>
LinkSet
;
...
@@ -663,17 +696,6 @@ class RemoteMessage: public IUInterface {//{{{
...
@@ -663,17 +696,6 @@ class RemoteMessage: public IUInterface {//{{{
typedef
boost
::
shared_ptr
<
RemoteMessage
>
ptr
;
typedef
boost
::
shared_ptr
<
RemoteMessage
>
ptr
;
};
//}}}
};
//}}}
class
Exception
:
public
std
::
exception
//{{{
{
protected:
std
::
string
_description
;
inline
Exception
(
const
std
::
string
&
description
=
""
)
:
_description
(
description
)
{
}
public
:
inline
~
Exception
()
throw
()
{
}
const
char
*
what
()
const
throw
()
{
return
_description
.
c_str
();
}
};
//}}}
class
IUNotFoundError
:
public
Exception
//{{{
class
IUNotFoundError
:
public
Exception
//{{{
{
{
public:
public:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment