Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
b47ae754
Kaydet (Commit)
b47ae754
authored
Kas 26, 2002
tarafından
Tino Rachui
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#105339#support for suspend and resume of event notifier thread
üst
f533cf27
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
20 deletions
+116
-20
FilePicker.cxx
fpicker/source/win32/filepicker/FilePicker.cxx
+44
-4
FilePicker.hxx
fpicker/source/win32/filepicker/FilePicker.hxx
+7
-2
asynceventnotifier.cxx
fpicker/source/win32/filepicker/asynceventnotifier.cxx
+49
-9
asynceventnotifier.hxx
fpicker/source/win32/filepicker/asynceventnotifier.hxx
+16
-5
No files found.
fpicker/source/win32/filepicker/FilePicker.cxx
Dosyayı görüntüle @
b47ae754
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
* $RCSfile: FilePicker.cxx,v $
* $RCSfile: FilePicker.cxx,v $
*
*
* $Revision: 1.1
7
$
* $Revision: 1.1
8
$
*
*
* last change: $Author: tra $ $Date: 2002-
03-28 08:57:33
$
* last change: $Author: tra $ $Date: 2002-
11-26 09:21:59
$
*
*
* The Contents of this file are made available subject to the terms of
* The Contents of this file are made available subject to the terms of
* either of the following licenses
* either of the following licenses
...
@@ -115,6 +115,10 @@ using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
...
@@ -115,6 +115,10 @@ using namespace ::com::sun::star::ui::dialogs::TemplateDescription;
namespace
namespace
{
{
// controling event notifications
const
bool
STARTUP_SUSPENDED
=
true
;
const
bool
STARTUP_ALIVE
=
false
;
uno
::
Sequence
<
rtl
::
OUString
>
SAL_CALL
FilePicker_getSupportedServiceNames
()
uno
::
Sequence
<
rtl
::
OUString
>
SAL_CALL
FilePicker_getSupportedServiceNames
()
{
{
uno
::
Sequence
<
rtl
::
OUString
>
aRet
(
2
);
uno
::
Sequence
<
rtl
::
OUString
>
aRet
(
2
);
...
@@ -287,6 +291,42 @@ rtl::OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const
...
@@ -287,6 +291,42 @@ rtl::OUString SAL_CALL CFilePicker::helpRequested(FilePickerEvent aEvent) const
return
aHelpText
;
return
aHelpText
;
}
}
//-------------------------------------
//
//-------------------------------------
bool
CFilePicker
::
startupEventNotification
(
bool
bStartupSuspended
)
{
return
m_aAsyncEventNotifier
.
startup
(
bStartupSuspended
);
}
//-------------------------------------
//
//-------------------------------------
void
CFilePicker
::
shutdownEventNotification
()
{
m_aAsyncEventNotifier
.
shutdown
();
}
//-------------------------------------
//
//-------------------------------------
void
CFilePicker
::
suspendEventNotification
()
{
m_aAsyncEventNotifier
.
suspend
();
}
//-------------------------------------
//
//-------------------------------------
void
CFilePicker
::
resumeEventNotification
()
{
m_aAsyncEventNotifier
.
resume
();
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// XFilePicker functions
// XFilePicker functions
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
...
@@ -412,7 +452,7 @@ sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException)
...
@@ -412,7 +452,7 @@ sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException)
sal_Int16
ret
;
sal_Int16
ret
;
if
(
m_aAsyncEventNotifier
.
start
(
))
if
(
startupEventNotification
(
STARTUP_SUSPENDED
))
{
{
// we should not block in this call else
// we should not block in this call else
// in the case of an event the client can't
// in the case of an event the client can't
...
@@ -420,7 +460,7 @@ sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException)
...
@@ -420,7 +460,7 @@ sal_Int16 SAL_CALL CFilePicker::execute() throw(uno::RuntimeException)
// deadlock !!!!!
// deadlock !!!!!
ret
=
m_pImpl
->
execute
(
);
ret
=
m_pImpl
->
execute
(
);
m_aAsyncEventNotifier
.
stop
();
shutdownEventNotification
();
}
}
else
else
{
{
...
...
fpicker/source/win32/filepicker/FilePicker.hxx
Dosyayı görüntüle @
b47ae754
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
* $RCSfile: FilePicker.hxx,v $
* $RCSfile: FilePicker.hxx,v $
*
*
* $Revision: 1.
8
$
* $Revision: 1.
9
$
*
*
* last change: $Author: tra $ $Date: 2002-
03-28 08:57:33
$
* last change: $Author: tra $ $Date: 2002-
11-26 09:21:59
$
*
*
* The Contents of this file are made available subject to the terms of
* The Contents of this file are made available subject to the terms of
* either of the following licenses
* either of the following licenses
...
@@ -294,6 +294,11 @@ public:
...
@@ -294,6 +294,11 @@ public:
void
SAL_CALL
controlStateChanged
(
::
com
::
sun
::
star
::
ui
::
dialogs
::
FilePickerEvent
aEvent
);
void
SAL_CALL
controlStateChanged
(
::
com
::
sun
::
star
::
ui
::
dialogs
::
FilePickerEvent
aEvent
);
void
SAL_CALL
dialogSizeChanged
(
);
void
SAL_CALL
dialogSizeChanged
(
);
bool
startupEventNotification
(
bool
bStartupSuspended
);
void
shutdownEventNotification
();
void
suspendEventNotification
();
void
resumeEventNotification
();
private
:
private
:
// prevent copy and assignment
// prevent copy and assignment
CFilePicker
(
const
CFilePicker
&
);
CFilePicker
(
const
CFilePicker
&
);
...
...
fpicker/source/win32/filepicker/asynceventnotifier.cxx
Dosyayı görüntüle @
b47ae754
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
* $RCSfile: asynceventnotifier.cxx,v $
* $RCSfile: asynceventnotifier.cxx,v $
*
*
* $Revision: 1.
9
$
* $Revision: 1.
10
$
*
*
* last change: $Author: tra $ $Date: 2002-
03-28 08:57:33
$
* last change: $Author: tra $ $Date: 2002-
11-26 09:21:59
$
*
*
* The Contents of this file are made available subject to the terms of
* The Contents of this file are made available subject to the terms of
* either of the following licenses
* either of the following licenses
...
@@ -97,8 +97,21 @@ CAsyncEventNotifier::CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelpe
...
@@ -97,8 +97,21 @@ CAsyncEventNotifier::CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelpe
m_hThread
(
0
),
m_hThread
(
0
),
m_bRun
(
false
),
m_bRun
(
false
),
m_ThreadId
(
0
),
m_ThreadId
(
0
),
m_rBroadcastHelper
(
rBroadcastHelper
)
m_rBroadcastHelper
(
rBroadcastHelper
),
m_NotifyEvent
(
m_hEvents
[
0
]),
m_ResumeNotifying
(
m_hEvents
[
1
])
{
{
// m_NotifyEvent
m_hEvents
[
0
]
=
CreateEvent
(
0
,
/* no security */
true
,
/* manual reset */
false
,
/* initial state not signaled */
0
);
/* automatic name */
// m_ResumeNotifying
m_hEvents
[
1
]
=
CreateEvent
(
0
,
/* no security */
true
,
/* manual reset */
false
,
/* initial state not signaled */
0
);
/* automatic name */
}
}
//------------------------------------------------
//------------------------------------------------
...
@@ -108,13 +121,16 @@ CAsyncEventNotifier::CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelpe
...
@@ -108,13 +121,16 @@ CAsyncEventNotifier::CAsyncEventNotifier(cppu::OBroadcastHelper& rBroadcastHelpe
CAsyncEventNotifier
::~
CAsyncEventNotifier
()
CAsyncEventNotifier
::~
CAsyncEventNotifier
()
{
{
OSL_ENSURE
(
0
==
m_hThread
,
"Thread not stopped, destroying this instance leads to desaster"
);
OSL_ENSURE
(
0
==
m_hThread
,
"Thread not stopped, destroying this instance leads to desaster"
);
CloseHandle
(
m_hEvents
[
0
]);
CloseHandle
(
m_hEvents
[
1
]);
}
}
//------------------------------------------------
//------------------------------------------------
//
//
//------------------------------------------------
//------------------------------------------------
bool
SAL_CALL
CAsyncEventNotifier
::
start
(
)
bool
SAL_CALL
CAsyncEventNotifier
::
start
up
(
bool
bCreateSuspended
)
{
{
osl
::
MutexGuard
aGuard
(
m_Mutex
);
osl
::
MutexGuard
aGuard
(
m_Mutex
);
...
@@ -125,6 +141,9 @@ bool SAL_CALL CAsyncEventNotifier::start()
...
@@ -125,6 +141,9 @@ bool SAL_CALL CAsyncEventNotifier::start()
// not be overwritten
// not be overwritten
if
(
!
m_bRun
)
if
(
!
m_bRun
)
{
{
if
(
!
bCreateSuspended
)
SetEvent
(
m_ResumeNotifying
);
m_hThread
=
(
HANDLE
)
_beginthreadex
(
m_hThread
=
(
HANDLE
)
_beginthreadex
(
NULL
,
0
,
CAsyncEventNotifier
::
ThreadProc
,
this
,
0
,
&
m_ThreadId
);
NULL
,
0
,
CAsyncEventNotifier
::
ThreadProc
,
this
,
0
,
&
m_ThreadId
);
...
@@ -143,7 +162,7 @@ bool SAL_CALL CAsyncEventNotifier::start()
...
@@ -143,7 +162,7 @@ bool SAL_CALL CAsyncEventNotifier::start()
//
//
//------------------------------------------------
//------------------------------------------------
void
SAL_CALL
CAsyncEventNotifier
::
s
top
()
void
SAL_CALL
CAsyncEventNotifier
::
s
hutdown
()
{
{
OSL_PRECOND
(
GetCurrentThreadId
()
!=
m_ThreadId
,
"Method called in wrong thread context!"
);
OSL_PRECOND
(
GetCurrentThreadId
()
!=
m_ThreadId
,
"Method called in wrong thread context!"
);
...
@@ -153,7 +172,10 @@ void SAL_CALL CAsyncEventNotifier::stop()
...
@@ -153,7 +172,10 @@ void SAL_CALL CAsyncEventNotifier::stop()
m_bRun
=
false
;
m_bRun
=
false
;
m_EventList
.
clear
();
m_EventList
.
clear
();
m_NotifyEvent
.
set
(
);
// awake the the notifier thread
SetEvent
(
m_ResumeNotifying
);
SetEvent
(
m_NotifyEvent
);
// releas the mutex here because the event
// releas the mutex here because the event
// notifier thread may need it to finish
// notifier thread may need it to finish
...
@@ -177,6 +199,24 @@ void SAL_CALL CAsyncEventNotifier::stop()
...
@@ -177,6 +199,24 @@ void SAL_CALL CAsyncEventNotifier::stop()
//
//
//------------------------------------------------
//------------------------------------------------
void
CAsyncEventNotifier
::
suspend
()
{
ResetEvent
(
m_ResumeNotifying
);
}
//------------------------------------------------
//
//------------------------------------------------
void
CAsyncEventNotifier
::
resume
()
{
SetEvent
(
m_ResumeNotifying
);
}
//------------------------------------------------
//
//------------------------------------------------
void
SAL_CALL
CAsyncEventNotifier
::
notifyEvent
(
CEventNotification
*
EventNotification
)
void
SAL_CALL
CAsyncEventNotifier
::
notifyEvent
(
CEventNotification
*
EventNotification
)
{
{
osl
::
MutexGuard
aGuard
(
m_Mutex
);
osl
::
MutexGuard
aGuard
(
m_Mutex
);
...
@@ -186,7 +226,7 @@ void SAL_CALL CAsyncEventNotifier::notifyEvent(CEventNotification* EventNotifica
...
@@ -186,7 +226,7 @@ void SAL_CALL CAsyncEventNotifier::notifyEvent(CEventNotification* EventNotifica
if
(
m_bRun
)
if
(
m_bRun
)
{
{
m_EventList
.
push_back
(
EventNotification
);
m_EventList
.
push_back
(
EventNotification
);
m_NotifyEvent
.
set
(
);
SetEvent
(
m_NotifyEvent
);
}
}
}
}
...
@@ -208,7 +248,7 @@ void SAL_CALL CAsyncEventNotifier::resetNotifyEvent()
...
@@ -208,7 +248,7 @@ void SAL_CALL CAsyncEventNotifier::resetNotifyEvent()
{
{
osl
::
MutexGuard
aGuard
(
m_Mutex
);
osl
::
MutexGuard
aGuard
(
m_Mutex
);
if
(
0
==
m_EventList
.
size
())
if
(
0
==
m_EventList
.
size
())
m_NotifyEvent
.
reset
(
);
ResetEvent
(
m_NotifyEvent
);
}
}
//------------------------------------------------
//------------------------------------------------
...
@@ -239,7 +279,7 @@ void SAL_CALL CAsyncEventNotifier::run()
...
@@ -239,7 +279,7 @@ void SAL_CALL CAsyncEventNotifier::run()
{
{
while
(
m_bRun
)
while
(
m_bRun
)
{
{
m_NotifyEvent
.
wait
(
);
WaitForMultipleObjects
(
2
,
m_hEvents
,
true
,
INFINITE
);
if
(
m_bRun
)
if
(
m_bRun
)
{
{
...
...
fpicker/source/win32/filepicker/asynceventnotifier.hxx
Dosyayı görüntüle @
b47ae754
...
@@ -2,9 +2,9 @@
...
@@ -2,9 +2,9 @@
*
*
* $RCSfile: asynceventnotifier.hxx,v $
* $RCSfile: asynceventnotifier.hxx,v $
*
*
* $Revision: 1.
5
$
* $Revision: 1.
6
$
*
*
* last change: $Author: tra $ $Date: 2002-
03-28 08:57:33
$
* last change: $Author: tra $ $Date: 2002-
11-26 09:21:59
$
*
*
* The Contents of this file are made available subject to the terms of
* The Contents of this file are made available subject to the terms of
* either of the following licenses
* either of the following licenses
...
@@ -97,8 +97,17 @@ public:
...
@@ -97,8 +97,17 @@ public:
CAsyncEventNotifier
(
cppu
::
OBroadcastHelper
&
rBroadcastHelper
);
CAsyncEventNotifier
(
cppu
::
OBroadcastHelper
&
rBroadcastHelper
);
~
CAsyncEventNotifier
();
~
CAsyncEventNotifier
();
bool
SAL_CALL
start
();
bool
SAL_CALL
startup
(
bool
bCreateSuspended
=
true
);
void
SAL_CALL
stop
();
void
SAL_CALL
shutdown
();
// notifications may be added the
// the event queue but will only
// be notified to the clients after
// resume was called
void
suspend
();
// resume notifying events
void
resume
();
// this class is responsible for the memory management of
// this class is responsible for the memory management of
// the CEventNotification instance
// the CEventNotification instance
...
@@ -120,7 +129,9 @@ private:
...
@@ -120,7 +129,9 @@ private:
bool
m_bRun
;
bool
m_bRun
;
unsigned
m_ThreadId
;
unsigned
m_ThreadId
;
::
cppu
::
OBroadcastHelper
&
m_rBroadcastHelper
;
::
cppu
::
OBroadcastHelper
&
m_rBroadcastHelper
;
osl
::
Condition
m_NotifyEvent
;
HANDLE
m_hEvents
[
2
];
HANDLE
&
m_NotifyEvent
;
HANDLE
&
m_ResumeNotifying
;
osl
::
Mutex
m_Mutex
;
osl
::
Mutex
m_Mutex
;
// prevent copy and assignment
// prevent copy and assignment
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment