Using C External Functions on separate threads 
Author Message
 Using C External Functions on separate threads

Subject: (VASTOS2) How to use a C External Function part on a new thread?
I have just struggled with my limited C to create a DLL. The function  
that I want to call waits on another program, so unless it's called  
on a separate thread VA just hangs. The return data from the function  
is a pointer to a C structure. If I use the C parts, then I can      
tear off the records contained within the structure, but I can't      
usefully use it as just sending it 'execute' causes the VA hang.      
If I use coroutineCallWith:threadKey: against a PlatformFunction      
object created from my DLL, then it just returns an AbtPointer.          
So I have two questions:                                              
- can I access the data pointed to by the AbtPointer?                  
- or is there any way of invoking the C External Function part's      
  execute action on a separate thread?                                    
Martin Connolly



Wed, 18 Jun 1902 08:00:00 GMT  
 Using C External Functions on separate threads

Hi Martin,

You can call a C routine to run on a separate thread using the
PlatformFunctions>> coroutineCallWith:with:threadKey: method. Create a
new thread and pass it on to the method like the following.

| thread |
thread := [] fork.
(PlatformFunctions at: 'DosBeep' )
  coroutineCallWith: 440
  with: 3000
  threadKey: thread.

This would not suspend the VisualAge thread and will execute the C
routine on a separate thread created. Refr to VisualAge for Smalltalk
User's guide for more info. Hope this helps.

Jags
Object Edge Inc.

Quote:

> Subject: (VASTOS2) How to use a C External Function part on a new thread?
> I have just struggled with my limited C to create a DLL. The function
> that I want to call waits on another program, so unless it's called
> on a separate thread VA just hangs. The return data from the function
> is a pointer to a C structure. If I use the C parts, then I can
> tear off the records contained within the structure, but I can't
> usefully use it as just sending it 'execute' causes the VA hang.
> If I use coroutineCallWith:threadKey: against a PlatformFunction
> object created from my DLL, then it just returns an AbtPointer.
> So I have two questions:
> - can I access the data pointed to by the AbtPointer?
> - or is there any way of invoking the C External Function part's
>   execute action on a separate thread?
> Martin Connolly



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using old External Functions (xfcn) in REALbasic

2. Using external DLL functions in a method

3. Using Queue in External Function

4. External Functions Using VERILOG PLI

5. Separating algorithms from containers by external iterators

6. Separating external interface and body?

7. External link errors when using external Catalyst SocketTools Library Edition 2.15 dll

8. vi server require for separate threads?

9. is a separate interpreter another thread?

10. Non-threaded function in a threaded recursion?

11. Threaded Tcl calls non-thread-safe library functions

12. Loop separate sounds, separate intervals

 

 
Powered by phpBB® Forum Software