Commit 8825e1b4 authored by Ghislain MARY's avatar Ghislain MARY

belle-sip object pools handled by ApiLock.

parent 37a3f363
#include "ApiLock.h"
#include "belle-sip/object.h"
#include <mutex>
namespace Linphone
{
......@@ -7,22 +9,49 @@ namespace Linphone
// The global API lock
ApiLock gApiLock;
ApiLock::ApiLock()
class ApiLockPrivate
{
public:
ApiLockPrivate() : count(0), pool(nullptr)
{
}
~ApiLockPrivate()
{
}
std::recursive_mutex mut;
int count;
belle_sip_object_pool_t *pool;
};
ApiLock::ApiLock() : d(new ApiLockPrivate())
{
}
ApiLock::~ApiLock()
{
delete d;
}
void ApiLock::Lock()
{
mut.lock();
d->mut.lock();
if (d->count == 0) {
d->pool = belle_sip_object_pool_push();
}
d->count++;
}
void ApiLock::Unlock()
{
mut.unlock();
d->count--;
if ((d->count == 0) && (d->pool != nullptr)) {
belle_sip_object_unref(d->pool);
d->pool = nullptr;
}
d->mut.unlock();
}
}
}
#pragma once
#include <mutex>
namespace Linphone
{
namespace Core
{
class ApiLockPrivate;
/// <summary>
/// A class that implements a mutex mechanism to protect objects accessible from the API surface exposed by this DLL
/// </summary>
......@@ -17,7 +18,7 @@ namespace Linphone
void Unlock();
private:
std::recursive_mutex mut;
ApiLockPrivate *d;
};
// The global API lock
......
#pragma once
#include "LinphoneCoreFactory.h"
#include <mutex>
namespace Linphone
{
......
......@@ -74,7 +74,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<GenerateXMLDocumentationFiles Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</GenerateXMLDocumentationFiles>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir)../submodules\oRTP\include;$(ProjectDir)../submodules/mediastreamer2/include;$(ProjectDir)../submodules/linphone;$(ProjectDir)../submodules/linphone/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">$(ProjectDir)../submodules\oRTP\include;$(ProjectDir)../submodules/mediastreamer2/include;$(ProjectDir)../submodules/linphone;$(ProjectDir)../submodules/linphone/include;$(ProjectDir)../submodules/belle-sip/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ExceptionHandling Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">SyncCThrow</ExceptionHandling>
</ClCompile>
<Link>
......@@ -178,6 +178,9 @@ popd</Command>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\submodules\belle-sip\build\windows\belle-sip\belle-sip.vcxproj">
<Project>{4c225a82-800b-427b-ba7b-61686a9b347f}</Project>
</ProjectReference>
<ProjectReference Include="..\submodules\linphone\build\vsx\LibLinphone\LibLinphone.vcxproj">
<Project>{08dd0d38-d9b5-4626-b60d-b4d76b571142}</Project>
</ProjectReference>
......
......@@ -3,6 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core.vcxproj", "{C8D75245-FFCF-4932-A228-C9CC8BB60B03}"
ProjectSection(ProjectDependencies) = postProject
{08DD0D38-D9B5-4626-B60D-B4D76B571142} = {08DD0D38-D9B5-4626-B60D-B4D76B571142}
{4C225A82-800B-427B-BA7B-61686A9B347F} = {4C225A82-800B-427B-BA7B-61686A9B347F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CoreProxyStub", "CoreProxyStub\CoreProxyStub.vcxproj", "{BBABEEA1-494C-4618-96E3-399873A5558B}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment