summaryrefslogtreecommitdiff
path: root/xfa/src/fwl/src/core/fwl_threadimp.cpp
blob: 7d9609a9cd9f1e7e4cace264274d4cc0d0fd1c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "../../../foxitlib.h"
#include "include/fwl_targetimp.h"
#include "include/fwl_noteimp.h"
#include "include/fwl_threadimp.h"
#include "include/fwl_appimp.h"
CFWL_ControlThread::~CFWL_ControlThread()
{
}
FWL_ERR CFWL_ControlThread::Run(FWL_HTHREAD hThread)
{
    static int count = 0;
    while (TRUE) {
    }
    return FWL_ERR_Succeeded;
}
IFWL_Thread * IFWL_Thread::Create()
{
    return (IFWL_Thread *) FX_NEW CFWL_Thread;
}
CFWL_Thread::CFWL_Thread()
{
}
CFWL_Thread::~CFWL_Thread()
{
}
FWL_ERR CFWL_Thread::Run(FWL_HTHREAD hThread)
{
    return FWL_ERR_Succeeded;
}
CFWL_ControlThread *	CFWL_NoteThread::_assistantThreadHandler	= NULL;
FWL_HTHREAD				CFWL_NoteThread::_assistantThread			= NULL;
int32_t				CFWL_NoteThread::_refCount					= 0;
IFWL_NoteThread* IFWL_NoteThread::Create()
{
    return (IFWL_NoteThread*) FX_NEW CFWL_NoteThread;
}
CFWL_NoteThread::CFWL_NoteThread()
    : m_hThread(NULL)
{
    m_pNoteDriver = FX_NEW CFWL_NoteDriver;
}
CFWL_NoteThread::~CFWL_NoteThread()
{
    if (m_hThread) {
        FWL_StopThread(m_hThread, 0);
    }
    if (m_pNoteDriver) {
        delete m_pNoteDriver;
        m_pNoteDriver = NULL;
    }
}
FWL_ERR CFWL_NoteThread::Run(FWL_HTHREAD hThread)
{
    _FWL_RETURN_VALUE_IF_FAIL(m_pNoteDriver, FWL_ERR_Indefinite);
    FWL_ERR result = m_pNoteDriver->Run();
    return result;
}
IFWL_NoteDriver* CFWL_NoteThread::GetNoteDriver()
{
    return (IFWL_NoteDriver*)m_pNoteDriver;
}
extern IFWL_AdapterNative* FWL_GetAdapterNative();
FWL_HTHREAD FWL_StartThread(IFWL_Thread *pThread, FX_BOOL bSuspended )
{
    IFWL_AdapterNative *pNative = FWL_GetAdapterNative();
    _FWL_RETURN_VALUE_IF_FAIL(pNative, NULL);
    IFWL_AdapterThreadMgr *pThreadMgr = pNative->GetThreadMgr();
    _FWL_RETURN_VALUE_IF_FAIL(pThreadMgr, NULL);
    FWL_HTHREAD hThread = NULL;
    pThreadMgr->Start(pThread, hThread, bSuspended);
    return hThread;
}
FWL_ERR FWL_ResumeThread(FWL_HTHREAD hThread)
{
    IFWL_AdapterNative * Native = FWL_GetAdapterNative();
    _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
    IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
    _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
    return ThreadMgr->Resume(hThread);
}
FWL_ERR FWL_SuspendThread(FWL_HTHREAD hThread)
{
    IFWL_AdapterNative * Native = FWL_GetAdapterNative();
    _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
    IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
    _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
    return ThreadMgr->Suspend(hThread);
}
FWL_ERR FWL_KillThread(FWL_HTHREAD hThread, int32_t iExitCode)
{
    IFWL_AdapterNative * Native = FWL_GetAdapterNative();
    _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
    IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
    _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
    return ThreadMgr->Kill(hThread, iExitCode);
}
FWL_ERR FWL_StopThread(FWL_HTHREAD hThread, int32_t iExitCode)
{
    IFWL_AdapterNative * Native = FWL_GetAdapterNative();
    _FWL_RETURN_VALUE_IF_FAIL(Native, FWL_ERR_Indefinite);
    IFWL_AdapterThreadMgr * ThreadMgr = Native->GetThreadMgr();
    _FWL_RETURN_VALUE_IF_FAIL(ThreadMgr, FWL_ERR_Indefinite);
    return ThreadMgr->Stop(hThread, iExitCode);
}
FWL_HMUTEX FWL_CreateMutex()
{
    return NULL;
}
FWL_ERR	FWL_DestroyMutex(FWL_HMUTEX hMutex)
{
    return FWL_ERR_Succeeded;
}
FWL_ERR	FWL_LockMutex(FWL_HMUTEX hMutex)
{
    return FWL_ERR_Succeeded;
}
FWL_ERR	FWL_TryLockMutex(FWL_HMUTEX hMutex)
{
    return FWL_ERR_Succeeded;
}
FWL_ERR	FWL_UnlockMutex(FWL_HMUTEX hMutex)
{
    return FWL_ERR_Succeeded;
}
FWL_ERR	FWL_IsLockedMutex(FWL_HMUTEX hMutex, FX_BOOL &bLocked)
{
    return FWL_ERR_Succeeded;
}
FWL_HSEMAPHORE FWL_CreateSemaphore()
{
    return (FWL_HSEMAPHORE) IFWL_AdapterSemaphore::Create();
}
FWL_ERR	FWL_DestroySemaphore(FWL_HSEMAPHORE hSemaphore)
{
    return ((IFWL_AdapterSemaphore*)hSemaphore)->Destroy();
}
FWL_ERR	FWL_WaitSemaphore(FWL_HSEMAPHORE hSemaphore)
{
    return ((IFWL_AdapterSemaphore*)hSemaphore)->Wait();
}
FWL_ERR	FWL_PostSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t down )
{
    return ((IFWL_AdapterSemaphore*)hSemaphore)->Post();
}
FWL_ERR	FWL_GetSemaphoreValue(FWL_HSEMAPHORE hSemaphore, int32_t &value)
{
    return ((IFWL_AdapterSemaphore*)hSemaphore)->Value((FX_DWORD &)value);
}
FWL_ERR	FWL_ResetSemaphore(FWL_HSEMAPHORE hSemaphore, int32_t init)
{
    return ((IFWL_AdapterSemaphore*)hSemaphore)->Reset(init);
}