• R/O
  • SSH
  • HTTPS

natexec: Commit


Commit MetaInfo

Revisión160 (tree)
Tiempo2022-02-11 03:09:16
Autorquiret

Log Message

- patched up the NativeExecutive library code to match the best-practices of the latest C++ standard

Cambiar Resumen

Diferencia incremental

--- NativeExecutive/include/NativeExecutive/CExecutiveManager.h (revision 159)
+++ NativeExecutive/include/NativeExecutive/CExecutiveManager.h (revision 160)
@@ -81,9 +81,10 @@
8181 virtual ~threadPluginInterface( void ) {}
8282
8383 virtual bool OnPluginConstruct( CExecThread *object, threadPluginOffset pluginOffset, threadPluginDescriptor pluginId ) = 0;
84- virtual void OnPluginDestruct( CExecThread *object, threadPluginOffset pluginOffset, threadPluginDescriptor pluginId ) = 0;
85- virtual bool OnPluginAssign( CExecThread *dstObject, const CExecThread *srcObject, threadPluginOffset pluginOffset, threadPluginDescriptor pluginid ) = 0;
86- virtual void DeleteOnUnregister( void )
84+ virtual void OnPluginDestruct( CExecThread *object, threadPluginOffset pluginOffset, threadPluginDescriptor pluginId ) noexcept = 0;
85+ virtual bool OnPluginCopyAssign( CExecThread *dstObject, const CExecThread *srcObject, threadPluginOffset pluginOffset, threadPluginDescriptor pluginid ) = 0;
86+ virtual bool OnPluginMoveAssign( CExecThread *dstObject, CExecThread *srcObject, threadPluginOffset pluginOffset, threadPluginDescriptor pluginid ) = 0;
87+ virtual void DeleteOnUnregister( void ) noexcept
8788 {
8889 return;
8990 }
--- NativeExecutive/include/NativeExecutive/CExecutiveManager.thread.h (revision 159)
+++ NativeExecutive/include/NativeExecutive/CExecutiveManager.thread.h (revision 160)
@@ -60,8 +60,8 @@
6060 void* ResolvePluginMemory( threadPluginOffset offset );
6161 const void* ResolvePluginMemory( threadPluginOffset offset ) const;
6262
63- static bool IsPluginOffsetValid( threadPluginOffset offset );
64- static threadPluginOffset GetInvalidPluginOffset( void );
63+ static bool IsPluginOffsetValid( threadPluginOffset offset ) noexcept;
64+ static threadPluginOffset GetInvalidPluginOffset( void ) noexcept;
6565 };
6666
6767 // Cleanup-interface executed on thread destruction.
--- NativeExecutive/include/NativeExecutive/CExecutiveManager.threadplugins.h (revision 159)
+++ NativeExecutive/include/NativeExecutive/CExecutiveManager.threadplugins.h (revision 160)
@@ -39,7 +39,7 @@
3939 }
4040
4141 template <typename interfaceType, typename... constrArgs>
42- inline threadPluginOffset RegisterCustomPlugin( size_t pluginSize, size_t pluginAlignment, const ExecutiveManager::threadPluginDescriptor& pluginId, constrArgs... args )
42+ inline threadPluginOffset RegisterCustomPlugin( size_t pluginSize, size_t pluginAlignment, const ExecutiveManager::threadPluginDescriptor& pluginId, constrArgs&&... args )
4343 {
4444 struct interfaceProxyType final : public interfaceType
4545 {
@@ -48,7 +48,7 @@
4848 this->manager = manager;
4949 }
5050
51- void DeleteOnUnregister( void ) override
51+ void DeleteOnUnregister( void ) noexcept override
5252 {
5353 CExecutiveManager *nativeMan = this->manager;
5454
@@ -88,7 +88,7 @@
8888 }
8989 }
9090
91- static inline bool IsOffsetValid( threadPluginOffset offset )
91+ static AINLINE bool IsOffsetValid( threadPluginOffset offset ) noexcept
9292 {
9393 return CExecThread::IsPluginOffsetValid( offset );
9494 }
@@ -100,7 +100,7 @@
100100 template <typename structType, bool isDependantStruct = false>
101101 struct execThreadStructPluginRegister
102102 {
103- inline execThreadStructPluginRegister( void )
103+ inline execThreadStructPluginRegister( void ) noexcept
104104 {
105105 this->execMan = nullptr;
106106 this->pluginOffset = CExecThread::GetInvalidPluginOffset();
--- NativeExecutive/src/CExecutiveManager.cpp (revision 159)
+++ NativeExecutive/src/CExecutiveManager.cpp (revision 160)
@@ -327,21 +327,6 @@
327327 nativeMan->isRuntimeTerminating = true;
328328 }
329329
330-struct basicFiberObjectConstructor
331-{
332- CExecutiveManagerNative *manager;
333-
334- AINLINE basicFiberObjectConstructor( CExecutiveManagerNative *manager )
335- {
336- this->manager = manager;
337- }
338-
339- AINLINE CFiberImpl* Construct( void *mem ) const
340- {
341- return new (mem) CFiberImpl( this->manager, nullptr, nullptr );
342- }
343-};
344-
345330 CFiber* CExecutiveManager::CreateFiber( CFiber::fiberexec_t proc, void *userdata, size_t stackSize )
346331 {
347332 CExecutiveManagerNative *nativeMan = (CExecutiveManagerNative*)this;
@@ -361,13 +346,8 @@
361346
362347 NatExecStandardObjectAllocator objMemAlloc( nativeMan );
363348
364- CFiberImpl *fiber = nullptr;
365- {
366- basicFiberObjectConstructor constructor( nativeMan );
349+ CFiberImpl *fiber = fiberEnv->fiberFact.ConstructArgs( objMemAlloc, nativeMan, nullptr, nullptr );
367350
368- fiber = fiberEnv->fiberFact.ConstructTemplate( objMemAlloc, constructor );
369- }
370-
371351 if ( !fiber )
372352 {
373353 return nullptr;
--- NativeExecutive/src/CExecutiveManager.thread.cpp (revision 159)
+++ NativeExecutive/src/CExecutiveManager.thread.cpp (revision 160)
@@ -566,7 +566,7 @@
566566 }
567567
568568 bool OnPluginConstruct( CExecThreadImpl *thread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOffset, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor id ) override;
569- void OnPluginDestruct( CExecThreadImpl *thread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOffset, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor id ) override;
569+ void OnPluginDestruct( CExecThreadImpl *thread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOffset, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor id ) noexcept override;
570570 };
571571
572572 #ifdef _WIN32
@@ -854,7 +854,7 @@
854854 return true;
855855 }
856856
857-void nativeThreadPluginInterface::OnPluginDestruct( CExecThreadImpl *thread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOffset, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor id )
857+void nativeThreadPluginInterface::OnPluginDestruct( CExecThreadImpl *thread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOffset, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor id ) noexcept
858858 {
859859 nativeThreadPlugin *info = privateThreadEnvironment::threadPluginContainer_t::RESOLVE_STRUCT <nativeThreadPlugin> ( thread, pluginOffset );
860860
@@ -1280,46 +1280,21 @@
12801280 return privateThreadEnvironment::threadPluginContainer_t::RESOLVE_STRUCT <void> ( nativeThread, offset );
12811281 }
12821282
1283-bool CExecThread::IsPluginOffsetValid( threadPluginOffset offset )
1283+bool CExecThread::IsPluginOffsetValid( threadPluginOffset offset ) noexcept
12841284 {
12851285 return privateThreadEnvironment::threadPluginContainer_t::IsOffsetValid( offset );
12861286 }
12871287
1288-threadPluginOffset CExecThread::GetInvalidPluginOffset( void )
1288+threadPluginOffset CExecThread::GetInvalidPluginOffset( void ) noexcept
12891289 {
12901290 return privateThreadEnvironment::threadPluginContainer_t::INVALID_PLUGIN_OFFSET;
12911291 }
12921292
1293-struct threadObjectConstructor
1294-{
1295- inline threadObjectConstructor( CExecutiveManagerNative *manager, bool isLocallyRemoteThread, const char *hint_thread_name, void *userdata, size_t stackSize, CExecThread::threadEntryPoint_t entryPoint )
1296- {
1297- this->manager = manager;
1298- this->isLocallyRemoteThread = isLocallyRemoteThread;
1299- this->hint_thread_name = hint_thread_name;
1300- this->userdata = userdata;
1301- this->stackSize = stackSize;
1302- this->entryPoint = entryPoint;
1303- }
1304-
1305- inline CExecThreadImpl* Construct( void *mem ) const
1306- {
1307- return new (mem) CExecThreadImpl( this->manager, this->isLocallyRemoteThread, this->hint_thread_name, this->userdata, this->stackSize, this->entryPoint );
1308- }
1309-
1310- CExecutiveManagerNative *manager;
1311- bool isLocallyRemoteThread;
1312- const char *hint_thread_name;
1313- void *userdata;
1314- size_t stackSize;
1315- CExecThread::threadEntryPoint_t entryPoint;
1316-};
1317-
13181293 threadPluginOffset CExecutiveManager::RegisterThreadPlugin( size_t pluginSize, size_t pluginAlignment, threadPluginInterface *pluginInterface )
13191294 {
13201295 struct threadPluginInterface_pipe : public privateThreadEnvironment::threadPluginContainer_t::pluginInterface
13211296 {
1322- inline threadPluginInterface_pipe( CExecutiveManagerNative *nativeMan, ExecutiveManager::threadPluginInterface *publicIntf )
1297+ inline threadPluginInterface_pipe( CExecutiveManagerNative *nativeMan, ExecutiveManager::threadPluginInterface *publicIntf ) noexcept
13231298 {
13241299 this->nativeMan = nativeMan;
13251300 this->publicIntf = publicIntf;
@@ -1330,19 +1305,26 @@
13301305 return this->publicIntf->OnPluginConstruct( nativeThread, pluginOff, ExecutiveManager::threadPluginDescriptor( pluginDesc.pluginId ) );
13311306 }
13321307
1333- void OnPluginDestruct( CExecThreadImpl *nativeThread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOff, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor pluginDesc ) override
1308+ void OnPluginDestruct( CExecThreadImpl *nativeThread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOff, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor pluginDesc ) noexcept override
13341309 {
13351310 this->publicIntf->OnPluginDestruct( nativeThread, pluginOff, ExecutiveManager::threadPluginDescriptor( pluginDesc.pluginId ) );
13361311 }
13371312
1338- bool OnPluginAssign( CExecThreadImpl *dstNativeThread, const CExecThreadImpl *srcNativeThread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOff, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor pluginDesc ) override
1313+ bool OnPluginCopyAssign( CExecThreadImpl *dstNativeThread, const CExecThreadImpl *srcNativeThread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOff, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor pluginDesc ) override
13391314 {
1340- return this->publicIntf->OnPluginAssign( dstNativeThread, srcNativeThread, pluginOff, ExecutiveManager::threadPluginDescriptor( pluginDesc.pluginId ) );
1315+ return this->publicIntf->OnPluginCopyAssign( dstNativeThread, srcNativeThread, pluginOff, ExecutiveManager::threadPluginDescriptor( pluginDesc.pluginId ) );
13411316 }
13421317
1343- void DeleteOnUnregister( void )
1318+ bool OnPluginMoveAssign( CExecThreadImpl *dstNativeThread, CExecThreadImpl *srcNativeThread, privateThreadEnvironment::threadPluginContainer_t::pluginOffset_t pluginOff, privateThreadEnvironment::threadPluginContainer_t::pluginDescriptor pluginDesc ) override
13441319 {
1320+ return this->publicIntf->OnPluginMoveAssign( dstNativeThread, srcNativeThread, pluginOff, ExecutiveManager::threadPluginDescriptor( pluginDesc.pluginId ) );
1321+ }
1322+
1323+ void DeleteOnUnregister( void ) noexcept override
1324+ {
13451325 NatExecStandardObjectAllocator memAlloc( this->nativeMan );
1326+
1327+ this->publicIntf->DeleteOnUnregister();
13461328
13471329 eir::dyn_del_struct <threadPluginInterface_pipe> ( memAlloc, nullptr, this );
13481330 }
@@ -1428,11 +1410,9 @@
14281410
14291411 try
14301412 {
1431- threadObjectConstructor threadConstruct( nativeMan, false, hint_thread_name, userdata, stackSize, entryPoint );
1432-
14331413 NatExecStandardObjectAllocator memAlloc( nativeMan );
14341414
1435- CExecThreadImpl *nativeThread = threadEnv->threadPlugins.ConstructTemplate( memAlloc, threadConstruct );
1415+ CExecThreadImpl *nativeThread = threadEnv->threadPlugins.ConstructArgs( memAlloc, nativeMan, false, hint_thread_name, userdata, stackSize, entryPoint );
14361416
14371417 if ( nativeThread )
14381418 {
@@ -1569,16 +1549,15 @@
15691549
15701550 try
15711551 {
1572- threadObjectConstructor threadConstruct(
1552+ NatExecStandardObjectAllocator memAlloc( nativeMan );
1553+
1554+ newThreadInfo = threadEnv->threadPlugins.ConstructArgs(
1555+ memAlloc,
15731556 nativeMan,
15741557 true, // is a remote thread.
15751558 "remote-thread",
15761559 nullptr, 0, nullptr
15771560 );
1578-
1579- NatExecStandardObjectAllocator memAlloc( nativeMan );
1580-
1581- newThreadInfo = threadEnv->threadPlugins.ConstructTemplate( memAlloc, threadConstruct );
15821561 }
15831562 catch( ... )
15841563 {
Show on old repository browser