touched up user-defined signal handling

This commit is contained in:
hyunghwan.chung 2019-09-18 08:24:05 +00:00
parent 3db6820932
commit e1e577ec22
3 changed files with 29 additions and 29 deletions

View File

@ -31,7 +31,7 @@ class System(Apex)
method(#class) _initialize
{
self.shr := Set new.
self.shr := OrderedCollection new.
self.asyncsg := SemaphoreGroup new.
}
@ -52,7 +52,7 @@ class System(Apex)
method(#class) installSignalHandler: block
{
self.shr add: block.
self.shr addLast: block.
}
method(#class) uninstallSignalHandler: block
@ -168,7 +168,7 @@ class System(Apex)
ifnot (self.shr isEmpty)
{
self.shr do: [ :handler | handler value: signo ]
self.shr do: [ :handler | handler value: signo ].
}
else
{

View File

@ -278,8 +278,8 @@ widget windowHandle dump.
if (self.gcHandle notNil)
{
self.widget displayServer _destroy_gc(self).
self.gcHandle := nil
}
self.gcHandle := nil.
}.
}
method apply
@ -466,6 +466,8 @@ class X11.Composite(X11.Widget)
method remove: widget
{
| link |
if (widget parent notNil) // TODO: DEBUG. check if this widget is being disposed multiple times. I see this method called with 'widget parent' of nil.
{
if (widget parent ~~ self)
{
selfns.Exception signal: "Cannot remove an unknown widget"
@ -474,6 +476,7 @@ class X11.Composite(X11.Widget)
link := self.children findIdenticalLink: widget.
self.children removeLink: link.
widget parent: nil.
}.
}
method childrenCount
@ -499,7 +502,10 @@ class X11.Composite(X11.Widget)
child dispose.
self remove: child.
].
super dispose
'Composite dispose DONE XXXXXXXXXXXXXX' dump.
'SUPER SUPER SUPER dispose' dump.
super dispose.
'SUPER SUPER SUPER dispose DONE' dump.
}
method onPaintEvent: event
@ -655,24 +661,20 @@ extend X11
{
if (self.event_loop_sem isNil)
{
self.event_loop_sem := Semaphore new.
self.event_loop_sem signalOnInput: (self _get_fd).
self.event_loop_proc := [
[
| llevtbuf llevent ongoing |
| llevtbuf llevent |
self.event_loop_exit_req := false.
llevtbuf := X11.LLEvent new.
ongoing := true.
while (self.shell_container childrenCount > 0)
{
'Waiting for X11 event...' dump.
if (self.event_loop_exit_req) { break }.
self.event_loop_sem wait.
if (self.event_loop_exit_req) { break }.
ifnot (ongoing) { break }.
while ((llevent := self _get_llevent(llevtbuf)) notNil)
{
@ -680,7 +682,6 @@ extend X11
{
//System logNl: ('Error while getting a event from server ' & self.cid asString).
self.event_loop_exit_req := true.
ongoing := false.
break.
}
else
@ -690,9 +691,7 @@ extend X11
}.
}.
] ensure: [
'CLOSING X11 EVENT LOOP' dump.
//self.event_loop_sem signal. // in case the process is suspended in self.event_loop_sem wait.
self.event_loop_sem unsignal.
// TODO: LOOK HERE FOR RACE CONDITION with exitEventLoop.
@ -701,10 +700,16 @@ extend X11
[ self dispose ] on: Exception do: [:ex | ("WARNING: dispose failure...." & ex messageText) dump ].
]
] fork.
] newProcess.
self.event_loop_proc resume.
}
}
/////////////////////////////////////////
// TOOD: exitEventLoop to terminate the whole process by force or
// requestToExit to signal process after having set a flag?
// what is better?
method exitEventLoop
{
if (self.event_loop_sem notNil)
@ -716,16 +721,12 @@ extend X11
}
}
method signal_event_loop_semaphore
{
self.event_loop_sem signal.
}
method requestToExit
{
self.event_loop_exit_req := true.
self.event_loop_sem signal.
}
/////////////////////////////////////////
method __dispatch_llevent: llevent
{
@ -810,7 +811,6 @@ class MyObject(Object)
method initialize
{
self.on_sig := [:sig |
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx' dump.
self.disp1 requestToExit.
self.disp2 requestToExit.
].

View File

@ -613,7 +613,7 @@ static void dump_process_info (moo_t* moo, moo_bitmask_t log_mask)
{
moo_ooi_t io_handle;
MOO_LOG0 (moo, log_mask, "> IO Semaphores:");
MOO_LOG0 (moo, log_mask, "> IO semaphores:");
for (io_handle = 0; io_handle < moo->sem_io_map_capa; io_handle++)
{
moo_ooi_t index;