Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-03-10
00:29 • Closed ticket [801429ffff]: Tcl_SetMainLoop: not thread safe? plus 6 other c... artifact: 57b5299076 user: dgp
2010-02-27
19:10 • Pending ticket [801429ffff]. artifact: 3527b8e416 user: dkf
19:10 • Ticket [801429ffff]: 4 changes artifact: 1e1a4eb6c4 user: dkf
2009-12-30
00:16 • Ticket [801429ffff]: 4 changes artifact: 6fe2aaa3c5 user: dkf
2009-12-10
02:48 • Ticket [801429ffff]: 1 change artifact: bd375298c4 user: dgp
2006-10-11
19:47 • Ticket [801429ffff]: 1 change artifact: a122ab5ac5 user: dgp
2005-11-22
02:03 • Ticket [801429ffff]: 5 changes artifact: 9abfd373ca user: dgp
2005-07-08
03:42 • Ticket [801429ffff]: 4 changes artifact: 620fb99f93 user: dgp
2003-09-06
07:44 • Ticket [801429ffff]: 4 changes artifact: 65a8d8b2bc user: mistachkin
2003-09-05
23:30 • New ticket [801429ffff]. artifact: ba08245a22 user: dgp

Tcl_SetMainLoop: not thread safe?

Closed / Fixed801429ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 17 years ago
Descriptionplain2003-09-05 23:30:40
It appears that Tcl_SetMainLoop() -- like
Tcl_Main() -- is not thread safe, and for
that reason should not be in any stubs table.
mistachkinplain2003-09-06 07:44:04
Logged In: YES 
user_id=113501

Is there some reason why it can't be made thread-safe using 
a mutex?
dgpplain2005-07-08 03:42:29
Logged In: YES 
user_id=80530


possibly related chat:

dgpthe half-baked example is the master thread Tcl_Main()...
[16:20]dgpevals a script that brings in the Thread
package, creates a second thread...
[16:20]dgp...then sends a message to [package require Tk]
in that other thread.
[16:21]dgpThat would call Tcl_SetMainLoop and establish an
event loop in the first thread, while it is needed in the
second one.

dgp% package require Thread
2.6.1
% set t [thread::create]
tid0x803
% thread::send $t {package require Tk}
[16:40]dgpdisplays a root window, and then hangs.
dgpplain2005-11-22 02:03:04
Logged In: YES 
user_id=80530

hoping to fix this for 8.4.12
dgp Ticket [801429ffff]: 1 change [History diff]2006-10-11 19:47:17
dgp Ticket [801429ffff]: 1 change [History diff]2009-12-10 02:48:05
dkfplain2009-12-30 00:16:09
Am I correct in saying that this is seeking to install a new main loop from a subsidiary thread when the main thread's main loop is operating? Ooooh....
dkfplain2010-02-27 19:10:47
Pushed the state set by Tcl_SetMainLoop into TSD for Tcl HEAD (8.6). If we really want to support the functionality now as global state, that's also possible (and in fact probably easier than before too given that accesses to the "global" state are now factored out internally).
dkf Pending ticket [801429ffff]. [History diff]2010-02-27 19:10:48
dgpplain2010-03-10 00:29:53
allow_comments - 1


no hang in the half-baked demo anymore.
Log in (anonymous is fine) to add a comment.