slightly faster path for port-commit-peeked with always-evt

svn: r2794
This commit is contained in:
Matthew Flatt 2006-04-26 12:55:01 +00:00
parent 1eee81ca66
commit 1ec48e2e83

View File

@ -1872,7 +1872,7 @@ int scheme_peeked_read_via_get(Scheme_Input_Port *ip,
Scheme_Type t; Scheme_Type t;
Scheme_Object * volatile target_evt = _target_evt; Scheme_Object * volatile target_evt = _target_evt;
/* Check whether t's even t value is known to be always itself: */ /* Check whether t's event value is known to be always itself: */
t = SCHEME_TYPE(target_evt); t = SCHEME_TYPE(target_evt);
if (!SAME_TYPE(t, scheme_sema_type) if (!SAME_TYPE(t, scheme_sema_type)
&& !SAME_TYPE(t, scheme_channel_put_type) && !SAME_TYPE(t, scheme_channel_put_type)
@ -1928,6 +1928,11 @@ int scheme_peeked_read_via_get(Scheme_Input_Port *ip,
/* No other thread is trying to commit. This one is hereby /* No other thread is trying to commit. This one is hereby
elected "main" if multiple threads try to commit. */ elected "main" if multiple threads try to commit. */
if (SAME_TYPE(t, scheme_always_evt_type)) {
/* Fast path: always-evt is ready */
return complete_peeked_read_via_get(ip, size);
}
/* This sema makes other threads wait before reading: */ /* This sema makes other threads wait before reading: */
sema = scheme_make_sema(0); sema = scheme_make_sema(0);
ip->input_lock = sema; ip->input_lock = sema;