--- a/ExternalLibraryFunction.st Mon Jun 19 09:35:06 2017 +0200
+++ b/ExternalLibraryFunction.st Mon Jun 19 14:44:08 2017 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 2004 by eXept Software AG
All Rights Reserved
@@ -187,61 +185,61 @@
example
"
- [exBegin]
- |f|
+ [exBegin]
+ |f|
- f := ExternalLibraryFunction new.
- f beCallTypeWINAPI.
+ f := ExternalLibraryFunction new.
+ f beCallTypeWINAPI.
- f name:'MessageBeep'
- module:'user32.dll'
- returnType:#boolean
- argumentTypes:#(uint).
+ f name:'MessageBeep'
+ module:'user32.dll'
+ returnType:#boolean
+ argumentTypes:#(uint).
- f invokeWith:1.
- [exEnd]
+ f invokeWith:1.
+ [exEnd]
Synchronous vs. Asynchronous calls:
by default, foreign function calls are synchronous, effectively blocking the whole ST/X system
- (that is by purpose,´because most C-code is not prepared for being interrupted, and also, normal
+ (that is by purpose,´because most C-code is not prepared for being interrupted, and also, normal
code is not prepared for a garbage collector to move objects around, while another C thread might
access the data...).
Therefore, the following will block all ST/X activity for 10 seconds
(try interacting with the launcher while the Sleep is performing):
- [exBegin]
- |f|
+ [exBegin]
+ |f|
- f := ExternalLibraryFunction new.
- f beCallTypeWINAPI.
+ f := ExternalLibraryFunction new.
+ f beCallTypeWINAPI.
- f name:'Sleep'
- module:'kernel32.dll'
- returnType:#void
- argumentTypes:#(uint).
+ f name:'Sleep'
+ module:'kernel32.dll'
+ returnType:#void
+ argumentTypes:#(uint).
- f invokeWith:10000.
- [exEnd]
+ f invokeWith:10000.
+ [exEnd]
if you know what you do and you do not pass any possibly moving objects (such as strings) as argument,
the call can be made asynchronous. In that case, ONLY the calling thread will be blocked; all other smalltalk
- threads wil continue to execute.
+ threads will continue to execute.
(try interacting now with the launcher while the Sleep is performing):
- [exBegin]
- |f|
+ [exBegin]
+ |f|
- f := ExternalLibraryFunction new.
- f beCallTypeWINAPI.
- f beAsync.
+ f := ExternalLibraryFunction new.
+ f beCallTypeWINAPI.
+ f beAsync.
- f name:'Sleep'
- module:'kernel32.dll'
- returnType:#void
- argumentTypes:#(uint).
+ f name:'Sleep'
+ module:'kernel32.dll'
+ returnType:#void
+ argumentTypes:#(uint).
- f invokeWith:10000.
- [exEnd]
+ f invokeWith:10000.
+ [exEnd]
"
! !